@roomi-fields/grillhouse 0.37.1 → 0.38.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 (47) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +26 -0
  3. package/charte.md +8 -1
  4. package/dist/temporal/circuit/activites.js +4 -1
  5. package/dist/temporal/circuit/activites.js.map +1 -1
  6. package/dist/temporal/places/contrat.d.ts +2 -0
  7. package/dist/temporal/tickets/activites.js +7 -2
  8. package/dist/temporal/tickets/activites.js.map +1 -1
  9. package/docs/ARCHITECTURE.md +7 -2
  10. package/docs/INTERFACE.md +8 -3
  11. package/hooks/register.tsx +95 -78
  12. package/package.json +1 -1
  13. package/scripts/activites.mjs +54 -13
  14. package/scripts/circuit.mjs +16 -5
  15. package/scripts/circuits-cles.d.mts +3 -0
  16. package/scripts/circuits-cles.mjs +20 -0
  17. package/scripts/composition-des-langages.mjs +1 -0
  18. package/scripts/dependances-internes.mjs +9 -2
  19. package/scripts/donnees-cles.mjs +0 -1
  20. package/scripts/enveloppe/enveloppe.mjs +1 -1
  21. package/scripts/file-des-tickets.d.mts +6 -0
  22. package/scripts/file-des-tickets.mjs +30 -4
  23. package/scripts/grillhouse-maj.mjs +4 -3
  24. package/scripts/groupe-cles.mjs +4 -2
  25. package/scripts/integration/integrer.mjs +13 -6
  26. package/scripts/jointure.d.ts +9 -0
  27. package/scripts/langages/cargo/commandes.mjs +11 -3
  28. package/scripts/langages/cargo/index.mjs +2 -1
  29. package/scripts/langages/cargo/verdict.mjs +14 -0
  30. package/scripts/langages/python/index.mjs +2 -0
  31. package/scripts/langages/typescript/code-mort.mjs +59 -9
  32. package/scripts/langages/typescript/index.mjs +7 -4
  33. package/scripts/langages/typescript/vitest-config/base.mjs +3 -0
  34. package/scripts/langages/typescript/vitest.nuit.config.mjs +1 -0
  35. package/scripts/ligne-etat/ligne-etat.mjs +20 -4
  36. package/scripts/nuit.sh +6 -3
  37. package/scripts/prefixe-des-tickets.mjs +12 -0
  38. package/scripts/regles-des-places.d.mts +4 -0
  39. package/scripts/regles-des-places.mjs +11 -2
  40. package/scripts/services-du-noyau.mjs +1 -0
  41. package/scripts/suiveur.mjs +362 -0
  42. package/scripts/tableau.mjs +100 -73
  43. package/scripts/ticket.sh +4 -2
  44. package/scripts/transitions.d.mts +2 -0
  45. package/scripts/transitions.mjs +38 -4
  46. package/scripts/un-commit-par-ticket.mjs +21 -24
  47. package/skills/pitmaster/SKILL.md +9 -0
@@ -42,7 +42,8 @@ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'no
42
42
  import { tmpdir } from 'node:os';
43
43
  import path from 'node:path';
44
44
  import { pathToFileURL } from 'node:url';
45
- import { horsCadre } from '../../paquets.mjs';
45
+ import { fournisseursDuPaquet } from '../../services-du-noyau.mjs';
46
+ import { horsCadre, paquets as paquetsDuDepot } from '../../paquets.mjs';
46
47
  import { MODE, trancher } from '../../dette.mjs';
47
48
  import { isTestFile } from './regle-des-tests.mjs';
48
49
 
@@ -92,17 +93,57 @@ export function constats(texte, genres = Object.keys(GENRES)) {
92
93
 
93
94
  const liste = v => (v === undefined ? [] : [v].flat());
94
95
 
96
+ // The providers of `grillhouse.donnees` of each consumer (`.` the root, else its folder), in the
97
+ // consumers' order; a faulty key throws its faults.
98
+ function fournisseursParConsommateur(racine) {
99
+ return ['.', ...paquetsDuDepot(racine).map(p => p.dossier)]
100
+ .map(dossier => [dossier, fournisseursDuPaquet(racine, dossier)])
101
+ .filter(([, noms]) => noms.length);
102
+ }
103
+
104
+ const sansDoublon = (...listes) => [...new Set(listes.flat())];
105
+
106
+ // The settings with the providers of `grillhouse.donnees` in `ignoreDependencies`: a provider is
107
+ // used as a datum of its consumer's tests, not dead. Each goes in its consumer's workspace
108
+ // (`workspaces["<folder>"]`, the settings knip gives that folder kept), at the top level for the
109
+ // root; a project without `workspaces` gets a `.` key holding its top-level settings, so they keep
110
+ // their effect on the root.
111
+ function avecLesFournisseurs(knipLu, r, consommateurs) {
112
+ const racineSeule = consommateurs.every(([d]) => d === '.');
113
+ if (racineSeule && !r.workspaces) {
114
+ return {
115
+ ...r,
116
+ ignoreDependencies: sansDoublon(liste(r.ignoreDependencies), consommateurs[0][1]),
117
+ };
118
+ }
119
+ const espaces = { ...r.workspaces };
120
+ if (!r.workspaces) {
121
+ espaces['.'] = reglagesDeEspace(knipLu, r, '.');
122
+ }
123
+ for (const [dossier, noms] of consommateurs) {
124
+ const base = espaces[dossier] ?? (dossier === '.' ? {} : reglagesDeEspace(knipLu, r, dossier));
125
+ espaces[dossier] = {
126
+ ...base,
127
+ ignoreDependencies: sansDoublon(liste(base.ignoreDependencies), noms),
128
+ };
129
+ }
130
+ return { ...r, workspaces: espaces };
131
+ }
132
+
95
133
  // The knip settings of the repository at <racine> with its packages out of the frame skipped:
96
134
  // its `knip.json` (empty without one) plus `ignoreWorkspaces` for each listed directory under
97
- // `packages/` and `ignore` for each listed directory under `packages/` and `src/`; null when the
98
- // list names nothing.
99
- function reglages(racine) {
135
+ // `packages/` and `ignore` for each listed directory under `packages/` and `src/`, and the
136
+ // providers of `grillhouse.donnees` (`avecLesFournisseurs`); null when neither the list nor a
137
+ // datum exists. A faulty `grillhouse.donnees` key throws its faults.
138
+ function reglages(knipLu, racine) {
100
139
  const hors = [...horsCadre(racine)].sort();
101
- if (!hors.length) {
140
+ const consommateurs = fournisseursParConsommateur(racine);
141
+ if (!hors.length && !consommateurs.length) {
102
142
  return null;
103
143
  }
104
144
  const fichier = path.join(racine, 'knip.json');
105
- const r = existsSync(fichier) ? JSON.parse(readFileSync(fichier, 'utf8')) : {};
145
+ const lu = existsSync(fichier) ? JSON.parse(readFileSync(fichier, 'utf8')) : {};
146
+ const r = consommateurs.length ? avecLesFournisseurs(knipLu, lu, consommateurs) : lu;
106
147
  const espaces = [];
107
148
  const motifs = [];
108
149
  for (const nom of hors) {
@@ -116,6 +157,9 @@ function reglages(racine) {
116
157
  motifs.push(`${parent}/${nom}/**`);
117
158
  }
118
159
  }
160
+ if (!hors.length) {
161
+ return r;
162
+ }
119
163
  return {
120
164
  ...r,
121
165
  ignore: [...liste(r.ignore), ...motifs],
@@ -311,10 +355,7 @@ function knip(racine, config, include) {
311
355
  // is written, and the debt's mode is <env>'s `GRILLHOUSE_DETTE`.
312
356
  export async function codeMort(racine, env = process.env) {
313
357
  const lignes = [];
314
- const hors = reglages(racine);
315
358
  const fichierKnip = path.join(racine, 'knip.json');
316
- const config =
317
- hors ?? (existsSync(fichierKnip) ? JSON.parse(readFileSync(fichierKnip, 'utf8')) : null);
318
359
  const DEPS = ['dependencies', 'devDependencies'];
319
360
  const { fichiers, dossiers, erreur } = fichiersTests(racine);
320
361
  if (erreur) {
@@ -328,6 +369,15 @@ export async function codeMort(racine, env = process.env) {
328
369
  );
329
370
  return { lignes, code: 1 };
330
371
  }
372
+ let hors;
373
+ try {
374
+ hors = reglages(knipLu, racine);
375
+ } catch (e) {
376
+ lignes.push(`⛔ CODE MORT — ${e.message.replace(/^⛔ /, '')}`);
377
+ return { lignes, code: 1 };
378
+ }
379
+ const config =
380
+ hors ?? (existsSync(fichierKnip) ? JSON.parse(readFileSync(fichierKnip, 'utf8')) : null);
331
381
  const premier = knip(racine, hors ?? config);
332
382
  const c1 = constats(premier.stdout ?? '');
333
383
  const second = fichiers.length
@@ -215,12 +215,13 @@ export default {
215
215
  // Where its tools write: the cache of Turborepo in the main tree, shared by every copy, written;
216
216
  // the logs of Turborepo's tasks (`.turbo/turbo-<task>.log`, written on every run, a task replayed
217
217
  // from its cache included, and which no option of Turborepo sends elsewhere) and the cache of
218
- // Vite, where Vitest writes the results of a run (`node_modules/.vite/vitest/`) and whose failure
219
- // fails it, proper to the session; and the cache of ESLint and Prettier (`.cache-outils/`),
220
- // proper to the session too, an empty one costing a whole reading, as without a cache.
218
+ // Vite, where Vitest writes the results of a run (`.cache-outils/vite/vitest/`, the `cacheDir` of
219
+ // the base configurations: a copy's `node_modules` is a link, so nothing under it is a clean
220
+ // output) and whose failure fails it; and the cache of ESLint and Prettier (`.cache-outils/`),
221
+ // proper to the session, an empty one costing a whole reading, as without a cache.
221
222
  sorties: {
222
223
  ecrites: ['//.turbo/cache/'],
223
- propres: ['.turbo', 'node_modules/.vite', '.cache-outils'],
224
+ propres: ['.turbo', '.cache-outils'],
224
225
  lues: [],
225
226
  },
226
227
  // The test tool run directly, Vitest or Turborepo that plays it: `npm test` and `npm run
@@ -267,6 +268,8 @@ export default {
267
268
  ...Object.fromEntries(OUTILS.map(n => [n, { script: ici(`${n}.mjs`), args: [] }])),
268
269
  }),
269
270
  verdict,
271
+ // A build failure is already a red `build` task here; no test task bears a compilation failure.
272
+ echecDeCompilation: () => false,
270
273
  estUnTest,
271
274
  // A night test, a bench or a time witness (./vitest-config/cibles.mjs, `estHorsDuJour`).
272
275
  horsDuJour: (chemin, racine) => estHorsDuJour(path.resolve(racine, chemin)),
@@ -145,6 +145,9 @@ function baseDeVitest() {
145
145
 
146
146
  export default {
147
147
  plugins: [baseDeVitest(), ciblage()],
148
+ // The cache of Vite, where Vitest writes its results (`vitest/results.json`), under the clean
149
+ // output `.cache-outils` of the module: never under `node_modules`, a link in a copy.
150
+ cacheDir: '.cache-outils/vite',
148
151
  test: {
149
152
  environment: 'node',
150
153
  env: {
@@ -21,6 +21,7 @@ import { DELAI_NUIT_MS } from './vitest-config/bornes.mjs';
21
21
 
22
22
  export default {
23
23
  plugins: [nuit()],
24
+ cacheDir: base.cacheDir,
24
25
  test: {
25
26
  env: base.test.env,
26
27
  environment: base.test.environment,
@@ -7,14 +7,16 @@
7
7
  // - The left part: the status line command of the person's own settings (~/.claude/settings.json),
8
8
  // run on the same input; without one, `defaut.sh` beside this file.
9
9
  // - The right part: `grillhouse-etat.txt` in the project's common git directory, which each
10
- // measure of the board writes (`scripts/tableau.mjs`), dim, aligned on the terminal's width
11
- // (COLUMNS), on the first line.
10
+ // measure of the follower writes (`scripts/suiveur.mjs`), dim, aligned on the terminal's width
11
+ // (COLUMNS), on the first line; nothing when that measure is older than 10 minutes.
12
12
  import { execFileSync } from 'node:child_process';
13
13
  import { readFileSync } from 'node:fs';
14
14
  import os from 'node:os';
15
15
  import path from 'node:path';
16
16
  import { fileURLToPath, pathToFileURL } from 'node:url';
17
17
 
18
+ import { lireEtat } from '../suiveur.mjs';
19
+
18
20
  const ICI = path.dirname(fileURLToPath(import.meta.url));
19
21
  // The columns Claude Code keeps around the status line: two before it, two after.
20
22
  const MARGE = 4;
@@ -69,7 +71,21 @@ function sortie(commande, entree, cwd) {
69
71
  }
70
72
  }
71
73
 
72
- // The chantier in progress the board last wrote for the project at `projet`, or ''.
74
+ /**
75
+ * The status text the follower wrote in `commun`, or '' without a file, with an unreadable one,
76
+ * or when its measure is older than 10 minutes (no follower runs). It measures nothing.
77
+ * @param {string} commun the project's common git directory
78
+ * @param {number} maintenant
79
+ */
80
+ export function etatDuFichier(commun, maintenant) {
81
+ try {
82
+ return lireEtat(readFileSync(path.join(commun, 'grillhouse-etat.txt'), 'utf8'), maintenant);
83
+ } catch {
84
+ return '';
85
+ }
86
+ }
87
+
88
+ // The chantier in progress the follower last wrote for the project at `projet`, or ''.
73
89
  function etat(projet) {
74
90
  try {
75
91
  const commun = execFileSync(
@@ -77,7 +93,7 @@ function etat(projet) {
77
93
  ['-C', projet, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
78
94
  { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }
79
95
  ).trim();
80
- return readFileSync(path.join(commun, 'grillhouse-etat.txt'), 'utf8').split('\n')[0].trim();
96
+ return etatDuFichier(commun, Date.now()).split('\n')[0].trim();
81
97
  } catch {
82
98
  return '';
83
99
  }
package/scripts/nuit.sh CHANGED
@@ -357,7 +357,7 @@ ouverts=
357
357
  commentes=" "
358
358
  # Reports one cause: comments the open night ticket whose title names it (once a night), or opens
359
359
  # its own (title « number — subject — parent », the number being the id without the project's
360
- # prefix as `bd config get issue_prefix` gives it, the subject naming « <cause> »); its id goes to
360
+ # prefix as `prefixe` reads it in `.beads/config.yaml`, the subject naming « <cause> »); its id goes to
361
361
  # `numero`.
362
362
  signaler() {
363
363
  local cause="$1" sujet="$2" texte="$3" ouvert neuf= prefixe
@@ -372,8 +372,11 @@ signaler() {
372
372
  esac
373
373
  else
374
374
  neuf="$(cd "$racine" && bd create "$sujet" -t bug -p 1 -l nuit -d "$texte" --silent)"
375
- prefixe="$(cd "$racine" && bd config get issue_prefix 2>/dev/null)"
376
- [ -n "$neuf" ] && (cd "$racine" && bd update "$neuf" --title "${neuf#"$prefixe"-} — $sujet — parent" >/dev/null)
375
+ if prefixe="$(node "$ici/prefixe-des-tickets.mjs" "$racine" 2>&1)"; then
376
+ [ -n "$neuf" ] && (cd "$racine" && bd update "$neuf" --title "${neuf#"$prefixe"-} — $sujet — parent" >/dev/null)
377
+ else
378
+ echo "⛔ ${prefixe}" >> "$journal"
379
+ fi
377
380
  fi
378
381
  numero="${ouvert:-$neuf}"
379
382
  }
@@ -6,6 +6,7 @@
6
6
  // (the migration 0.30.0 « préfixe des tickets »).
7
7
  import { readFileSync, writeFileSync } from 'node:fs';
8
8
  import path from 'node:path';
9
+ import { pathToFileURL } from 'node:url';
9
10
 
10
11
  export const CONFIG_BEADS = '.beads/config.yaml';
11
12
 
@@ -66,3 +67,14 @@ export function ecrireLePrefixe(racine, valeur) {
66
67
  );
67
68
  return ligne;
68
69
  }
70
+
71
+ // Run as `node prefixe-des-tickets.mjs <racine>`, the shell scripts (ticket.sh, nuit.sh) read the
72
+ // prefix by the same function: it prints the prefix, or the message of the refusal with exit 1.
73
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
74
+ try {
75
+ process.stdout.write(prefixe(process.argv[2] ?? process.cwd()));
76
+ } catch (e) {
77
+ process.stderr.write(`${e.message}\n`);
78
+ process.exitCode = 1;
79
+ }
80
+ }
@@ -80,6 +80,8 @@ export interface PlaceDeCircuit {
80
80
  creation?: string;
81
81
  /** The identity of its project's group, absent out of a group. */
82
82
  groupe?: string;
83
+ /** The places of circuits its project holds at most, as its last demand said; absent unbounded. */
84
+ max?: number;
83
85
  }
84
86
 
85
87
  /**
@@ -98,6 +100,8 @@ export function reserverDesCircuits(
98
100
  reprise?: { ticket: string; rang: number | null };
99
101
  groupe?: string;
100
102
  priorites?: Record<string, { priorite: number; creation: string }>;
103
+ /** The places of circuits the project holds at most (`grillhouse.circuits`). */
104
+ max?: number;
101
105
  },
102
106
  o: { rang: number; plafond: number; maintenant: number; reservee?: boolean }
103
107
  ): { circuits: PlaceDeCircuit[]; rang: number; accordes: string[] };
@@ -152,12 +152,17 @@ export const reservationPerimee = (reservation, maintenant) =>
152
152
  * of arrival again by priority (P0 to P4), age, then rank. A circuit already granted keeps its
153
153
  * place (a higher priority arriving later passes only the ones that wait), a project out of a
154
154
  * group and the order of the groups between them keep the order of arrival.
155
+ *
156
+ * The project <racine> holds at most <max> places of circuits (`grillhouse.circuits`, read by
157
+ * scripts/circuits-cles.mjs), the circuits resumed after their question with the others: past it,
158
+ * its circuits that wait keep waiting, whichever project's demand judges them, and the other
159
+ * projects still pass.
155
160
  * @param {Array<{ racine: string, ticket: string, rang: number, accordee: boolean, depuis: number,
156
161
  * vu: number, reprise?: boolean, raison?: string | null, priorite?: number, creation?: string,
157
162
  * groupe?: string }>} places
158
163
  * @param {{ racine: string, vivants?: string[], candidats?: string[], disque?: string | null,
159
164
  * reprise?: { ticket: string, rang: number | null }, groupe?: string,
160
- * priorites?: Record<string, { priorite: number, creation: string }> }} demande
165
+ * priorites?: Record<string, { priorite: number, creation: string }>, max?: number }} demande
161
166
  * @param {{ rang: number, plafond: number, maintenant: number, reservee?: boolean }} o `reservee`:
162
167
  * the machine is reserved by the night, no place is given
163
168
  */
@@ -170,6 +175,7 @@ export function reserverDesCircuits(places, demande, o) {
170
175
  reprise,
171
176
  groupe,
172
177
  priorites = {},
178
+ max,
173
179
  } = demande;
174
180
  const { plafond, maintenant, reservee = false } = o;
175
181
  let { rang } = o;
@@ -181,6 +187,7 @@ export function reserverDesCircuits(places, demande, o) {
181
187
  // What the demand says of a ticket's place: its group, its priority and its creation.
182
188
  const dit = ticket => ({
183
189
  ...(groupe === undefined ? {} : { groupe }),
190
+ ...(max === undefined ? {} : { max }),
184
191
  ...(priorites[ticket] === undefined
185
192
  ? {}
186
193
  : { priorite: priorites[ticket].priorite, creation: priorites[ticket].creation }),
@@ -235,12 +242,14 @@ export function reserverDesCircuits(places, demande, o) {
235
242
  });
236
243
  }
237
244
  let tenues = circuits.filter(c => c.accordee).length;
245
+ // The places of circuits each project holds, under the bound its last demand carried (`max`).
246
+ const tenuesDe = r => circuits.filter(c => c.accordee && c.racine === r).length;
238
247
  for (const c of circuits.filter(x => !x.accordee).sort((a, b) => a.rang - b.rang)) {
239
248
  // Under the reservation of the night no place is new: circuits alive keep theirs.
240
249
  if (reservee || tenues >= plafond) {
241
250
  break;
242
251
  }
243
- if (c.raison) {
252
+ if (c.raison || (c.max !== undefined && tenuesDe(c.racine) >= c.max)) {
244
253
  continue;
245
254
  }
246
255
  c.accordee = true;
@@ -18,6 +18,7 @@ export { garderLeTotal, inscrireLePlan, ouvrirAvancement } from './avancement.mj
18
18
  export { sources } from './sources.mjs';
19
19
  export { trouverDansLePath } from './commandes-du-path.mjs';
20
20
  export { paquetsSansPackageJson } from './paquet-npm.mjs';
21
+ export { fournisseursDuPaquet } from './donnees-cles.mjs';
21
22
  export { poserLeGabaritAbsent } from './gabarit-absent.mjs';
22
23
  export {
23
24
  cheminsDeLaTache,