@roomi-fields/grillhouse 0.51.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +20 -0
- package/charte/plan.md +47 -0
- package/charte/preuve.md +39 -0
- package/charte/superviseur.md +61 -0
- package/charte/tests.md +38 -0
- package/charte.md +22 -177
- package/dist/temporal/circuit/client.d.ts +1 -2
- package/dist/temporal/circuit/client.js +1 -2
- package/dist/temporal/circuit/client.js.map +1 -1
- package/docs/INTERFACE.md +4 -3
- package/docs/architecture/circuit.md +2 -2
- package/docs/architecture/entree.md +1 -1
- package/docs/architecture/greffon.md +43 -18
- package/docs/architecture/installation.md +17 -7
- package/docs/architecture/machine.md +30 -3
- package/docs/architecture/tests.md +8 -3
- package/docs/lexique.md +10 -1
- package/hooks/hooks.json +0 -10
- package/hooks/register.tsx +91 -3
- package/package.json +2 -1
- package/scripts/activites.mjs +20 -5
- package/scripts/aiguillage.mjs +0 -1
- package/scripts/attente-au-tour.mjs +2 -3
- package/scripts/bilan.mjs +116 -56
- package/scripts/bilans-gardes.mjs +37 -0
- package/scripts/circuit.mjs +3 -1
- package/scripts/direct.mjs +1 -1
- package/scripts/droits.mjs +115 -36
- package/scripts/entree-de-seance.mjs +35 -0
- package/scripts/enveloppe/enveloppe.mjs +23 -16
- package/scripts/enveloppe/lancer.sh +32 -22
- package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
- package/scripts/jointure.d.ts +2 -1
- package/scripts/langages/python/commandes.mjs +50 -7
- package/scripts/langages/python/squelette.mjs +2 -1
- package/scripts/langages/typescript/index.mjs +12 -12
- package/scripts/langages/typescript/turbo-des-paquets.mjs +52 -2
- package/scripts/langages/typescript/verifier.mjs +27 -2
- package/scripts/migrations/serveurs-de-l-index.mjs +1 -1
- package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
- package/scripts/migrations.mjs +2 -0
- package/scripts/nuit.sh +3 -2
- package/scripts/paquet.mjs +1 -1
- package/scripts/resultats.mjs +2 -2
- package/scripts/seances.mjs +53 -26
- package/scripts/session-start.sh +8 -6
- package/scripts/sortie-de-seance.mjs +70 -0
- package/scripts/sous-commandes.mjs +0 -1
- package/scripts/superviseur.mjs +373 -155
- package/scripts/tableau.mjs +127 -49
- package/skills/explorateur/SKILL.md +2 -2
- package/skills/grill/SKILL.md +3 -2
- package/skills/pitmaster/SKILL.md +68 -34
- package/skills/pitmaster/references/cadre.md +1 -1
- package/skills/pitmaster/references/tour.md +6 -5
- package/skills/relecteur/SKILL.md +1 -1
- package/skills/testwriter/SKILL.md +2 -2
- package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
- package/scripts/attente-a-l-arret.mjs +0 -114
package/docs/lexique.md
CHANGED
|
@@ -107,7 +107,8 @@ L'unité qu'on construit et qu'on publie, d'un seul langage, une ligne du tablea
|
|
|
107
107
|
_À éviter_ : composant, crate, projet
|
|
108
108
|
|
|
109
109
|
**Module** :
|
|
110
|
-
Une partie interne d'un paquet,
|
|
110
|
+
Une partie interne d'un paquet, le module d'un langage dans le cadre, ou un module de la charte
|
|
111
|
+
commune, ses règles propres à un public.
|
|
111
112
|
|
|
112
113
|
## L'entrée sur main
|
|
113
114
|
|
|
@@ -140,6 +141,14 @@ _À éviter_ : mise à jour, upgrade, migration
|
|
|
140
141
|
Un arrêt du circuit qui attend le superviseur.
|
|
141
142
|
_À éviter_ : blocage, demande
|
|
142
143
|
|
|
144
|
+
**Note de reprise** :
|
|
145
|
+
Ce que la séance du superviseur transmet à la suivante, une par dépôt.
|
|
146
|
+
_À éviter_ : suivi, passation
|
|
147
|
+
|
|
148
|
+
**Jalon** :
|
|
149
|
+
Le moment que la séance du superviseur déclare propre à son renouvellement.
|
|
150
|
+
_À éviter_ : point d'étape, checkpoint
|
|
151
|
+
|
|
143
152
|
**Remontée** :
|
|
144
153
|
Un défaut qu'un projet du cadre signale au cadre.
|
|
145
154
|
_À éviter_ : retour, feedback
|
package/hooks/hooks.json
CHANGED
package/hooks/register.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import type { Etat, Fiche, Ligne, Tableau } from '../types'
|
|
|
19
19
|
// the frame's command measures their board as one (`grillhouse tableau <dossier>…`), which the
|
|
20
20
|
// pane draws as it draws one project's. `/grillhouse newday` sets the day's marker to now
|
|
21
21
|
// (`grillhouse newday`): FAITS AUJOURD'HUI and the « rejetés »/« validés » cases restart from zero.
|
|
22
|
+
// The session of supervision renews itself at a milestone it declared (`renouveler`).
|
|
22
23
|
const PANE = 'grillhouse'
|
|
23
24
|
// The frame's command, which the project's `npm install` links, and its package.
|
|
24
25
|
const GRILLHOUSE = 'node_modules/.bin/grillhouse'
|
|
@@ -497,6 +498,13 @@ let relevee = false
|
|
|
497
498
|
const tours = new Set<string>()
|
|
498
499
|
// The messages submitted and not yet read: their text, and the time they were put in the queue.
|
|
499
500
|
const soumis: { texte: string; envoyeA: number }[] = []
|
|
501
|
+
// What the renewal reads of the session: the time of its last Stop with no task in flight and of
|
|
502
|
+
// the last message of the owner (0 without one), and whether a compaction of the main conversation
|
|
503
|
+
// is still to tell.
|
|
504
|
+
let arretA = 0
|
|
505
|
+
let messageA = 0
|
|
506
|
+
let compaction = false
|
|
507
|
+
const DU_RESPONSABLE = new Set(['composer', 'bridge'])
|
|
500
508
|
|
|
501
509
|
// A turn started at <lueA> with <texte>: the questions of each message it contains are read, those
|
|
502
510
|
// sent up to the latest such message. A text that holds no submitted message marks nothing.
|
|
@@ -519,13 +527,30 @@ export async function pousserLesQuestions($: EngineInterface): Promise<void> {
|
|
|
519
527
|
if (!eligible || relevee || tours.size) return
|
|
520
528
|
relevee = true
|
|
521
529
|
try {
|
|
522
|
-
|
|
530
|
+
await relever($)
|
|
531
|
+
await renouveler($)
|
|
532
|
+
} finally {
|
|
533
|
+
relevee = false
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// One reading of the questions: its message submitted to the session. A compaction not yet told
|
|
538
|
+
// goes with it, and stays to tell when the reading gave nothing for a fault.
|
|
539
|
+
async function relever($: EngineInterface): Promise<void> {
|
|
540
|
+
const apresCompaction = compaction
|
|
541
|
+
compaction = false
|
|
542
|
+
try {
|
|
543
|
+
const r = await $.process.run(
|
|
544
|
+
[GRILLHOUSE, 'superviseur', '--relever', cwd, ...(apresCompaction ? ['--compaction'] : [])],
|
|
545
|
+
{ cwd, timeoutMs: 60_000 },
|
|
546
|
+
)
|
|
523
547
|
// A reading at fault can still give a message: that of the projects of the group it read.
|
|
524
548
|
if (r.exitCode !== 0) {
|
|
525
549
|
const faute = (r.stderr || '').trim().slice(0, 300)
|
|
526
550
|
if (faute) await update($, etat, s => ({ ...s, erreur: faute }))
|
|
527
551
|
}
|
|
528
552
|
const texte = (r.stdout || '').trim()
|
|
553
|
+
if (apresCompaction && r.exitCode !== 0 && !texte) compaction = true
|
|
529
554
|
if (texte) {
|
|
530
555
|
// The questions of this message are sent: kept with the time they were put in it, until a
|
|
531
556
|
// turn starts with its text (`marquerLesLues`).
|
|
@@ -535,11 +560,51 @@ export async function pousserLesQuestions($: EngineInterface): Promise<void> {
|
|
|
535
560
|
}
|
|
536
561
|
} catch {
|
|
537
562
|
// a reading that fails is taken again at the next period
|
|
538
|
-
|
|
539
|
-
|
|
563
|
+
if (apresCompaction) compaction = true
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// The renewal of the session of supervision (greffon.md, §5.1), as a worker is recycled between
|
|
568
|
+
// two requests. The frame's command judges (`grillhouse superviseur --renouveler`): it is told the
|
|
569
|
+
// time of the last Stop of the session that left no task in flight (`arretA`) and of the last
|
|
570
|
+
// message of the owner (`messageA`), and gives the message of resumption when the milestone is due.
|
|
571
|
+
// The mod then runs /clear and submits it, unless a turn runs, a draft stands in the prompt box, a
|
|
572
|
+
// message of questions is not read, or a Stop or a message of the owner came since the command was
|
|
573
|
+
// asked. A /clear refused is tried again at a later period.
|
|
574
|
+
async function renouveler($: EngineInterface): Promise<void> {
|
|
575
|
+
if (tours.size) return
|
|
576
|
+
const dits = { arretA, messageA }
|
|
577
|
+
try {
|
|
578
|
+
const r = await $.process.run(
|
|
579
|
+
[GRILLHOUSE, 'superviseur', '--renouveler', cwd, String(dits.arretA), String(dits.messageA)],
|
|
580
|
+
{ cwd, timeoutMs: 60_000 },
|
|
581
|
+
)
|
|
582
|
+
const reprise = (r.stdout || '').trim()
|
|
583
|
+
if (r.exitCode !== 0 || !reprise) return
|
|
584
|
+
if ((await $.prompt.read()).text !== '') return
|
|
585
|
+
if (tours.size || soumis.length || arretA !== dits.arretA || messageA !== dits.messageA) return
|
|
586
|
+
await $.command.run({ command: 'clear' })
|
|
587
|
+
arretA = 0
|
|
588
|
+
void $.prompt.submit({ text: reprise })
|
|
589
|
+
} catch {
|
|
590
|
+
// a renewal refused is tried again at the next period
|
|
540
591
|
}
|
|
541
592
|
}
|
|
542
593
|
|
|
594
|
+
// The /clear of the session ends its context: what the mod holds of it starts over, and the pane
|
|
595
|
+
// takes its projects again from the store, the state having been emptied.
|
|
596
|
+
async function reprendreApresClear($: EngineInterface): Promise<void> {
|
|
597
|
+
arretA = 0
|
|
598
|
+
messageA = 0
|
|
599
|
+
compaction = false
|
|
600
|
+
tours.clear()
|
|
601
|
+
soumis.length = 0
|
|
602
|
+
if (!eligible) return
|
|
603
|
+
const projets = await lireLaListe($)
|
|
604
|
+
await update($, etat, s => ({ ...s, projets }))
|
|
605
|
+
void demarrer($)
|
|
606
|
+
}
|
|
607
|
+
|
|
543
608
|
// The board applies to a Grillhouse project outside an agent's copy (`eligible`), once someone can
|
|
544
609
|
// see it: a person at the terminal's prompt from the start (`isInteractive`), or a surface that
|
|
545
610
|
// attaches later — the desktop app's Code tab, whose session starts headless, as the SDK's does,
|
|
@@ -595,6 +660,29 @@ export const register: Register = on => {
|
|
|
595
660
|
return next(e)
|
|
596
661
|
})
|
|
597
662
|
|
|
663
|
+
on('classic.Stop', (_$, e, next) => {
|
|
664
|
+
arretA = e.background_tasks?.length === 0 ? Date.now() : 0
|
|
665
|
+
return next(e)
|
|
666
|
+
})
|
|
667
|
+
|
|
668
|
+
on('prompt.submit', (_$, e, next) => {
|
|
669
|
+
if (DU_RESPONSABLE.has(e.origin?.kind ?? '')) messageA = Date.now()
|
|
670
|
+
return next(e)
|
|
671
|
+
})
|
|
672
|
+
|
|
673
|
+
// A compaction installed in the main conversation: neither a subagent's, nor one computed ahead.
|
|
674
|
+
on('session.compact', async (_$, e, next) => {
|
|
675
|
+
const r = await next(e)
|
|
676
|
+
if (!e.agentId && e.trigger !== 'precompute' && !('skip' in r)) compaction = true
|
|
677
|
+
return r
|
|
678
|
+
})
|
|
679
|
+
|
|
680
|
+
on('classic.SessionStart', async ($, e, next) => {
|
|
681
|
+
const r = await next(e)
|
|
682
|
+
if (e.source === 'clear') await reprendreApresClear($)
|
|
683
|
+
return r
|
|
684
|
+
})
|
|
685
|
+
|
|
598
686
|
// The command answers at once; the board comes from the follower's lines.
|
|
599
687
|
// `ajouter <chemin>` and `retirer <chemin>` change the projects the pane shows.
|
|
600
688
|
on('command.run', { command: 'grillhouse' }, async ($, e) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roomi-fields/grillhouse",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"description": "Roomi's Grillhouse: the frame's scripts, called by one command, grillhouse <sous-commande>",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"agents",
|
|
30
30
|
"bin",
|
|
31
31
|
"cadre",
|
|
32
|
+
"charte",
|
|
32
33
|
"charte.md",
|
|
33
34
|
"dist",
|
|
34
35
|
"docs",
|
package/scripts/activites.mjs
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
texteDesDifferences,
|
|
40
40
|
} from './references-changees.mjs';
|
|
41
41
|
import { ecrireLaListe, VARIABLE as VARIABLE_ENVELOPPE } from './enveloppe/paquets-du-plan.mjs';
|
|
42
|
+
import { inscrireLeLot, rendreLIndex } from './enveloppe/travail-de-la-copie.mjs';
|
|
42
43
|
import { auteurDuCode, etapeDuCircuit, EXPLORATEUR, SUITE } from './etapes.mjs';
|
|
43
44
|
import { gardesDuCadre, nomsDesGardes } from './gardes-du-cadre.mjs';
|
|
44
45
|
import { INTEGRE } from './integration/file.mjs';
|
|
@@ -1566,11 +1567,20 @@ function npm(ctx, etape, args, env = {}, cwd = ctx.copie) {
|
|
|
1566
1567
|
...(args[0] === 'test' || args[1] === 'verifier' ? mesureDesPasses(ctx) : {}),
|
|
1567
1568
|
})
|
|
1568
1569
|
);
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
}
|
|
1570
|
+
// A command of the checks or of the final pass judges the tree of the lot, its
|
|
1571
|
+
// new files in the index; the index is put back after it.
|
|
1572
|
+
if (etape === 'controles') {
|
|
1573
|
+
inscrireLeLot(ctx.copie);
|
|
1574
|
+
}
|
|
1575
|
+
try {
|
|
1576
|
+
return spawnSync(lancement.cmd, lancement.args, {
|
|
1577
|
+
cwd,
|
|
1578
|
+
stdio: ['ignore', fd, fd],
|
|
1579
|
+
env: lancement.env,
|
|
1580
|
+
});
|
|
1581
|
+
} finally {
|
|
1582
|
+
rendreLIndex(ctx.copie);
|
|
1583
|
+
}
|
|
1574
1584
|
} finally {
|
|
1575
1585
|
oublier();
|
|
1576
1586
|
}
|
|
@@ -1744,6 +1754,8 @@ export function preuveARepasser(ctx, runs) {
|
|
|
1744
1754
|
// the copy changed (`mesureDeLaPreuve`).
|
|
1745
1755
|
// A measure with a run at 75 proved nothing: the proof is « à repasser » (`preuveARepasser`).
|
|
1746
1756
|
export function preuve(ctx, { mesure: derniere = null, fichiers: duRouge = null } = {}) {
|
|
1757
|
+
// Before any read of the copy: the index a killed pass left is put back.
|
|
1758
|
+
rendreLIndex(ctx.copie);
|
|
1747
1759
|
// Only the files of the day are proved; the ones only the night plays are put aside, named.
|
|
1748
1760
|
// Resumed at a red (<duRouge>, the files it names), the proof plays the tests among them alone
|
|
1749
1761
|
// (<seuls>) and passes when they load: a test fixed is green, not red. A red that names no test
|
|
@@ -2229,6 +2241,9 @@ const ligneDeCommande = c =>
|
|
|
2229
2241
|
// at the final pass, each key of the debt a guard wrote inscribed above what it finds, `{ garde,
|
|
2230
2242
|
// fichier, regle, trouve }`.
|
|
2231
2243
|
export function controles(ctx, finale, restreinte = null, reportes = null, fichiers = null) {
|
|
2244
|
+
// Before any read of the copy: the index a killed pass left is put back, or git reads the lot
|
|
2245
|
+
// as staged there (a file moved is a rename, its source no longer a change).
|
|
2246
|
+
rendreLIndex(ctx.copie);
|
|
2232
2247
|
const liste = composantsDe(ctx.copie).filter(p => !p.hors);
|
|
2233
2248
|
// Resumed at a red in the test files <fichiers>: the final pass plays their packages alone (the
|
|
2234
2249
|
// graph of packages of Turborepo, the root's tasks beside), the checks of the plan their tests
|
package/scripts/aiguillage.mjs
CHANGED
|
@@ -60,7 +60,6 @@ const PAQUET_QUI_TOURNE = path.resolve(import.meta.dirname, '..');
|
|
|
60
60
|
* results, the removal of a copy and the balance, even when the supervisor runs one by hand.
|
|
61
61
|
*/
|
|
62
62
|
export const REDIRIGEES = new Set([
|
|
63
|
-
'attente-a-l-arret',
|
|
64
63
|
'attente-au-tour',
|
|
65
64
|
'bilan',
|
|
66
65
|
'circuit',
|
|
@@ -21,13 +21,12 @@ import { ligneDeQuestion, questionsEnAttente, ticketsHorsAttente } from './super
|
|
|
21
21
|
/**
|
|
22
22
|
* The root of the repository whose session of supervision works in <dossier>: null out of a git
|
|
23
23
|
* repository, in an agent's copy (a worktree) and in the session of a role that the circuit
|
|
24
|
-
* launches (BEADS_ACTOR set).
|
|
25
|
-
* scripts/attente-a-l-arret.mjs).
|
|
24
|
+
* launches (BEADS_ACTOR set).
|
|
26
25
|
* @param {string} dossier
|
|
27
26
|
* @param {Record<string, string | undefined>} env
|
|
28
27
|
* @returns {string | null}
|
|
29
28
|
*/
|
|
30
|
-
|
|
29
|
+
function racineDeLaSupervision(dossier, env = process.env) {
|
|
31
30
|
if (env.BEADS_ACTOR) {
|
|
32
31
|
return null;
|
|
33
32
|
}
|
package/scripts/bilan.mjs
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
// `bilan` of scripts/effets.mjs and read from the Temporal server by the command); the night
|
|
20
20
|
// the project declares (`grillhouse.plageDeNuit`); the transcript of each supervisor's session
|
|
21
21
|
// a stop names (`~/.claude/projects/<projet>/<séance>.jsonl`), for the origin and the time of
|
|
22
|
-
// each message
|
|
22
|
+
// each message; the transcript of each session the circuit launched, found the same way, for
|
|
23
|
+
// the usage of its first request, read by the board's reader (scripts/tableau.mjs).
|
|
23
24
|
// - The steps and the roles are those of scripts/etapes.mjs; a register line's role is read as
|
|
24
25
|
// the board reads it (`roleDeLAgent`: bare, or scoped `grillhouse:<rôle>`). Only the circuit's
|
|
25
26
|
// roles count; only the sessions the circuit launched count in the window, the categories, the
|
|
@@ -56,6 +57,10 @@
|
|
|
56
57
|
// the questions of the plan asked, the plans they changed and the questions left open, the tri
|
|
57
58
|
// of the discoveries on a line of its own, the tokens, the cache reads and the cost (a session
|
|
58
59
|
// without a cost counts 0); a session's tokens go to its turns by their time.
|
|
60
|
+
// - `premiersTours` holds one `{ seance, role }` per session the circuit launched, whether the
|
|
61
|
+
// register holds it or not, with the input, cache written and cache read of its first response
|
|
62
|
+
// of a model (`entree`, `cacheEcrit`, `cacheLu`), none of them without a readable one; the text
|
|
63
|
+
// gives their means by role over the sessions that have them.
|
|
59
64
|
// - It is kept in the main tree, `.claude/worktrees/<ticket>.bilan.json`, and compares itself with
|
|
60
65
|
// the latest other ticket of the project whose bilan is kept, recomputed by this version from
|
|
61
66
|
// its sources (`precedent`), or with nothing when none is: no figure kept by an earlier version,
|
|
@@ -75,6 +80,14 @@ import os from 'node:os';
|
|
|
75
80
|
import path from 'node:path';
|
|
76
81
|
import { StringDecoder } from 'node:string_decoder';
|
|
77
82
|
import { REGISTRE } from './adresse-du-registre.mjs';
|
|
83
|
+
import {
|
|
84
|
+
bilansGardes,
|
|
85
|
+
dollars,
|
|
86
|
+
dossier,
|
|
87
|
+
minutes,
|
|
88
|
+
pourcent,
|
|
89
|
+
SUFFIXE,
|
|
90
|
+
} from './bilans-gardes.mjs';
|
|
78
91
|
import { lireLaConsommation } from './consommation-des-passes.mjs';
|
|
79
92
|
import { lireLeJournal } from './journal-des-etats.mjs';
|
|
80
93
|
import { pathToFileURL } from 'node:url';
|
|
@@ -89,12 +102,14 @@ import {
|
|
|
89
102
|
SUPERVISEUR,
|
|
90
103
|
tousLesRolesDe,
|
|
91
104
|
} from './etapes.mjs';
|
|
105
|
+
import { lireFichier } from './tableau.mjs';
|
|
106
|
+
|
|
107
|
+
export { bilansGardes, enBref } from './bilans-gardes.mjs';
|
|
92
108
|
|
|
93
109
|
// The role of a register line that a step of the circuit writes, and of its results.
|
|
94
110
|
const CIRCUIT = 'circuit';
|
|
95
111
|
// The gap allowed between a result and the turn or step it closes.
|
|
96
112
|
const JEU = 2000;
|
|
97
|
-
const MINUTE = 60_000;
|
|
98
113
|
|
|
99
114
|
// The categories, in the order the text lists them, with their names.
|
|
100
115
|
const CATEGORIES = [
|
|
@@ -133,23 +148,42 @@ export function plageDeNuit(racine) {
|
|
|
133
148
|
: NUIT;
|
|
134
149
|
}
|
|
135
150
|
|
|
136
|
-
// The
|
|
137
|
-
// its end hour, of the next day when it crosses midnight, in local time.
|
|
151
|
+
// The bounds [start, end] (ms) of the night <nuit> that starts the day of <jour>: from its start
|
|
152
|
+
// hour of that day to its end hour, of the next day when it crosses midnight, in local time.
|
|
153
|
+
function laNuitDu(jour, nuit) {
|
|
154
|
+
const a = new Date(jour);
|
|
155
|
+
a.setHours(nuit.debut, 0, 0, 0);
|
|
156
|
+
const b = new Date(a);
|
|
157
|
+
if (nuit.fin < nuit.debut) {
|
|
158
|
+
b.setDate(b.getDate() + 1);
|
|
159
|
+
}
|
|
160
|
+
b.setHours(nuit.fin, 0, 0, 0);
|
|
161
|
+
return [a.getTime(), b.getTime()];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// The start (ms) of the night <nuit> that runs at <maintenant>; null by day.
|
|
165
|
+
export function nuitEnCours(maintenant, nuit) {
|
|
166
|
+
const veille = new Date(maintenant);
|
|
167
|
+
veille.setDate(veille.getDate() - 1);
|
|
168
|
+
for (const jour of [veille, maintenant]) {
|
|
169
|
+
const [a, b] = laNuitDu(jour, nuit);
|
|
170
|
+
if (a <= maintenant && maintenant < b) {
|
|
171
|
+
return a;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// The parts of the interval [d, f] in the nights <nuit>.
|
|
138
178
|
function nuits([d, f], nuit) {
|
|
139
179
|
const out = [];
|
|
140
180
|
const jour = new Date(d);
|
|
141
181
|
jour.setHours(0, 0, 0, 0);
|
|
142
182
|
jour.setDate(jour.getDate() - 1);
|
|
143
183
|
while (jour.getTime() < f) {
|
|
144
|
-
const a =
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
if (nuit.fin < nuit.debut) {
|
|
148
|
-
b.setDate(b.getDate() + 1);
|
|
149
|
-
}
|
|
150
|
-
b.setHours(nuit.fin);
|
|
151
|
-
const x = Math.max(a.getTime(), d);
|
|
152
|
-
const y = Math.min(b.getTime(), f);
|
|
184
|
+
const [a, b] = laNuitDu(jour, nuit);
|
|
185
|
+
const x = Math.max(a, d);
|
|
186
|
+
const y = Math.min(b, f);
|
|
153
187
|
if (y > x) {
|
|
154
188
|
out.push([x, y]);
|
|
155
189
|
}
|
|
@@ -279,7 +313,8 @@ function tracesDuJournal(journal, ticket) {
|
|
|
279
313
|
// The bilan of <ticket> from the register's lines <lignes> (of its project), the results the
|
|
280
314
|
// circuit kept <entrees> (`<ticket>.fiches.jsonl`), the circuit's state <etat> (or null), the
|
|
281
315
|
// project's night <nuit> and the times of the owner's messages in the supervisor's sessions the
|
|
282
|
-
// stops name <duResponsable
|
|
316
|
+
// stops name <duResponsable>; `premierTour` gives the usage of the first request of the session it
|
|
317
|
+
// is given, or null.
|
|
283
318
|
export function bilan({
|
|
284
319
|
ticket,
|
|
285
320
|
lignes,
|
|
@@ -288,6 +323,7 @@ export function bilan({
|
|
|
288
323
|
nuit = NUIT,
|
|
289
324
|
duResponsable = [],
|
|
290
325
|
journal = [],
|
|
326
|
+
premierTour = () => null,
|
|
291
327
|
maintenant = Date.now(),
|
|
292
328
|
}) {
|
|
293
329
|
// The sessions the circuit launched, by their id.
|
|
@@ -500,6 +536,17 @@ export function bilan({
|
|
|
500
536
|
c.cache = Math.round(c.cache);
|
|
501
537
|
}
|
|
502
538
|
|
|
539
|
+
// One entry per session the circuit launched, by its id.
|
|
540
|
+
const lesLancements = new Map(
|
|
541
|
+
entrees
|
|
542
|
+
.filter(e => e.role === CIRCUIT && e.lancement)
|
|
543
|
+
.map(e => [e.lancement.seance, roleDeLAgent(e.lancement.role)])
|
|
544
|
+
);
|
|
545
|
+
const premiersTours = [...lesLancements].map(([seance, role]) => ({
|
|
546
|
+
seance,
|
|
547
|
+
role,
|
|
548
|
+
...premierTour(seance),
|
|
549
|
+
}));
|
|
503
550
|
const sessions = agents.filter(l => l.role !== CIRCUIT);
|
|
504
551
|
// The sessions <l> by role, in the order of the steps.
|
|
505
552
|
const parRoleDe = l => {
|
|
@@ -598,6 +645,7 @@ export function bilan({
|
|
|
598
645
|
arrets,
|
|
599
646
|
questionnement,
|
|
600
647
|
tri,
|
|
648
|
+
premiersTours,
|
|
601
649
|
jetons: somme('jetons'),
|
|
602
650
|
cache: somme('cache'),
|
|
603
651
|
cout: somme('cout'),
|
|
@@ -615,15 +663,8 @@ function statutDe(etat) {
|
|
|
615
663
|
return 'en cours';
|
|
616
664
|
}
|
|
617
665
|
|
|
618
|
-
const minutes = ms => Math.round(ms / MINUTE);
|
|
619
|
-
const pourcent = (x, sur) => (sur ? Math.round((100 * x) / sur) : 0);
|
|
620
|
-
const dollars = x => (x ?? 0).toFixed(2).replace('.', ',');
|
|
621
666
|
const millions = x => ((x ?? 0) / 1e6).toFixed(2).replace('.', ',');
|
|
622
667
|
|
|
623
|
-
// The key figures of the bilan <b> in one sentence, as the ticket's card shows them.
|
|
624
|
-
export const enBref = b =>
|
|
625
|
-
`Bilan : ${minutes(b.mur)} min, ${pourcent(b.perdu, b.mur)} % perdus, ${b.seances.total} séances, ${dollars(b.cout)} $.`;
|
|
626
|
-
|
|
627
668
|
/**
|
|
628
669
|
* The passes of <ticket> that consumed clearly more than their part, from the register of the
|
|
629
670
|
* consumption of the project at <racine> (scripts/consommation-des-passes.mjs): each `{ sorte,
|
|
@@ -701,18 +742,38 @@ export function texteDuBilan(b, avant, depassent = []) {
|
|
|
701
742
|
.map(([nom, ms]) => `${nom} ${minutes(ms)} min`)
|
|
702
743
|
.join(', ');
|
|
703
744
|
const reprise = `Reprise après un rouge : ${minutes(b.reprise.rejoue.ms)} min rejouées${b.reprise.rejoue.ms ? ` (${parEtape(b.reprise.rejoue)})` : ''}, ${minutes(b.reprise.relu.ms)} min relues sans rejouer${b.reprise.relu.ms ? ` (${parEtape(b.reprise.relu)})` : ''}.`;
|
|
745
|
+
const premiers = ligneDesPremiersTours(b.premiersTours ?? []);
|
|
704
746
|
const parts = depassent.length
|
|
705
747
|
? [
|
|
706
748
|
`Passes au-delà de leur part : ${depassent.length} (${depassent.map(d => `${d.sorte}, ${d.depasse}`).join(' ; ')}).`,
|
|
707
749
|
]
|
|
708
750
|
: [];
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
);
|
|
751
|
+
const fin = [...premiers, ...parts, `Arrêts : ${arrets || 'aucun'}.`, base];
|
|
752
|
+
return [tete, ...lignes, ...tri, reprise, ...fin].join('\n');
|
|
712
753
|
}
|
|
713
754
|
|
|
714
|
-
|
|
715
|
-
|
|
755
|
+
// The line of the first requests of the sessions <tours> (`premiersTours`): by role, in the order
|
|
756
|
+
// of the steps, the means in whole tokens over the measured sessions and their number; no line
|
|
757
|
+
// without a measured session.
|
|
758
|
+
function ligneDesPremiersTours(tours) {
|
|
759
|
+
const mesures = tours.filter(t => t.entree !== undefined);
|
|
760
|
+
const roles = new Set([...ROLES, ...mesures.map(t => t.role)]);
|
|
761
|
+
const parRole = [...roles].flatMap(role => {
|
|
762
|
+
const l = mesures.filter(t => t.role === role);
|
|
763
|
+
if (!l.length) {
|
|
764
|
+
return [];
|
|
765
|
+
}
|
|
766
|
+
const moyennes = ['entree', 'cacheEcrit', 'cacheLu']
|
|
767
|
+
.map(k => Math.round(l.reduce((m, t) => m + t[k], 0) / l.length))
|
|
768
|
+
.join(', ');
|
|
769
|
+
return [`${nomDuRole(role)} ${moyennes} (${l.length} séance${l.length > 1 ? 's' : ''})`];
|
|
770
|
+
});
|
|
771
|
+
return parRole.length
|
|
772
|
+
? [
|
|
773
|
+
`Premier tour, moyenne par rôle en jetons (entrée, cache écrit, cache lu) : ${parRole.join(' ; ')}.`,
|
|
774
|
+
]
|
|
775
|
+
: [];
|
|
776
|
+
}
|
|
716
777
|
|
|
717
778
|
// Keeps the bilan <b> in the main tree <racine>.
|
|
718
779
|
export function garder(racine, b) {
|
|
@@ -722,31 +783,11 @@ export function garder(racine, b) {
|
|
|
722
783
|
renameSync(provisoire, f);
|
|
723
784
|
}
|
|
724
785
|
|
|
725
|
-
// The bilans kept in the main tree <racine>, by ticket; a file that does not parse is left out.
|
|
726
|
-
export function bilansGardes(racine) {
|
|
727
|
-
const d = dossier(racine);
|
|
728
|
-
const out = {};
|
|
729
|
-
if (!existsSync(d)) {
|
|
730
|
-
return out;
|
|
731
|
-
}
|
|
732
|
-
for (const n of readdirSync(d).filter(x => x.endsWith(SUFFIXE))) {
|
|
733
|
-
try {
|
|
734
|
-
const b = JSON.parse(readFileSync(path.join(d, n), 'utf8'));
|
|
735
|
-
if (b?.ticket) {
|
|
736
|
-
out[b.ticket] = b;
|
|
737
|
-
}
|
|
738
|
-
} catch {
|
|
739
|
-
// A torn bilan counts nothing.
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
return out;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
786
|
// The base of the bilan of <ticket> in the main tree <racine>: the bilan of the latest other ticket
|
|
746
787
|
// whose bilan is kept, computed again by this version from its sources, as a bench of time remakes
|
|
747
788
|
// its base, never the figures kept by the version that wrote them; null when its sources give no
|
|
748
789
|
// bilan any more. The figures a base gives (wall time, loss, sessions, cost) hold whoever waited,
|
|
749
|
-
// the owner or the supervisor:
|
|
790
|
+
// the owner or the supervisor: no transcript is read.
|
|
750
791
|
export function precedent(racine, ticket) {
|
|
751
792
|
const avant = Object.values(bilansGardes(racine))
|
|
752
793
|
.filter(b => b.ticket !== ticket)
|
|
@@ -754,7 +795,7 @@ export function precedent(racine, ticket) {
|
|
|
754
795
|
if (!avant) {
|
|
755
796
|
return null;
|
|
756
797
|
}
|
|
757
|
-
const b = calculer(racine, avant.ticket, {
|
|
798
|
+
const b = calculer(racine, avant.ticket, { transcriptions: false });
|
|
758
799
|
return b.mur > 0 ? b : null;
|
|
759
800
|
}
|
|
760
801
|
|
|
@@ -798,15 +839,32 @@ export function messagesDuResponsable(texte) {
|
|
|
798
839
|
// whole.
|
|
799
840
|
const MORCEAU = 1_048_576;
|
|
800
841
|
|
|
801
|
-
// The
|
|
802
|
-
//
|
|
803
|
-
function
|
|
842
|
+
// The transcript of the session <seance>, in any project folder of ~/.claude/projects (the main
|
|
843
|
+
// tree's or a copy's); undefined when none holds it.
|
|
844
|
+
function transcriptionDeLaSeance(seance) {
|
|
804
845
|
const projets = path.join(os.homedir(), '.claude', 'projects');
|
|
805
|
-
|
|
846
|
+
return existsSync(projets)
|
|
806
847
|
? readdirSync(projets)
|
|
807
848
|
.map(d => path.join(projets, d, `${seance}.jsonl`))
|
|
808
849
|
.find(g => existsSync(g))
|
|
809
|
-
:
|
|
850
|
+
: undefined;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
// The usage of the first request of the session <seance>, read in its transcript; null without a
|
|
854
|
+
// transcript that reads, or without a readable usage.
|
|
855
|
+
function premierTourDeLaSeance(seance) {
|
|
856
|
+
const f = transcriptionDeLaSeance(seance);
|
|
857
|
+
try {
|
|
858
|
+
return f ? lireFichier(f).premierTour : null;
|
|
859
|
+
} catch {
|
|
860
|
+
return null;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// The times of the owner's messages in the transcript of the supervisor's session <seance>; none
|
|
865
|
+
// when no transcript holds it.
|
|
866
|
+
function messagesDeLaSeance(seance) {
|
|
867
|
+
const f = transcriptionDeLaSeance(seance);
|
|
810
868
|
if (!f) {
|
|
811
869
|
return [];
|
|
812
870
|
}
|
|
@@ -831,8 +889,9 @@ function messagesDeLaSeance(seance) {
|
|
|
831
889
|
|
|
832
890
|
// The bilan of <ticket> computed from the main tree <racine>: its register, the results its
|
|
833
891
|
// circuit kept, where its circuit ended (<fin>, `{ etape, raison, code }`, null while it runs), and
|
|
834
|
-
// the owner's messages in the supervisor's sessions its stops name
|
|
835
|
-
|
|
892
|
+
// the owner's messages in the supervisor's sessions its stops name and the first request of each
|
|
893
|
+
// session it launched, unless <transcriptions> is false: then no transcript is read.
|
|
894
|
+
function calculer(racine, ticket, fin, { transcriptions = true } = {}) {
|
|
836
895
|
const lignes = lignesDuProjet(
|
|
837
896
|
existsSync(REGISTRE) ? readFileSync(REGISTRE, 'utf8') : '',
|
|
838
897
|
racine
|
|
@@ -854,7 +913,8 @@ function calculer(racine, ticket, fin, { responsable = true } = {}) {
|
|
|
854
913
|
entrees,
|
|
855
914
|
etat: fin,
|
|
856
915
|
nuit: plageDeNuit(racine),
|
|
857
|
-
duResponsable:
|
|
916
|
+
duResponsable: transcriptions ? [...seances].flatMap(s => messagesDeLaSeance(String(s))) : [],
|
|
917
|
+
premierTour: transcriptions ? s => premierTourDeLaSeance(String(s)) : undefined,
|
|
858
918
|
journal: lireLeJournal(racine, { ticket }).lignes,
|
|
859
919
|
});
|
|
860
920
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The bilans the circuit keeps in the main tree (`.claude/worktrees/<ticket>.bilan.json`, written
|
|
2
|
+
// by scripts/bilan.mjs) and their key figures: what the board (scripts/tableau.mjs) reads of them.
|
|
3
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
const MINUTE = 60_000;
|
|
7
|
+
|
|
8
|
+
export const dossier = racine => path.join(racine, '.claude', 'worktrees');
|
|
9
|
+
export const SUFFIXE = '.bilan.json';
|
|
10
|
+
|
|
11
|
+
export const minutes = ms => Math.round(ms / MINUTE);
|
|
12
|
+
export const pourcent = (x, sur) => (sur ? Math.round((100 * x) / sur) : 0);
|
|
13
|
+
export const dollars = x => (x ?? 0).toFixed(2).replace('.', ',');
|
|
14
|
+
|
|
15
|
+
// The key figures of the bilan <b> in one sentence, as the ticket's card shows them.
|
|
16
|
+
export const enBref = b =>
|
|
17
|
+
`Bilan : ${minutes(b.mur)} min, ${pourcent(b.perdu, b.mur)} % perdus, ${b.seances.total} séances, ${dollars(b.cout)} $.`;
|
|
18
|
+
|
|
19
|
+
// The bilans kept in the main tree <racine>, by ticket; a file that does not parse is left out.
|
|
20
|
+
export function bilansGardes(racine) {
|
|
21
|
+
const d = dossier(racine);
|
|
22
|
+
const out = {};
|
|
23
|
+
if (!existsSync(d)) {
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
for (const n of readdirSync(d).filter(x => x.endsWith(SUFFIXE))) {
|
|
27
|
+
try {
|
|
28
|
+
const b = JSON.parse(readFileSync(path.join(d, n), 'utf8'));
|
|
29
|
+
if (b?.ticket) {
|
|
30
|
+
out[b.ticket] = b;
|
|
31
|
+
}
|
|
32
|
+
} catch {
|
|
33
|
+
// A torn bilan counts nothing.
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
package/scripts/circuit.mjs
CHANGED
|
@@ -227,7 +227,7 @@ import {
|
|
|
227
227
|
|
|
228
228
|
// The sheet of the plan that says a field, as scripts/resultats.mjs reads it.
|
|
229
229
|
export { ficheDuPlan };
|
|
230
|
-
import { preparer, rolesDuConflit } from './enveloppe/travail-de-la-copie.mjs';
|
|
230
|
+
import { preparer, rendreLIndex, rolesDuConflit } from './enveloppe/travail-de-la-copie.mjs';
|
|
231
231
|
import { refusArbitrage } from './integration/integrer.mjs';
|
|
232
232
|
import { prendreUnRang } from './places-de-la-machine.mjs';
|
|
233
233
|
import { langageDe, langageDeLaCopie } from './langages.mjs';
|
|
@@ -1033,6 +1033,8 @@ export function publierLArret(ctx, erreur, etat) {
|
|
|
1033
1033
|
// The fact <fait> of the circuit of <ctx>, with its <parametres>, the facts <faits> of the step
|
|
1034
1034
|
// read before it: a session, a pass, a reading of the copy or of the ticket.
|
|
1035
1035
|
export async function lireLeFait(ctx, fait, parametres, faits) {
|
|
1036
|
+
// Before any fact reads the copy: the index a killed pass left is put back.
|
|
1037
|
+
rendreLIndex(ctx.copie);
|
|
1036
1038
|
switch (fait) {
|
|
1037
1039
|
case 'mecanique':
|
|
1038
1040
|
return cheminMecanique(ctx);
|
package/scripts/direct.mjs
CHANGED
|
@@ -273,7 +273,7 @@ export async function lancerLeDirect({ id, ticket, panne, options = [], ports })
|
|
|
273
273
|
}
|
|
274
274
|
if (!(ticket.labels ?? []).includes('direct')) {
|
|
275
275
|
throw new Error(
|
|
276
|
-
`Le ticket ${id} n'est pas étiqueté direct : la commande ne mène que les tickets de la voie directe (charte, « Un ticket prend l'une de trois voies »).`
|
|
276
|
+
`Le ticket ${id} n'est pas étiqueté direct : la commande ne mène que les tickets de la voie directe (charte, module superviseur, « Un ticket prend l'une de trois voies »).`
|
|
277
277
|
);
|
|
278
278
|
}
|
|
279
279
|
if (ticket.status === 'closed') {
|