@roomi-fields/grillhouse 0.28.1 → 0.28.2

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.
@@ -5,5 +5,5 @@
5
5
  "author": {
6
6
  "name": "Romain Peyrichou"
7
7
  },
8
- "version": "0.28.1"
8
+ "version": "0.28.2"
9
9
  }
@@ -1,7 +1,7 @@
1
1
  import { atom, read, update } from 'claude-code'
2
2
  import type { EngineInterface, Register } from 'claude-code'
3
3
 
4
- import type { Etat, Fiche, Ligne, Lu, Tableau } from '../types'
4
+ import type { Etat, Fiche, Ligne, Tableau } from '../types'
5
5
 
6
6
  // The board of a Grillhouse project, in the pane (/grillhouse) on its three levels. The frame's
7
7
  // command of the project (`node_modules/.bin/grillhouse tableau`, the package
@@ -15,8 +15,9 @@ import type { Etat, Fiche, Ligne, Lu, Tableau } from '../types'
15
15
  // session, an agent's copy included, has a Bash command that starts with cd refused, with the
16
16
  // form to take (`env -C`, `git -C`). A session that coordinates several projects adds them to its
17
17
  // pane (`/grillhouse ajouter <chemin>`, `/grillhouse retirer <chemin>`), as a multi-root workspace
18
- // of VS Code lists its folders: the list is kept for the session's folder in the mod's store, each
19
- // project's board is measured in its folder, and the pane fuses them (`fusionner`).
18
+ // of VS Code lists its folders: the list is kept for the session's folder in the mod's store, and
19
+ // the frame's command measures their board as one (`grillhouse tableau <dossier>…`), which the
20
+ // pane draws as it draws one project's.
20
21
  const PANE = 'grillhouse'
21
22
  // The frame's command, which the project's `npm install` links, and its package.
22
23
  const GRILLHOUSE = 'node_modules/.bin/grillhouse'
@@ -59,6 +60,7 @@ const etat = atom({ plugin: 'grillhouse', key: 'etat' } as const, {
59
60
  tableau: null,
60
61
  erreur: null,
61
62
  lu: 0,
63
+ revision: 0,
62
64
  choisi: null,
63
65
  element: null,
64
66
  grand: false,
@@ -134,10 +136,38 @@ export const defiler = (avant: number, by: number, n: number, rangs: number) =>
134
136
  // A line the pane lists, the key of its Button and `i`, its index in the lines shown.
135
137
  export type Visible = { l: Ligne; cle: string | null; i: number }
136
138
 
137
- // The lines the pane lists, each with the key of its Button: `<ticket>:<i>` for a ticket's line,
138
- // `>:<i>` for a folded group's title, none for a plain line.
139
+ // The lines the pane lists, each with the key of its Button: `<ticket>:<n>` for the n-th line of a
140
+ // ticket (from 0), `>:<groupe>` for a folded group's title, none for a plain line. A key names its
141
+ // line by what it shows, never by its place, as React's keys do: a new measure that adds lines
142
+ // above keeps the key the ring holds.
139
143
  export function visibles(lignes: Ligne[]): Visible[] {
140
- return lignes.map((l, i) => ({ l, cle: l.ticket ? `${l.ticket}:${i}` : l.groupe ? `>:${i}` : null, i }))
144
+ const vus = new Map<string, number>()
145
+ return lignes.map((l, i) => {
146
+ if (l.ticket) {
147
+ const n = vus.get(l.ticket) ?? 0
148
+ vus.set(l.ticket, n + 1)
149
+ return { l, cle: `${l.ticket}:${n}`, i }
150
+ }
151
+ return { l, cle: l.groupe ? `>:${l.groupe}` : null, i }
152
+ })
153
+ }
154
+
155
+ // A computation kept from its last inputs, as React's useMemo keeps it from its dependencies:
156
+ // called with the same dependencies (each the same value; by default every argument), it gives
157
+ // the last result again without computing it.
158
+ export function memoire<A extends unknown[], R>(
159
+ calcul: (...a: A) => R,
160
+ dependances: (...a: A) => unknown[] = (...a) => a,
161
+ ): (...a: A) => R {
162
+ let dernier: { d: unknown[]; r: R } | null = null
163
+ return (...a: A) => {
164
+ const d = dependances(...a)
165
+ const avant = dernier
166
+ if (avant && avant.d.length === d.length && d.every((x, j) => Object.is(x, avant.d[j]))) return avant.r
167
+ const r = calcul(...a)
168
+ dernier = { d, r }
169
+ return r
170
+ }
141
171
  }
142
172
 
143
173
  // The first of `n` lines to show in `rangs` rows: the window stays where it was (`avant`) while the
@@ -219,122 +249,61 @@ export function dossierDe(chemin: string, dossier: string, maison = ''): string
219
249
  return `/${parts.join('/')}`
220
250
  }
221
251
 
222
- // A project's label in a fused board: its ticket prefix, else its folder's name.
223
- const nomDu = (dossier: string) => dossier.split('/').filter(Boolean).pop() ?? dossier
224
- const etiquetteDe = (l: Lu) => l.tableau?.prefixe || nomDu(l.dossier)
225
-
226
- // The width of the step's column in a fused board, « 3 Code », « ? Question ».
227
- const ETAPE = 13
228
- // A ticket line's step in words: « ? Question » stopped on a question, « ■ Arrêté » after the
229
- // steps, else its number and title.
230
- const libelleDEtape = (l: Ligne) =>
231
- l.question ? '? Question' : l.etape?.numero ? `${l.etape.numero} ${l.etape.titre}` : '■ Arrêté'
232
- // The rank a ticket line sorts by in a fused board, the maquette's order: the steps from the last
233
- // to the first, a step after its sub-steps (« 4 » is « 4.0 »), then the questions, then the
234
- // circuits stopped after the steps.
235
- const rangDe = (l: Ligne): number[] =>
236
- l.question ? [1] : l.etape?.numero ? [0, ...l.etape.numero.split('.').map(n => -Number(n))] : [2]
237
- const comparer = (a: number[], b: number[]) => {
238
- for (let i = 0; i < Math.max(a.length, b.length); i++) {
239
- const d = (a[i] ?? 0) - (b[i] ?? 0)
240
- if (d) return d
241
- }
242
- return 0
243
- }
244
- const couperA = (x: string, n: number) => (x.length > n ? `${x.slice(0, n - 1)}…` : x)
245
-
246
- // The boards of several projects fused into one, the owner's maquette (grillhouse-erp): the tickets
247
- // at a step of each project in one list sorted by step, each line « <étape> [<projet>] <id> —
248
- // <sujet> », then each project's chantiers prefixed by its label; the states' view of each project
249
- // under its label; every card, and the folder of each ticket's project (`dossiers`); a footer
250
- // (`pied`) that sums up each project, « osc 2▶ · SH 1▶ 3 en attente · OSD 0 », and names each
251
- // project whose board does not read with its fault.
252
- export function fusionner(lus: Lu[]): Tableau {
253
- const lisibles = lus.flatMap(l => (l.tableau && !l.erreur ? [{ ...l, tableau: l.tableau }] : []))
254
- const fautifs = lus.filter(l => !l.tableau || l.erreur)
255
- const large = Math.max(0, ...lisibles.map(l => etiquetteDe(l).length + 2))
256
- const prefixe = (l: Lu) => `[${etiquetteDe(l)}]`.padEnd(large)
257
- const tickets = lisibles.flatMap(lu =>
258
- lu.tableau.lignes
259
- .filter(l => l.section === 'agents' && l.ticket && l.etape)
260
- .map(l => ({
261
- ...l,
262
- texte: `${couperA(libelleDEtape(l), ETAPE).padEnd(ETAPE)} ${prefixe(lu)} ${l.ticket} — ${lu.tableau.fiches[l.ticket ?? '']?.titre ?? ''}`,
263
- })),
264
- )
265
- tickets.sort((a, b) => comparer(rangDe(a), rangDe(b)))
266
- const chantiers = lisibles.flatMap(lu =>
267
- lu.tableau.lignes
268
- .filter(l => l.chantier && l.ticket)
269
- .map(l => ({ ...l, texte: `[${etiquetteDe(lu)}] ${l.texte}` })),
270
- )
271
- const vueEtats: Ligne[] = lisibles.flatMap((lu, i) => [
272
- ...(i ? [{ texte: '', section: 'etats' as const }] : []),
273
- { texte: etiquetteDe(lu), ton: 'titre' as const, section: 'etats' as const },
274
- ...(lu.tableau.vueEtats ?? []),
275
- ])
276
- // The summaries share a line while they fit the pane's width, then go on to the next.
277
- const pied: Ligne[] = []
278
- for (const lu of lisibles) {
279
- const c = lu.tableau.global?.compteurs
280
- const resume = [
281
- etiquetteDe(lu),
282
- ...(c?.enCours ? [`${c.enCours}▶`] : []),
283
- ...(c?.enAttente ? [`${c.enAttente} en attente`] : []),
284
- ...(!c?.enCours && !c?.enAttente ? ['0'] : []),
285
- ].join(' ')
286
- const avant = pied[pied.length - 1]
287
- if (avant && avant.texte.length + 3 + resume.length <= COLONNES) avant.texte += ` · ${resume}`
288
- else pied.push({ texte: resume, ton: 'discret', section: 'agents' })
289
- }
290
- for (const lu of fautifs) {
291
- const faute = (lu.erreur ?? '').split('\n')[0]?.trim() || 'le tableau ne se lit pas'
292
- pied.push({ texte: `⚠ ${nomDu(lu.dossier)} : ${faute}`, ton: 'alerte', section: 'agents' })
293
- }
294
- const dossiers: Record<string, string> = {}
295
- for (const lu of lisibles) for (const id of Object.keys(lu.tableau.fiches)) dossiers[id] ??= lu.dossier
296
- return {
297
- lignes: [...tickets, ...(chantiers.length ? [{ texte: '', section: 'chantier' as const }, ...chantiers] : [])],
298
- vueEtats,
299
- groupes: {},
300
- fiches: Object.assign({}, ...lisibles.map(l => l.tableau.fiches)) as Tableau['fiches'],
301
- dernier: lisibles.map(l => l.tableau.dernier).find(Boolean) ?? null,
302
- pied,
303
- dossiers,
304
- }
305
- }
306
-
307
252
  // The session's project, whether it is a Grillhouse project, whether the board applies to it, and
308
253
  // whether the board is on.
309
254
  let cwd = ''
310
255
  let projet = false
311
256
  let eligible = false
312
257
  let actif = false
313
- // The pane's window: its first line, the element it last followed, and the rows and focus it was
314
- // last drawn with. The wheel moves it; the ring moving to another line makes it follow.
258
+ // The pane's window: its first line, the element it last followed and that element's line, and
259
+ // the wheel's notches not drawn yet. The wheel moves it; the ring moving to another line makes it
260
+ // follow.
315
261
  let fenetre = 0
316
262
  let suivi: string | null = null
317
- let cadre = { rangs: 1, focus: false }
263
+ let ligneSuivie = -1
264
+ let crans: number[] = []
318
265
  // The whole card's window: the first row of its text shown, and, while it is drawn, the text's
319
266
  // rows and the rows it shows them in.
320
267
  let ligneTexte = 0
321
268
  let texteDessine: { n: number; rangs: number } | null = null
322
-
323
- // The lines the window runs over, every line of the board, the window placed on them: when the
324
- // ring has moved to another line since the window last followed it, the window follows it
325
- // (`debut`); it stays within the lines.
326
- function placer(s: Etat, rangs: number, focus: boolean): Visible[] {
327
- const liste = visibles(lignesDe(s))
328
- const ici = liste.findIndex(x => x.cle === s.element)
329
- if (focus && ici >= 0 && s.element !== suivi) {
269
+ // The lines the pane lists, kept until the board or the view changes.
270
+ const listeDe = memoire(
271
+ (s: Etat) => visibles(lignesDe(s)),
272
+ s => [s.revision, s.vue, s.groupe],
273
+ )
274
+ // The cards the pane has drawn, by their key, kept until the board, the width or the surface's
275
+ // elements change.
276
+ const cartesGardees = memoire(
277
+ (_revision: number, _colonnes: number, _elements: unknown) => new Map<string, JSX.Element>(),
278
+ )
279
+
280
+ // The lines the window runs over, every line of the board, the window placed on them. A board
281
+ // measured again keeps the followed line on its row, as a browser's scroll anchoring keeps the
282
+ // line in view where it was. When the ring has moved to another line since the window last
283
+ // followed it, the window follows it (`debut`). Then the wheel's notches move it, one by one,
284
+ // each within the lines.
285
+ function placer(liste: Visible[], element: string | null, rangs: number, focus: boolean): void {
286
+ const ici = liste.findIndex(x => x.cle === element)
287
+ if (focus && ici >= 0 && element === suivi && ligneSuivie >= 0) fenetre += ici - ligneSuivie
288
+ if (focus && ici >= 0 && element !== suivi) {
330
289
  // The ring's next stops: the nearest lines with a button, above and below.
331
290
  const avant = liste.slice(0, ici).findLastIndex(x => x.cle)
332
291
  const apres = liste.findIndex((x, j) => j > ici && x.cle)
333
292
  fenetre = debut(liste.length, ici, rangs, fenetre, avant < 0 ? ici - 1 : avant, apres < 0 ? ici + 1 : apres)
334
- suivi = s.element
293
+ suivi = element
335
294
  }
295
+ ligneSuivie = ici
336
296
  fenetre = Math.max(0, Math.min(fenetre, liste.length - rangs))
337
- return liste
297
+ for (const by of crans) fenetre = Math.max(0, Math.min(fenetre + by, liste.length - rangs))
298
+ crans = []
299
+ }
300
+
301
+ // Another view starts its window over: at its first line, following nothing, no notch kept.
302
+ function recommencer(): void {
303
+ fenetre = 0
304
+ suivi = null
305
+ ligneSuivie = -1
306
+ crans = []
338
307
  }
339
308
 
340
309
  // Measures the board again and redraws the pane.
@@ -374,35 +343,30 @@ async function bientot($: EngineInterface) {
374
343
  await rafraichir($)
375
344
  }
376
345
 
377
- // The board of the project in <dossier>, or the fault that keeps it out. A board past what a
378
- // process returns (4 MiB) or that does not parse is said, never thrown.
379
- async function lire($: EngineInterface, dossier: string): Promise<Lu> {
380
- const r = await $.process.run([GRILLHOUSE, 'tableau'], { cwd: dossier, timeoutMs: 20_000 })
381
- if (r.exitCode !== 0) return { dossier, tableau: null, erreur: r.stderr.slice(0, 300) }
382
- try {
383
- if (r.isStdoutTruncated) throw new Error('la sortie de grillhouse tableau dépasse 4 Mio')
384
- return { dossier, tableau: JSON.parse(r.stdout) as Tableau, erreur: null }
385
- } catch (err) {
386
- return { dossier, tableau: null, erreur: `Tableau illisible : ${(err as Error).message}`.slice(0, 300) }
387
- }
388
- }
389
-
390
- // The session's board alone, a fault keeping the last board read; with other projects, every
391
- // board, read side by side, fused.
346
+ // The board, the session's project with the projects the pane shows beside it; a fault keeps the
347
+ // last board read. A board past what a process returns (4 MiB) or that does not parse is said,
348
+ // never thrown.
392
349
  async function mesurer($: EngineInterface) {
393
350
  if (!actif) return
394
351
  const { projets } = await read($, etat)
395
- if (projets.length) {
396
- const lus = await Promise.all([cwd, ...projets].map(d => lire($, d)))
397
- await update($, etat, s => ({ ...s, tableau: fusionner(lus), erreur: null, lu: Date.now() }))
352
+ const r = await $.process.run([GRILLHOUSE, 'tableau', ...projets], { cwd, timeoutMs: 20_000 })
353
+ if (r.exitCode !== 0) {
354
+ await update($, etat, s => ({ ...s, erreur: r.stderr.slice(0, 300) }))
398
355
  return
399
356
  }
400
- const { tableau, erreur } = await lire($, cwd)
401
- await update($, etat, s => (tableau ? { ...s, tableau, erreur: null, lu: Date.now() } : { ...s, erreur }))
357
+ let tableau: Tableau
358
+ try {
359
+ if (r.isStdoutTruncated) throw new Error('la sortie de grillhouse tableau dépasse 4 Mio')
360
+ tableau = JSON.parse(r.stdout) as Tableau
361
+ } catch (err) {
362
+ await update($, etat, s => ({ ...s, erreur: `Tableau illisible : ${(err as Error).message}`.slice(0, 300) }))
363
+ return
364
+ }
365
+ await update($, etat, s => ({ ...s, tableau, erreur: null, lu: Date.now(), revision: (s.revision || 0) + 1 }))
402
366
  }
403
367
 
404
- // The folder of the project the ticket <id> belongs to: its own in a fused board, else the
405
- // session's.
368
+ // The folder of the project the ticket <id> belongs to, which the board names beside the
369
+ // session's (`dossiers`); the session's otherwise.
406
370
  const dossierDu = (t: Tableau | null, id: string) => t?.dossiers?.[id] ?? cwd
407
371
 
408
372
  // The whole text of a ticket, read from Beads in its project when the card fills the pane: the
@@ -550,9 +514,10 @@ export const register: Register = on => {
550
514
  return r
551
515
  })
552
516
 
553
- // The pane draws its own rows: the wheel moves its window by `e.by` rows, within its lines, and
554
- // draws it again. On the whole card, the wheel, the arrows and the page keys move its text by
555
- // `e.by` rows, and the engine's window is held on the row under the card's spare top row, so an
517
+ // The pane draws its own rows: each notch of the wheel is kept, and the next render moves the
518
+ // window by every notch kept, one by one within its lines, as a browser folds the scroll events
519
+ // of one frame into one paint: a notch reads nothing and computes nothing. On the whole card,
520
+ // the wheel, the arrows and the page keys move its text by `e.by` rows, and the engine's window is held on the row under the card's spare top row, so an
556
521
  // arrow up scrolls as an arrow down does, wherever the text stands.
557
522
  on('ui.scroll', async ($, e, next) => {
558
523
  if (e.requestId !== PANE) return next(e)
@@ -561,8 +526,7 @@ export const register: Register = on => {
561
526
  $.ui.invalidate('ui.render')
562
527
  return next({ ...e, offset: 1 })
563
528
  }
564
- const liste = placer(await read($, etat), cadre.rangs, cadre.focus)
565
- fenetre = Math.max(0, Math.min(fenetre + e.by, liste.length - cadre.rangs))
529
+ crans.push(e.by)
566
530
  $.ui.invalidate('ui.render')
567
531
  return {}
568
532
  })
@@ -576,11 +540,9 @@ export const register: Register = on => {
576
540
  // Focused, the card shows the chosen ticket; otherwise the one that moved last.
577
541
  const montre = e.props.isFocused ? choisi : (t.dernier ?? choisi)
578
542
  const fiche = montre ? t.fiches[montre] : undefined
579
- // A fused board's footer stands between the list and the rule.
580
- const pied = t.pied ?? []
581
- const rangs = Math.max(1, e.props.scroll.bodyRows - FICHE - 1 - pied.length)
582
- cadre = { rangs, focus: e.props.isFocused }
583
- const liste = placer(s, rangs, e.props.isFocused)
543
+ const rangs = Math.max(1, e.props.scroll.bodyRows - FICHE - 1)
544
+ const liste = listeDe(s)
545
+ placer(liste, element, rangs, e.props.isFocused)
584
546
  const ici = liste.findIndex(x => x.cle === element)
585
547
  // The chantier the keyboard is on, which `h` switches on or off.
586
548
  const chantier = ici >= 0 && liste[ici]?.l.chantier ? liste[ici]?.l.ticket : undefined
@@ -597,8 +559,7 @@ export const register: Register = on => {
597
559
  plain
598
560
  hotkey="e"
599
561
  onPress={() => {
600
- fenetre = 0
601
- suivi = null
562
+ recommencer()
602
563
  void update($, etat, basculerVue)
603
564
  }}
604
565
  >
@@ -610,8 +571,7 @@ export const register: Register = on => {
610
571
  plain
611
572
  hotkey="o"
612
573
  onPress={() => {
613
- fenetre = 0
614
- suivi = null
574
+ recommencer()
615
575
  void update($, etat, x => ouvrirGroupe(x, groupe))
616
576
  }}
617
577
  >
@@ -683,8 +643,18 @@ export const register: Register = on => {
683
643
  )
684
644
  }
685
645
  const premier = fenetre
646
+ const montrees = liste.slice(premier, premier + rangs)
686
647
  // A card fills the pane's last rows: the whole title on as many lines as it takes, then the
687
- // component, state, duration and tokens, then the description in the rows left.
648
+ // component, state, duration and tokens, then the description in the rows left. Each card is
649
+ // drawn once for a board, a width and a surface, and kept.
650
+ const gardees = cartesGardees(s.revision, colonnes, Box)
651
+ const garder = (cle: string, dessin: () => JSX.Element) => {
652
+ const deja = gardees.get(cle)
653
+ if (deja) return deja
654
+ const neuf = dessin()
655
+ gardees.set(cle, neuf)
656
+ return neuf
657
+ }
688
658
  const carte = (f: Fiche | undefined) => {
689
659
  const [titre, etatDuTicket, resume] = ficheLignes(f)
690
660
  return (
@@ -712,7 +682,7 @@ export const register: Register = on => {
712
682
  return (
713
683
  <Box flexDirection="column" height={e.props.scroll.bodyRows}>
714
684
  <Box flexDirection="column" flexGrow={1} overflow="hidden">
715
- {liste.slice(premier, premier + rangs).map(({ l, cle }) => {
685
+ {montrees.map(({ l, cle }) => {
716
686
  const texte = (
717
687
  <Text bold={l.ton === 'titre'} dimColor={l.ton === 'discret'} color={couleur(l.ton)} wrap="truncate-end">
718
688
  {l.texte || ' '}
@@ -741,28 +711,29 @@ export const register: Register = on => {
741
711
  )
742
712
  })}
743
713
  </Box>
744
- {pied.map((l, i) => (
745
- <Text key={`pied:${i}`} dimColor={l.ton === 'discret'} color={couleur(l.ton)} wrap="truncate-end">
746
- {l.texte}
747
- </Text>
748
- ))}
749
714
  {regle('tout le texte')}
750
715
  <Box flexDirection="column" height={FICHE} flexShrink={0}>
751
- {carte(fiche)}
752
- {Object.entries(t.fiches).map(([id, f]) => (
716
+ {garder(`carte:${montre ?? ''}`, () => carte(fiche))}
717
+ {[...new Set(montrees.map(x => x.l.ticket))].map(id => {
718
+ const f = id ? t.fiches[id] : undefined
753
719
  // The card of the ticket under the pointer, drawn over the chosen one on a blank of its
754
- // size, so no character of the chosen card shows through.
755
- <Box position="absolute" top={0} left={0} display="none" hover={{ scope: id, display: 'flex' }}>
756
- <Box flexDirection="column">
757
- {Array.from({ length: FICHE }, () => (
758
- <Text>{' '.repeat(colonnes)}</Text>
759
- ))}
760
- </Box>
761
- <Box position="absolute" top={0} left={0}>
762
- {carte(f)}
763
- </Box>
764
- </Box>
765
- ))}
720
+ // size, so no character of the chosen card shows through: one for each ticket of the
721
+ // lines in the window, the only ones the pointer can be over.
722
+ return id && f
723
+ ? garder(`survol:${id}`, () => (
724
+ <Box position="absolute" top={0} left={0} display="none" hover={{ scope: id, display: 'flex' }}>
725
+ <Box flexDirection="column">
726
+ {Array.from({ length: FICHE }, () => (
727
+ <Text>{' '.repeat(colonnes)}</Text>
728
+ ))}
729
+ </Box>
730
+ <Box position="absolute" top={0} left={0}>
731
+ {carte(f)}
732
+ </Box>
733
+ </Box>
734
+ ))
735
+ : null
736
+ })}
766
737
  </Box>
767
738
  </Box>
768
739
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roomi-fields/grillhouse",
3
- "version": "0.28.1",
3
+ "version": "0.28.2",
4
4
  "description": "Roomi's Grillhouse: the frame's scripts, called by one command, grillhouse <sous-commande>",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -43,7 +43,7 @@
43
43
  # the work in progress of the copy in the copy, never in git's stash, which every copy of the
44
44
  # repository shares: it is set aside as a lot, the copy fast-forwards, and the lot is applied
45
45
  # three ways, as the lot of a branch sent back is (scripts/enveloppe/travail-de-la-copie.mjs).
46
- # A refusal, such as commits of the agent on its branch or conflicts left unresolved, goes to
46
+ # A refusal, such as a branch that has left main or conflicts left unresolved, goes to
47
47
  # the log and stops the launch, CODE_COPIE; so does a reapplication that conflicts: the log
48
48
  # names the copy and each file in conflict, the conflicts stay marked in the copy's files and
49
49
  # unmerged in its index, and no agent starts on a half-merged copy. Its
@@ -23,11 +23,13 @@
23
23
  // - A copy whose lot still waits in its git directory (git refused it whole, as a deletion of
24
24
  // a file main changed) is not touched: the output names the file and how to take it back;
25
25
  // exit 1. So no relaunch loses it.
26
- // - A copy still in conflict (unmerged entries in its index) or whose branch carries commits
27
- // main has not (no fast-forward) is not touched; the output says why; exit 1. A fast-forward
28
- // that fails after the work is set aside (an untracked file in the way) gives the work back
29
- // on HEAD; exit 1.
30
- // - A copy at <cible> already, or without local work, simply fast-forwards; exit 0.
26
+ // - A copy still in conflict (unmerged entries in its index) or whose branch has left main
27
+ // (commits on both sides, no fast-forward) is not touched; the output says why; exit 1. A
28
+ // fast-forward that fails after the work is set aside (an untracked file in the way) gives
29
+ // the work back on HEAD; exit 1.
30
+ // - A copy at <cible> already, or ahead of it (<cible> an ancestor of its HEAD, as a branch
31
+ // whose commits main has not entered yet), is not touched, as `git merge --ff-only` answers
32
+ // « Already up to date »; a copy without local work simply fast-forwards; exit 0.
31
33
  // - Both: a generated file the project declares (`grillhouse.engendres`, scripts/engendres.mjs,
32
34
  // read from the main tree) is not merged, as npm writes package-lock.json again after a merge:
33
35
  // when the lot touches one of its files, or one it reads (the copy's untracked files counting),
@@ -178,7 +180,12 @@ export function avancer(copie, cible) {
178
180
  if (vise.status !== 0) {
179
181
  return { ok: false, message: `⛔ ${cible} ne nomme aucun commit : ${texte(vise)}` };
180
182
  }
181
- if (tete === String(vise.stdout).trim()) {
183
+ // At <cible>, or ahead of it (<cible> an ancestor of HEAD): nothing to move, as git's
184
+ // `merge --ff-only` answers « Already up to date ».
185
+ if (
186
+ tete === String(vise.stdout).trim() ||
187
+ git(copie, ['merge-base', '--is-ancestor', cible, 'HEAD']).status === 0
188
+ ) {
182
189
  return { ok: true, message: '' };
183
190
  }
184
191
  if (git(copie, ['merge-base', '--is-ancestor', 'HEAD', cible]).status !== 0) {
@@ -35,7 +35,7 @@
35
35
  // writes its configuration). For the check of the uses, test files (under a folder `test/`,
36
36
  // `tests/` or `__tests__/`, or named `*.test.*`, `*.spec.*`) count only for their imports of a
37
37
  // package of the material; `dist/`, `docs/` and `node_modules/` are never read, nor are Vite's
38
- // temporary files, and a file gone between the walk and its read is passed over (`parcourir`).
38
+ // temporary files, and a file gone between the walk and its read is passed over (`parcourir`, ./parcours.mjs).
39
39
  // The identity of a component is its name: two directories of the same name, one under `packages/`
40
40
  // and one under `src/`, are refused, both paths named (the way npm workspaces, Nx and Cargo refuse
41
41
  // two projects of one name). Names differing by case are two names.
@@ -43,12 +43,13 @@
43
43
  // A project's guard imports `matieres` by the package's entry
44
44
  // `@roomi-fields/grillhouse/consommateurs`, its types in ./consommateurs.d.ts (docs/ARCHITECTURE.md,
45
45
  // the package's named entries).
46
- import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
46
+ import { existsSync, readFileSync } from 'node:fs';
47
47
  import path from 'node:path';
48
48
  import { pathToFileURL } from 'node:url';
49
49
  import { trancher } from '../../dette.mjs';
50
50
  import { horsCadre } from '../../paquets.mjs';
51
51
  import { composants, dossiers, matieres } from './composants.mjs';
52
+ import { lireSiPresent, parcourir } from './parcours.mjs';
52
53
 
53
54
  // The components and the packages of the shared material, read by ./composants.mjs; the entry
54
55
  // publishes `matieres` from here.
@@ -161,45 +162,6 @@ export function imports(source) {
161
162
  return out;
162
163
  }
163
164
 
164
- // The temporary file Vite writes beside a configuration it bundles, then removes
165
- // (`vitest.config.ts.timestamp-<n>-<hash>.mjs`).
166
- const TEMPORAIRE_DE_VITE = /\.timestamp-[^/\\]*\.mjs$/;
167
-
168
- // <f> read by <lire>, or <absent> when it no longer exists (ENOENT).
169
- function siPresent(lire, f, absent) {
170
- try {
171
- return lire(f);
172
- } catch (e) {
173
- if (e?.code === 'ENOENT') return absent;
174
- throw e;
175
- }
176
- }
177
-
178
- // The files under <chemin> (a directory, or a file), each its absolute path: an entry below it
179
- // whose path <sauter> keeps out is neither entered nor listed, and Vite's temporary files are
180
- // never listed. The guards of the frame walk the repository while other processes write in it
181
- // (`npm run verifier` plays them beside the tests): a file or a directory gone before the walk
182
- // reaches it is passed over. The walk of every guard of the frame.
183
- export function parcourir(chemin, sauter = () => false) {
184
- const out = [];
185
- const walk = (p, dossier) => {
186
- if (!dossier) {
187
- if (!TEMPORAIRE_DE_VITE.test(p)) out.push(p);
188
- return;
189
- }
190
- for (const e of siPresent(d => readdirSync(d, { withFileTypes: true }), p, [])) {
191
- const q = path.join(p, e.name);
192
- if (!sauter(q)) walk(q, e.isDirectory());
193
- }
194
- };
195
- const racine = siPresent(statSync, chemin, null);
196
- if (racine) walk(chemin, racine.isDirectory());
197
- return out;
198
- }
199
-
200
- // The text of the file <f> a walk listed, or null when it is gone since.
201
- export const lireSiPresent = f => siPresent(x => readFileSync(x, 'utf8'), f, null);
202
-
203
165
  // The source files under <dir>: [{ f, test }], `test` for a file under a test folder or of a test
204
166
  // name.
205
167
  function fichiers(dir) {
@@ -57,7 +57,8 @@ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'no
57
57
  import { tmpdir } from 'node:os';
58
58
  import path from 'node:path';
59
59
  import { pathToFileURL } from 'node:url';
60
- import { composants, lireSiPresent, parcourir } from './consommateurs.mjs';
60
+ import { composants } from './consommateurs.mjs';
61
+ import { lireSiPresent, parcourir } from './parcours.mjs';
61
62
  import { paquetsDeLEnveloppe } from '../../services-du-noyau.mjs';
62
63
  import { trancher } from '../../dette.mjs';
63
64
 
@@ -19,14 +19,8 @@
19
19
  // what its tests read (`parLesTests`): the components its tests import.
20
20
  import { existsSync, readFileSync } from 'node:fs';
21
21
  import path from 'node:path';
22
- import {
23
- declares,
24
- imports,
25
- lireSiPresent,
26
- NOM_DE_TEST,
27
- parcourir,
28
- utilise,
29
- } from './consommateurs.mjs';
22
+ import { declares, imports, NOM_DE_TEST, utilise } from './consommateurs.mjs';
23
+ import { lireSiPresent, parcourir } from './parcours.mjs';
30
24
  import { lire } from './index-interfaces.mjs';
31
25
  import { elementsEcrits, parLesTypes } from './references-par-les-types.mjs';
32
26
 
@@ -0,0 +1,49 @@
1
+ // The walk of the repository every guard of the module typescript makes: the files under a path,
2
+ // Vite's temporary files never listed, a file or a directory gone before the walk reaches it
3
+ // passed over. The guards walk the repository while other processes write in it (`npm run
4
+ // verifier` plays them beside the tests). Node alone (./vitest-config/lances.mjs, which the
5
+ // configuration of Vitest loads, imports it).
6
+ import { readdirSync, readFileSync, statSync } from 'node:fs';
7
+ import path from 'node:path';
8
+
9
+ // The temporary file Vite writes beside a configuration it bundles, then removes
10
+ // (`vitest.config.ts.timestamp-<n>-<hash>.mjs`).
11
+ const TEMPORAIRE_DE_VITE = /\.timestamp-[^/\\]*\.mjs$/;
12
+
13
+ // <f> read by <lire>, or <absent> when it no longer exists (ENOENT).
14
+ function siPresent(lire, f, absent) {
15
+ try {
16
+ return lire(f);
17
+ } catch (e) {
18
+ if (e?.code === 'ENOENT') return absent;
19
+ throw e;
20
+ }
21
+ }
22
+
23
+ /**
24
+ * The files under <chemin> (a directory, or a file), each its absolute path: an entry below it
25
+ * whose path <sauter> keeps out is neither entered nor listed, and Vite's temporary files are
26
+ * never listed.
27
+ * @param {string} chemin
28
+ * @param {(p: string) => boolean} [sauter]
29
+ * @returns {string[]}
30
+ */
31
+ export function parcourir(chemin, sauter = () => false) {
32
+ const out = [];
33
+ const walk = (p, dossier) => {
34
+ if (!dossier) {
35
+ if (!TEMPORAIRE_DE_VITE.test(p)) out.push(p);
36
+ return;
37
+ }
38
+ for (const e of siPresent(d => readdirSync(d, { withFileTypes: true }), p, [])) {
39
+ const q = path.join(p, e.name);
40
+ if (!sauter(q)) walk(q, e.isDirectory());
41
+ }
42
+ };
43
+ const racine = siPresent(statSync, chemin, null);
44
+ if (racine) walk(chemin, racine.isDirectory());
45
+ return out;
46
+ }
47
+
48
+ /** The text of the file <f> a walk listed, or null when it is gone since. */
49
+ export const lireSiPresent = f => siPresent(x => readFileSync(x, 'utf8'), f, null);
@@ -26,7 +26,8 @@
26
26
  import { existsSync } from 'node:fs';
27
27
  import { createRequire } from 'node:module';
28
28
  import path from 'node:path';
29
- import { lireSiPresent, NOM_DE_TEST } from './consommateurs.mjs';
29
+ import { NOM_DE_TEST } from './consommateurs.mjs';
30
+ import { lireSiPresent } from './parcours.mjs';
30
31
  import { sorties } from './frontieres.mjs';
31
32
 
32
33
  const requis = createRequire(import.meta.url);
@@ -163,7 +163,8 @@ import path from 'node:path';
163
163
  import { pathToFileURL } from 'node:url';
164
164
  import { applyEdits, modify, parse } from 'jsonc-parser';
165
165
  import { AVANCEMENT, CHANGEMENTS, inscrireLePlan } from '../../services-du-noyau.mjs';
166
- import { matieres, parcourir } from './consommateurs.mjs';
166
+ import { matieres } from './consommateurs.mjs';
167
+ import { parcourir } from './parcours.mjs';
167
168
  import { paquets, TYPAGE } from '../../paquets.mjs';
168
169
  import { ecrireSarif, RESULTATS } from '../../resultats.mjs';
169
170
  import { SCRIPT_DES_TESTS as TESTS } from './script-des-tests.mjs';
@@ -47,11 +47,12 @@
47
47
  // takes from this module what a test file is, its material, its imports and their resolution.
48
48
  //
49
49
  // This module's top level uses Node alone (./changements.mjs imports it).
50
- import { existsSync, globSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
50
+ import { existsSync, globSync, readFileSync, realpathSync, statSync } from 'node:fs';
51
51
  import { createRequire } from 'node:module';
52
52
  import path from 'node:path';
53
53
  import { matieres } from '../composants.mjs';
54
54
  import { paquets } from '../../../paquets.mjs';
55
+ import { parcourir } from '../parcours.mjs';
55
56
 
56
57
  /** A test file, as Vitest's default `include` names one. */
57
58
  export const TEST = /\.(?:test|spec)\.[cm]?[jt]sx?$/;
@@ -121,20 +122,10 @@ const estDossier = f => {
121
122
  }
122
123
  };
123
124
 
124
- // The files under the directory <dir>, absolute, SAUTES left out.
125
- function fichiersSous(dir) {
126
- let entrees;
127
- try {
128
- entrees = readdirSync(dir, { withFileTypes: true });
129
- } catch {
130
- return [];
131
- }
132
- return entrees.flatMap(e => {
133
- if (SAUTES.has(e.name)) return [];
134
- const f = path.join(dir, e.name);
135
- return e.isDirectory() ? fichiersSous(f) : e.isFile() ? [f] : [];
136
- });
137
- }
125
+ // The files under the directory <dir>, absolute, SAUTES left out: the walk of the guards
126
+ // (../parcours.mjs), which never lists Vite's temporary files (the night of 2026-11-01,
127
+ // grillhouse-rm7: one, beside a configuration of another package, counted as a module).
128
+ const fichiersSous = dir => parcourir(dir, f => SAUTES.has(path.basename(f)));
138
129
 
139
130
  // The specifiers <texte> imports.
140
131
  const specifiers = texte =>
@@ -5,6 +5,8 @@
5
5
  //
6
6
  // npx grillhouse tableau the board, as JSON (with its lines, 52 columns wide)
7
7
  // npx grillhouse tableau --texte the board, as text
8
+ // npx grillhouse tableau <dossier>… the board of this project and of the projects in <dossier>…,
9
+ // one board, each ticket prefixed by its project (`ensemble`)
8
10
  //
9
11
  // Each measure writes the status line (the chantier in progress) to `grillhouse-etat.txt` in the
10
12
  // common git directory, where the status line (`scripts/ligne-etat/`) reads it.
@@ -1007,7 +1009,7 @@ export function assembler({
1007
1009
  /^La nuit est rouge\b/.test(titreLu) && !Number.isNaN(ouvert)
1008
1010
  ? `Nuit rouge depuis le ${jourEtMois(ouvert)}`
1009
1011
  : titreLu;
1010
- alertes.push({ niveau: 'rouge', texte: `${sujet} ${n}`, sujet, numero: n });
1012
+ alertes.push({ niveau: 'rouge', texte: `${sujet} ${n}`, sujet, numero: n, id: t.id });
1011
1013
  }
1012
1014
  for (const b of blocs) {
1013
1015
  for (const x of b.enCours) {
@@ -1145,9 +1147,7 @@ const couperAvant = (gauche, suite, droite, largeur) => {
1145
1147
  // The board's lines, `largeur` columns wide, each with its tone (titre, alerte, attention, actif,
1146
1148
  // discret, or none), its section (`section`: agents, chantier or faits, in that order) and, for a
1147
1149
  // ticket's line, its id (`ticket`), which the pane makes selectable; an epic's line is marked
1148
- // `chantier`. A ticket's line in AGENTS names the step it stands under (`etape`: its `numero`,
1149
- // null after the steps, and `titre`) and, stopped on a question, who must answer it (`question`):
1150
- // the pane that fuses several projects' boards sorts their tickets by it. The head belongs to agents, the first section; a blank line belongs to the section
1150
+ // `chantier`. The head belongs to agents, the first section; a blank line belongs to the section
1151
1151
  // of the title after it. A chantier's « sans go » and « reporté » groups, its « à valider » group
1152
1152
  // past SEUIL_REPLI tickets, and the other chantiers beside one in progress fold to their title and
1153
1153
  // count: the folded title carries its group's key (`groupe`), and `groupes` receives, under that
@@ -1162,32 +1162,61 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1162
1162
  const poser = (...l) => out.push(...l.map(marquer));
1163
1163
  const cadre = couper;
1164
1164
  const L = (texte, ton, ticket) => poser(ticket ? { texte, ton, ticket } : { texte, ton });
1165
- const g = t.global;
1166
- const c = g.compteurs;
1165
+ // A board of several projects (`projets`, scripts/tableau.mjs `ensemble`): each line of a ticket,
1166
+ // a chantier or an alert carries its project's label, « [SH] »; one project's board, none.
1167
+ const plusieurs = Array.isArray(t.projets);
1168
+ const duProjet = x => (plusieurs ? `[${x.projet}] ` : '');
1169
+ // The labels' column of the head and of AGENTS, « [OB] », « [OSD] ».
1170
+ const large = Math.max(0, ...(t.projets ?? []).map(p => p.etiquette.length + 3));
1171
+ const colonneDe = etiquette => `[${etiquette}]`.padEnd(large);
1167
1172
  L(nom.toUpperCase(), 'titre');
1168
- // Two lines of states: those of the circuit, then those that wait for the owner.
1169
- L(
1170
- cadre(
1171
- `▶ ${c.enCours} en cours · ${c.enAttente} en attente · ${c.bloques} bloqués · ${c.fermes} faits`,
1172
- '',
1173
- largeur
1174
- )
1175
- );
1176
- L(
1177
- cadre(`${c.sansGo} sans go · ${c.aValider} à valider · ${c.reportes} reportés`, '', largeur),
1178
- c.sansGo || c.aValider ? 'attention' : undefined
1179
- );
1180
- L(
1181
- cadre(
1182
- `jour ${duree(g.jour.travail)} · ${k(g.jour.jetons)} · cumul ${duree(g.cumul.travail)} · ${k(g.cumul.jetons)}`,
1183
- '',
1184
- largeur
1185
- ),
1186
- 'discret'
1187
- );
1173
+ if (plusieurs) {
1174
+ // One line per project: its counters, or the fault that keeps its board out.
1175
+ for (const p of t.projets) {
1176
+ if (p.erreur) {
1177
+ L(cadre(`${colonneDe(p.etiquette)}⚠ ${p.erreur}`, '', largeur), 'alerte');
1178
+ continue;
1179
+ }
1180
+ const c = p.compteurs;
1181
+ L(
1182
+ cadre(
1183
+ `${colonneDe(p.etiquette)}▶ ${c.enCours} en cours · ${c.enAttente} en attente · ${c.fermes} faits`,
1184
+ '',
1185
+ largeur
1186
+ )
1187
+ );
1188
+ }
1189
+ } else {
1190
+ const g = t.global;
1191
+ const c = g.compteurs;
1192
+ // Two lines of states: those of the circuit, then those that wait for the owner.
1193
+ L(
1194
+ cadre(
1195
+ `▶ ${c.enCours} en cours · ${c.enAttente} en attente · ${c.bloques} bloqués · ${c.fermes} faits`,
1196
+ '',
1197
+ largeur
1198
+ )
1199
+ );
1200
+ L(
1201
+ cadre(`${c.sansGo} sans go · ${c.aValider} à valider · ${c.reportes} reportés`, '', largeur),
1202
+ c.sansGo || c.aValider ? 'attention' : undefined
1203
+ );
1204
+ L(
1205
+ cadre(
1206
+ `jour ${duree(g.jour.travail)} · ${k(g.jour.jetons)} · cumul ${duree(g.cumul.travail)} · ${k(g.cumul.jetons)}`,
1207
+ '',
1208
+ largeur
1209
+ ),
1210
+ 'discret'
1211
+ );
1212
+ }
1213
+ // An alert of several projects' board names its ticket by its whole id.
1188
1214
  for (const a of t.alertes) {
1215
+ const droite = plusieurs ? (a.id ?? a.numero) : a.numero;
1189
1216
  L(
1190
- a.numero ? cadre(`⚠ ${a.sujet}`, a.numero, largeur) : cadre(`⚠ ${a.texte}`, '', largeur),
1217
+ droite
1218
+ ? cadre(`⚠ ${duProjet(a)}${a.sujet}`, droite, largeur)
1219
+ : cadre(`⚠ ${duProjet(a)}${a.texte}`, '', largeur),
1191
1220
  a.niveau === 'rouge' ? 'alerte' : 'attention'
1192
1221
  );
1193
1222
  }
@@ -1264,21 +1293,29 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1264
1293
  const montres = t.agents.flatMap(b =>
1265
1294
  [...b.enCours, ...b.attend].filter(x => !enCircuit.has(x.id))
1266
1295
  );
1267
- const colonne = Math.max(
1268
- 0,
1269
- ...[...(t.circuits ?? []), ...montres].map(x => String(x.numero).length)
1270
- );
1271
- const numero = n => String(n).padEnd(colonne);
1272
- // The step a ticket's line stands under, as data: its number (null after the steps) and title.
1273
- const etapeDuBloc = b => ({ numero: b.numero, titre: b.titre });
1274
- const ligneDuCircuit = (c, b, qui) => {
1275
- const droite = conso(t.parTicket?.[c.id]?.travail ?? 0, t.parTicket?.[c.id]?.jetons ?? 0);
1296
+ // A ticket's number, or on several projects' board its whole id, in one column.
1297
+ const nomme = x => String(plusieurs ? x.id : x.numero);
1298
+ const colonne = Math.max(0, ...[...(t.circuits ?? []), ...montres].map(x => nomme(x).length));
1299
+ // A ticket's line in AGENTS: « <signe> <numéro> <sujet> … <droite> »; on several projects'
1300
+ // board « <[projet]> <id> <sujet> … <signe> <droite> », the owner's maquette (grillhouse-erp.1).
1301
+ const teteDe = (signe, x) =>
1302
+ plusieurs
1303
+ ? `${colonneDe(x.projet)}${nomme(x).padEnd(colonne)} `
1304
+ : `${signe} ${nomme(x).padEnd(colonne)} `;
1305
+ const droiteDe = (signe, droite) =>
1306
+ plusieurs ? `${signe}${droite ? ` ${droite}` : ''}` : droite;
1307
+ const ligneDuCircuit = c => {
1308
+ const signe = c.vivant ? '▶' : '■';
1309
+ const droite = droiteDe(
1310
+ signe,
1311
+ conso(t.parTicket?.[c.id]?.travail ?? 0, t.parTicket?.[c.id]?.jetons ?? 0)
1312
+ );
1276
1313
  const etape = etapeDe(c);
1277
1314
  const boucles = (etape ? bouclesDe(etape) : [])
1278
1315
  .filter(b => b.max && c.boucles?.[b.cle] >= 2)
1279
1316
  .map(b => ` · ${b.libelle} ${c.boucles[b.cle]}/${b.max}`)
1280
1317
  .join('');
1281
- const tete = `${c.vivant ? '▶' : '■'} ${numero(c.numero)} `;
1318
+ const tete = teteDe(signe, c);
1282
1319
  const temoin = c.vivant && etape?.qui.includes(AUTO) ? temoinDe(c, maintenant) : null;
1283
1320
  // The progress after the counters of the loops while the subject keeps its room beside them,
1284
1321
  // in their place otherwise.
@@ -1292,8 +1329,6 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1292
1329
  texte: couperAvant(`${tete}${c.sujet}`, suite, droite, largeur),
1293
1330
  ton: temoin?.fige ? 'alerte' : c.vivant ? 'actif' : 'attention',
1294
1331
  ticket: c.id,
1295
- etape: etapeDuBloc(b),
1296
- ...(qui ? { question: qui } : {}),
1297
1332
  ...(temoin ? { avancement: true } : {}),
1298
1333
  });
1299
1334
  };
@@ -1322,31 +1357,32 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1322
1357
  const tickets = (b, retrait) => {
1323
1358
  const { circuits, enQuestions, enCours, attend } = contenus.get(b);
1324
1359
  for (const c of circuits) {
1325
- ligneDuCircuit(c, b);
1360
+ ligneDuCircuit(c);
1326
1361
  }
1327
1362
  for (const x of enCours) {
1328
- poser({
1329
- texte: cadre(`▶ ${numero(x.numero)} ${x.sujet}`, conso(x.travail, x.jetons), largeur),
1330
- ton: 'actif',
1331
- ticket: x.id,
1332
- etape: etapeDuBloc(b),
1333
- });
1363
+ L(
1364
+ cadre(`${teteDe('▶', x)}${x.sujet}`, droiteDe('▶', conso(x.travail, x.jetons)), largeur),
1365
+ 'actif',
1366
+ x.id
1367
+ );
1334
1368
  }
1335
1369
  const attente = x => ({
1336
1370
  texte: cadre(
1337
- `· ${numero(x.numero)} ${x.sujet}`,
1338
- x.bloquePar?.length ? `attend ${x.bloquePar.join(', ')}` : conso(x.travail, x.jetons),
1371
+ `${teteDe('·', x)}${x.sujet}`,
1372
+ droiteDe(
1373
+ '·',
1374
+ x.bloquePar?.length ? `attend ${x.bloquePar.join(', ')}` : conso(x.travail, x.jetons)
1375
+ ),
1339
1376
  largeur
1340
1377
  ),
1341
1378
  ton: 'discret',
1342
1379
  ticket: x.id,
1343
- etape: etapeDuBloc(b),
1344
1380
  });
1345
1381
  poser(...attend.map(attente));
1346
1382
  for (const [qui, l] of enQuestions) {
1347
1383
  L(cadre(`${retrait}⤷ Question · ${qui}`, '', largeur), 'titre');
1348
1384
  for (const c of l) {
1349
- ligneDuCircuit(c, b, qui);
1385
+ ligneDuCircuit(c);
1350
1386
  }
1351
1387
  }
1352
1388
  };
@@ -1390,7 +1426,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1390
1426
  for (const ch of t.chantiers) {
1391
1427
  L('', undefined);
1392
1428
  poser({
1393
- texte: cadre(`CHANTIER ${ch.numero} — ${ch.sujet}`, '', largeur),
1429
+ texte: cadre(`CHANTIER ${duProjet(ch)}${ch.numero} — ${ch.sujet}`, '', largeur),
1394
1430
  ton: 'titre',
1395
1431
  ticket: ch.id,
1396
1432
  chantier: true,
@@ -1433,7 +1469,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1433
1469
  ? marque(n)
1434
1470
  : '';
1435
1471
  return {
1436
- texte: cadre(` ${n.numero} ${n.sujet}`, droite, largeur),
1472
+ texte: cadre(` ${duProjet(n)}${n.numero} ${n.sujet}`, droite, largeur),
1437
1473
  ton: n.etat === 'enCours' ? 'actif' : undefined,
1438
1474
  ticket: n.id,
1439
1475
  };
@@ -1482,7 +1518,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1482
1518
  if (t.autres.length) {
1483
1519
  L('', undefined);
1484
1520
  const autres = t.autres.map(a => ({
1485
- texte: cadre(`${a.numero} ${a.sujet}`, `${a.faits}/${a.total}`, largeur),
1521
+ texte: cadre(`${duProjet(a)}${a.numero} ${a.sujet}`, `${a.faits}/${a.total}`, largeur),
1486
1522
  ticket: a.id,
1487
1523
  chantier: true,
1488
1524
  }));
@@ -1518,7 +1554,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1518
1554
  'titre'
1519
1555
  );
1520
1556
  const fait = x => ({
1521
- texte: cadre(`✓ ${x.numero} ${x.sujet}`, conso(x.travail, x.jetons), largeur),
1557
+ texte: cadre(`✓ ${duProjet(x)}${x.numero} ${x.sujet}`, conso(x.travail, x.jetons), largeur),
1522
1558
  ton: 'discret',
1523
1559
  ticket: x.id,
1524
1560
  });
@@ -1547,7 +1583,7 @@ export function lignesEtats(t, largeur = LARGEUR) {
1547
1583
  for (const x of e.tickets) {
1548
1584
  out.push({
1549
1585
  texte: couper(
1550
- ` ${x.numero} ${x.sujet}`,
1586
+ ` ${x.projet ? `[${x.projet}] ` : ''}${x.numero} ${x.sujet}`,
1551
1587
  e.cle === 'bloques' && x.bloquePar.length
1552
1588
  ? `attend ${x.bloquePar.join(', ')}`
1553
1589
  : conso(t.parTicket[x.id]?.travail ?? 0, t.parTicket[x.id]?.jetons ?? 0),
@@ -1676,9 +1712,9 @@ const bdJson = (racine, ...args) => {
1676
1712
  }
1677
1713
  };
1678
1714
 
1679
- // The board of the repository at <racine>, with its ticket prefix (`prefixe`), which labels its
1680
- // lines in a pane that fuses several projects.
1681
- export function tableau(racine, { home = os.homedir(), maintenant = Date.now() } = {}) {
1715
+ // What the board reads of the repository at <racine>: its tickets, its prefix, its running agents
1716
+ // and its assembled board (`t`), with the folder git keeps its shared files in (`commun`).
1717
+ function lire(racine, { home, maintenant, horsTicket = null }) {
1682
1718
  let prefix = '';
1683
1719
  try {
1684
1720
  prefix = execFileSync('bd', ['config', 'get', 'issue_prefix'], {
@@ -1765,42 +1801,132 @@ export function tableau(racine, { home = os.homedir(), maintenant = Date.now() }
1765
1801
  verdicts,
1766
1802
  maintenant,
1767
1803
  jour: minuit.getTime(),
1768
- horsTicket: lireLaMesure(process.env),
1804
+ horsTicket,
1769
1805
  });
1770
- // The project is named by its repository's folder, as a shell prompt names it.
1771
- const nom = path.basename(racine);
1772
- const groupes = {};
1773
- const l = lignes(t, nom, LARGEUR, groupes);
1774
- const vue = lignesEtats(t);
1775
- const etat = ligneEtat(t);
1806
+ return { t, prefix, tous, vivants, commun };
1807
+ }
1808
+
1809
+ // The boards of several projects as one (grillhouse-erp.1), as the multi-root explorer of VS Code
1810
+ // keeps one view and files each root under its name: <lus> holds each project's label
1811
+ // (`etiquette`, its ticket prefix) and its board (`t`) or the fault that keeps it out (`erreur`),
1812
+ // the session's project first. Each ticket, alert and chantier is marked with its project's label
1813
+ // (`projet`), the agents' blocks hold every project's tickets at their step, and `projets` gives
1814
+ // each project's counters or fault, which the head shows one line each.
1815
+ export function ensemble(lus) {
1816
+ const lisibles = lus.filter(l => l.t);
1817
+ const [premier] = lisibles;
1818
+ const marquer = projet => x => ({ ...x, projet });
1819
+ const noeud = projet => n => ({ ...n, projet, enfants: n.enfants.map(noeud(projet)) });
1820
+ const tous = cle => lisibles.flatMap(l => (l.t[cle] ?? []).map(marquer(l.etiquette)));
1821
+ return {
1822
+ projets: lus.map(l =>
1823
+ l.t
1824
+ ? { etiquette: l.etiquette, compteurs: l.t.global.compteurs }
1825
+ : { etiquette: l.etiquette, erreur: l.erreur }
1826
+ ),
1827
+ alertes: tous('alertes'),
1828
+ circuits: tous('circuits'),
1829
+ chantiers: lisibles.flatMap(l => l.t.chantiers.map(noeud(l.etiquette))),
1830
+ autres: tous('autres'),
1831
+ agents: premier.t.agents.map(b => {
1832
+ const de = cle =>
1833
+ lisibles.flatMap(l =>
1834
+ (l.t.agents.find(x => x.numero === b.numero)?.[cle] ?? []).map(marquer(l.etiquette))
1835
+ );
1836
+ return { ...b, enCours: de('enCours'), attend: de('attend') };
1837
+ }),
1838
+ maintenant: premier.t.maintenant,
1839
+ horsTicket: premier.t.horsTicket,
1840
+ faitsDuJour: tous('faitsDuJour'),
1841
+ etats: premier.t.etats.map(e => ({
1842
+ ...e,
1843
+ tickets: lisibles.flatMap(l =>
1844
+ (l.t.etats.find(x => x.cle === e.cle)?.tickets ?? []).map(marquer(l.etiquette))
1845
+ ),
1846
+ })),
1847
+ parTicket: Object.assign({}, ...lisibles.map(l => l.t.parTicket)),
1848
+ };
1849
+ }
1850
+
1851
+ // A project beside the session's, read in its folder <dossier>: its board, or the fault that keeps
1852
+ // it out, on one line.
1853
+ function lireUnAutre(dossier, o) {
1776
1854
  try {
1777
- if (commun) {
1778
- writeFileSync(path.join(commun, 'grillhouse-etat.txt'), `${etat}\n`);
1855
+ if (!existsSync(dossier)) {
1856
+ throw new Error('dossier introuvable');
1857
+ }
1858
+ return { dossier, ...lire(dossier, o) };
1859
+ } catch (e) {
1860
+ return { dossier, erreur: String(e.message ?? e).split('\n')[0] };
1861
+ }
1862
+ }
1863
+
1864
+ // The board of the repository at <racine>; with <projets>, the folders of other projects, the
1865
+ // board of them all (`ensemble`), named « <dépôt> + <projet> + … », with the folder of each
1866
+ // ticket's project (`dossiers`), where the pane runs Beads for it. The status line is the
1867
+ // session's project's alone.
1868
+ export function tableau(
1869
+ racine,
1870
+ { home = os.homedir(), maintenant = Date.now(), projets = [] } = {}
1871
+ ) {
1872
+ const ici = {
1873
+ dossier: racine,
1874
+ ...lire(racine, { home, maintenant, horsTicket: lireLaMesure(process.env) }),
1875
+ };
1876
+ const etat = ligneEtat(ici.t);
1877
+ try {
1878
+ if (ici.commun) {
1879
+ writeFileSync(path.join(ici.commun, 'grillhouse-etat.txt'), `${etat}\n`);
1779
1880
  }
1780
1881
  } catch {
1781
1882
  // A read-only place keeps the board working, without its status line.
1782
1883
  }
1884
+ const lus = [ici, ...projets.map(d => lireUnAutre(d, { home, maintenant }))];
1885
+ const etiquette = l => l.prefix || path.basename(l.dossier);
1886
+ const t = projets.length
1887
+ ? ensemble(lus.map(l => ({ etiquette: etiquette(l), t: l.t, erreur: l.erreur })))
1888
+ : ici.t;
1889
+ // The project is named by its repository's folder, as a shell prompt names it.
1890
+ const nom = [path.basename(racine), ...lus.slice(1).map(etiquette)].join(' + ');
1891
+ const groupes = {};
1892
+ const l = lignes(t, nom, LARGEUR, groupes);
1893
+ const vue = lignesEtats(t);
1894
+ const toutes = [...l, ...vue, ...Object.values(groupes).flat()];
1895
+ const lisibles = lus.filter(x => x.t);
1896
+ const parProjet = lisibles.map(x => ({
1897
+ dossier: x.dossier,
1898
+ fiches: fiches(x.tous, toutes, x.prefix, x.t.parTicket, x.t.circuits, bilansGardes(x.dossier)),
1899
+ }));
1783
1900
  return {
1784
1901
  ...t,
1785
- prefixe: prefix,
1786
1902
  lignes: l,
1787
1903
  vueEtats: vue,
1788
1904
  groupes,
1789
- fiches: fiches(
1790
- tous,
1791
- [...l, ...vue, ...Object.values(groupes).flat()],
1792
- prefix,
1793
- t.parTicket,
1794
- t.circuits,
1795
- bilansGardes(racine)
1905
+ fiches: Object.assign({}, ...parProjet.map(x => x.fiches)),
1906
+ dernier: dernierBouge(
1907
+ lisibles.flatMap(x => x.tous),
1908
+ l,
1909
+ lisibles.flatMap(x => x.vivants),
1910
+ maintenant
1796
1911
  ),
1797
- dernier: dernierBouge(tous, l, vivants, maintenant),
1798
1912
  etat,
1913
+ ...(projets.length
1914
+ ? {
1915
+ dossiers: Object.fromEntries(
1916
+ parProjet.flatMap(x => Object.keys(x.fiches).map(id => [id, x.dossier]))
1917
+ ),
1918
+ }
1919
+ : {}),
1799
1920
  };
1800
1921
  }
1801
1922
 
1802
1923
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
1803
- const t = tableau(process.cwd());
1924
+ // The arguments other than --texte are the folders of the other projects.
1925
+ const projets = process.argv
1926
+ .slice(2)
1927
+ .filter(a => a !== '--texte')
1928
+ .map(d => path.resolve(d));
1929
+ const t = tableau(process.cwd(), { projets });
1804
1930
  process.stdout.write(
1805
1931
  process.argv.includes('--texte')
1806
1932
  ? `${t.lignes.map(l => l.texte).join('\n')}\n`
package/types/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  export type Ton = 'titre' | 'alerte' | 'attention' | 'actif' | 'discret'
2
2
  // `ticket`: the id of the ticket a line names, which makes the line selectable. `chantier`: the line is an epic's, which the pane switches on or off. `section`: the board's
3
3
  // section the line belongs to. `groupe`: the key of the folded group the line stands for, which `o`
4
- // opens. `etape`: the step a ticket's line of AGENTS stands under (its `numero`, null after the
5
- // steps); `question`: who must answer the question its circuit stopped on.
4
+ // opens.
6
5
  export type Section = 'agents' | 'chantier' | 'faits' | 'etats'
7
6
  export type Ligne = {
8
7
  texte: string
@@ -12,8 +11,6 @@ export type Ligne = {
12
11
  section: Section
13
12
  groupe?: string
14
13
  avancement?: boolean
15
- etape?: { numero: string | null; titre: string }
16
- question?: string
17
14
  }
18
15
  export type Fiche = {
19
16
  numero: string
@@ -26,32 +23,27 @@ export type Fiche = {
26
23
  }
27
24
  // What the mod reads of `grillhouse tableau`: the board's lines, laid out there, the states' view
28
25
  // (`vueEtats`: each state, its meaning, its tickets), each folded group whole (`groupes`), their
29
- // cards, the ticket that moved last, the project's ticket prefix (`prefixe`) and its counters
30
- // (`global.compteurs`). A board fused from several projects' adds its footer (`pied`: a summary of
31
- // each project, a line per project whose board does not read) and the folder of each ticket's
32
- // project (`dossiers`).
26
+ // cards, and the ticket that moved last. The board of several projects adds the folder of each
27
+ // ticket's project (`dossiers`).
33
28
  export type Tableau = {
34
29
  lignes: Ligne[]
35
30
  vueEtats?: Ligne[]
36
31
  groupes?: Record<string, Ligne[]>
37
32
  fiches: Record<string, Fiche>
38
33
  dernier?: string | null
39
- prefixe?: string
40
- global?: { compteurs: { enCours: number; enAttente: number } }
41
- pied?: Ligne[]
42
34
  dossiers?: Record<string, string>
43
35
  }
44
- // A project's board as the pane read it in its folder: the board, or the fault that kept it out.
45
- export type Lu = { dossier: string; tableau: Tableau | null; erreur: string | null }
46
36
  // `choisi`: the ticket whose card the pane shows; `element`: the line the keyboard is on; `grand`:
47
37
  // the card fills the pane; `vue`: the lines shown, the board's, the states' view or one folded
48
38
  // group's (`groupe`, its key); `texte`: the
49
39
  // whole text of the ticket the filled card shows, read from Beads; `projets`: the folders of the
50
- // projects the pane shows beside the session's, kept for the session's folder.
40
+ // projects the pane shows beside the session's, kept for the session's folder; `revision`: one more at
41
+ // each board measured, the version the pane's kept computations read.
51
42
  export type Etat = {
52
43
  tableau: Tableau | null
53
44
  erreur: string | null
54
45
  lu: number
46
+ revision: number
55
47
  choisi: string | null
56
48
  element: string | null
57
49
  grand: boolean