@roomi-fields/grillhouse 0.53.0 → 0.54.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 +48 -0
- package/cadre/templates/projet/docs/agents/issue-tracker.md +2 -2
- package/charte.md +12 -0
- package/dist/temporal/circuit/deroule.js +5 -9
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +15 -2
- package/dist/temporal/installation.js +69 -17
- package/dist/temporal/installation.js.map +1 -1
- package/docs/INTERFACE.md +21 -1
- package/docs/architecture/circuit.md +3 -3
- package/docs/architecture/entree.md +4 -4
- package/docs/architecture/greffon.md +19 -10
- package/docs/architecture/installation.md +11 -7
- package/docs/architecture/machine.md +1 -1
- package/docs/architecture/tests.md +1 -1
- package/hooks/register.tsx +50 -24
- package/package.json +1 -1
- package/scripts/aiguillage.mjs +4 -2
- package/scripts/bd-garde.mjs +69 -0
- package/scripts/ci-de-main.mjs +259 -56
- package/scripts/circuit.mjs +20 -5
- package/scripts/commandes-composees.mjs +1 -1
- package/scripts/droits.mjs +11 -4
- package/scripts/file-des-tickets.mjs +27 -9
- package/scripts/langages/c/commandes.mjs +1 -1
- package/scripts/langages/cargo/commandes.mjs +1 -1
- package/scripts/langages/cargo/tailles-des-tests.mjs +115 -6
- package/scripts/langages/python/commandes.mjs +1 -1
- package/scripts/langages/typescript/code-mort.mjs +36 -3
- package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +95 -24
- package/scripts/langages/typescript/mise-a-jour.mjs +49 -12
- package/scripts/langages/typescript/parcours.mjs +5 -1
- package/scripts/langages.d.mts +6 -0
- package/scripts/langages.mjs +6 -0
- package/scripts/lire.mjs +236 -0
- package/scripts/migrations/cout-des-jetons-au-registre.mjs +136 -0
- package/scripts/migrations/lire-un-ticket.mjs +46 -0
- package/scripts/migrations.mjs +4 -0
- package/scripts/montee.mjs +110 -46
- package/scripts/nuit.sh +21 -12
- package/scripts/registre.d.mts +7 -1
- package/scripts/registre.mjs +114 -102
- package/scripts/resultats.mjs +15 -5
- package/scripts/sous-commandes.mjs +1 -0
- package/scripts/suiveur.mjs +12 -4
- package/scripts/superviseur.mjs +28 -17
- package/scripts/tableau.mjs +527 -119
- package/scripts/tarifs.mjs +67 -0
- package/scripts/ticket-du-circuit.mjs +3 -4
- package/scripts/transitions.d.mts +0 -5
- package/scripts/transitions.mjs +3 -13
- package/scripts/verdict-de-la-nuit.mjs +2 -2
- package/skills/explorateur/SKILL.md +10 -5
- package/skills/mesure/SKILL.md +4 -3
- package/skills/pitmaster/SKILL.md +11 -2
- package/skills/pitmaster/references/erreurs.md +4 -2
- package/skills/pitmaster/references/tour.md +11 -4
- package/types/index.d.ts +3 -1
- package/scripts/base-des-workflows.mjs +0 -58
package/scripts/langages.d.mts
CHANGED
|
@@ -20,3 +20,9 @@ export function langagesDe(racine: string): Langage[];
|
|
|
20
20
|
export function langageDe(racine: string): Composition;
|
|
21
21
|
/** The join of the copy <copie>, its readings played in the main tree when they throw in it. */
|
|
22
22
|
export function langageDeLaCopie(copie: string, principal?: () => string | null): Composition;
|
|
23
|
+
|
|
24
|
+
/** The components of the repository at <racine>, read by `langageDeLaCopie`, and the packages out
|
|
25
|
+
* of the frame a plan may name, each `dossier` relative to it. */
|
|
26
|
+
export function composantsLisibles(
|
|
27
|
+
racine: string
|
|
28
|
+
): { dossier: string; pkg: { name: string }; hors: boolean }[];
|
package/scripts/langages.mjs
CHANGED
|
@@ -38,6 +38,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
38
38
|
import { createRequire } from 'node:module';
|
|
39
39
|
import path from 'node:path';
|
|
40
40
|
import { composer } from './composition-des-langages.mjs';
|
|
41
|
+
import { paquetsDuLangage } from './enveloppe/paquets-du-plan.mjs';
|
|
41
42
|
import { matieresDeclarees, sousUneMatiere } from './matieres-lues.mjs';
|
|
42
43
|
import { paquets } from './paquets.mjs';
|
|
43
44
|
import {
|
|
@@ -256,3 +257,8 @@ export function langageDeLaCopie(copie, principal = () => arbrePrincipal(copie))
|
|
|
256
257
|
manifestes: { ...langage.manifestes, horsDesTests: tolerer(langage.manifestes.horsDesTests) },
|
|
257
258
|
});
|
|
258
259
|
}
|
|
260
|
+
|
|
261
|
+
// The components of the repository at <racine>, as `paquetsDuLangage` gives them, still read in a
|
|
262
|
+
// copy its tool no longer loads (`langageDeLaCopie`): what an act of the circuit reads to open on
|
|
263
|
+
// its ticket, so that it writes its stop and resumes, and what the title of a defect of main names.
|
|
264
|
+
export const composantsLisibles = racine => paquetsDuLangage(langageDeLaCopie(racine), racine);
|
package/scripts/lire.mjs
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Reads a ticket, its summary first, as `gh issue view` gives the comments on demand:
|
|
3
|
+
// `grillhouse lire <ticket> [<numéro> | --description | --tout]` (USAGE).
|
|
4
|
+
//
|
|
5
|
+
// - Without option, the summary: the id and the title; the status, the reason of the closure, the
|
|
6
|
+
// labels, the parent and each other dependency, each when the ticket has it; the children by
|
|
7
|
+
// their count per status and the command that lists them; the description up to the end of its
|
|
8
|
+
// section of criteria (a `##` heading that begins with « Critères »; the whole description
|
|
9
|
+
// without one), each section left out named by its title and the presence of notes said, with
|
|
10
|
+
// `--description`; one line per comment: its number (from 1, in the order Beads gives), its
|
|
11
|
+
// author, its date and its first non blank line, cut at 200 characters.
|
|
12
|
+
// - A number gives that comment whole; `--description` the whole description and the notes;
|
|
13
|
+
// `--tout` the summary with the whole description, the notes and every comment whole.
|
|
14
|
+
// - Beads is read, never written: `bd show <ticket> --json`, `bd comments <ticket> --json` and
|
|
15
|
+
// `bd list --parent <ticket> --all --limit 0 --json`, those the answer needs.
|
|
16
|
+
// - Exit codes: 0; 2 with the usage for a call that is not understood; 1 with the reason for a
|
|
17
|
+
// ticket Beads does not give, a reading that fails or a number without comment. A refusal
|
|
18
|
+
// writes nothing on the standard output.
|
|
19
|
+
import { pathToFileURL } from 'node:url';
|
|
20
|
+
import { lancerBd } from './ticket.mjs';
|
|
21
|
+
|
|
22
|
+
export const USAGE = [
|
|
23
|
+
'Lit un ticket : son sommaire d’abord, la suite à la demande.',
|
|
24
|
+
' grillhouse lire <ticket> le sommaire : titre, état, description jusqu’aux',
|
|
25
|
+
' critères, une ligne par commentaire',
|
|
26
|
+
' grillhouse lire <ticket> <numéro> ce commentaire en entier',
|
|
27
|
+
' grillhouse lire <ticket> --description la description entière et les notes',
|
|
28
|
+
' grillhouse lire <ticket> --tout le sommaire, la description entière, les notes et',
|
|
29
|
+
' chaque commentaire en entier',
|
|
30
|
+
'',
|
|
31
|
+
].join('\n');
|
|
32
|
+
|
|
33
|
+
// The characters of the first line of a comment the summary gives.
|
|
34
|
+
const COUPE = 200;
|
|
35
|
+
const OPTIONS = new Set(['--description', '--tout']);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @typedef {import('./ticket.mjs').Bd} Bd
|
|
39
|
+
* @typedef {{ id: string, status?: string, dependency_type?: string }} Dependance
|
|
40
|
+
* @typedef {{ id: string, title?: string, description?: string, notes?: string, status?: string, close_reason?: string, labels?: string[], parent?: string, dependencies?: Dependance[] }} Ticket
|
|
41
|
+
* @typedef {{ author?: string, created_at?: string, text?: string }} Commentaire
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
// What the call <args> of Beads answers, a list read from its JSON; throws, naming the call, when
|
|
45
|
+
// it fails or gives no list.
|
|
46
|
+
async function liste(bd, args) {
|
|
47
|
+
const nomme = `bd ${args.join(' ')}`;
|
|
48
|
+
const r = await bd(args);
|
|
49
|
+
if (r.status !== 0) {
|
|
50
|
+
const raison = String(r.stderr ?? '')
|
|
51
|
+
.trim()
|
|
52
|
+
.split('\n')[0];
|
|
53
|
+
throw new Error(`${nomme} : ${raison || `code ${r.status}`}`);
|
|
54
|
+
}
|
|
55
|
+
let lu;
|
|
56
|
+
try {
|
|
57
|
+
lu = JSON.parse(r.stdout ?? '');
|
|
58
|
+
} catch (e) {
|
|
59
|
+
throw new Error(`${nomme} : réponse illisible (${/** @type {Error} */ (e).message})`);
|
|
60
|
+
}
|
|
61
|
+
if (!Array.isArray(lu)) {
|
|
62
|
+
throw new Error(`${nomme} : aucune liste rendue`);
|
|
63
|
+
}
|
|
64
|
+
return lu;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// The description cut after its section of criteria: what the summary keeps, and the titles of
|
|
68
|
+
// the sections it leaves out. A heading inside a block of code is text.
|
|
69
|
+
function couper(description) {
|
|
70
|
+
const lignes = description.split('\n');
|
|
71
|
+
const titres = [];
|
|
72
|
+
let bloc = false;
|
|
73
|
+
lignes.forEach((ligne, i) => {
|
|
74
|
+
if (/^\s*(```|~~~)/.test(ligne)) {
|
|
75
|
+
bloc = !bloc;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const m = bloc ? null : /^(##?)\s+(.*)$/.exec(ligne);
|
|
79
|
+
if (m) {
|
|
80
|
+
titres.push({ i, niveau: m[1].length, titre: m[2].trim() });
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const criteres = titres.findIndex(t => t.niveau === 2 && t.titre.startsWith('Critères'));
|
|
84
|
+
const ecartes = criteres < 0 ? [] : titres.slice(criteres + 1);
|
|
85
|
+
const gardees = ecartes.length > 0 ? lignes.slice(0, ecartes[0].i) : lignes;
|
|
86
|
+
return { gardee: gardees.join('\n').trimEnd(), ecartees: ecartes.map(t => t.titre) };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// The head of the summary: the id and the title, then each fact of the state the ticket has.
|
|
90
|
+
/** @param {Ticket} t @param {Ticket[]} enfants */
|
|
91
|
+
function tete(t, enfants) {
|
|
92
|
+
const lignes = [`${t.id} — ${t.title ?? ''}`];
|
|
93
|
+
if (t.status) {
|
|
94
|
+
lignes.push(`Statut : ${t.status}`);
|
|
95
|
+
}
|
|
96
|
+
if (t.close_reason) {
|
|
97
|
+
lignes.push(`Motif de fermeture : ${t.close_reason}`);
|
|
98
|
+
}
|
|
99
|
+
if (t.labels?.length) {
|
|
100
|
+
lignes.push(`Étiquettes : ${t.labels.join(', ')}`);
|
|
101
|
+
}
|
|
102
|
+
if (t.parent) {
|
|
103
|
+
lignes.push(`Parent : ${t.parent}`);
|
|
104
|
+
}
|
|
105
|
+
const autres = (t.dependencies ?? []).filter(
|
|
106
|
+
d => !(d.dependency_type === 'parent-child' && d.id === t.parent)
|
|
107
|
+
);
|
|
108
|
+
if (autres.length > 0) {
|
|
109
|
+
lignes.push('Dépendances :');
|
|
110
|
+
lignes.push(...autres.map(d => `- ${d.id} · ${d.dependency_type} · ${d.status}`));
|
|
111
|
+
}
|
|
112
|
+
if (enfants.length > 0) {
|
|
113
|
+
const comptes = new Map();
|
|
114
|
+
for (const e of enfants) {
|
|
115
|
+
comptes.set(e.status, (comptes.get(e.status) ?? 0) + 1);
|
|
116
|
+
}
|
|
117
|
+
const dits = [...comptes].map(([statut, n]) => `${n} ${statut}`).join(', ');
|
|
118
|
+
lignes.push(`Enfants : ${dits} ; leur liste : \`bd list --parent ${t.id}\``);
|
|
119
|
+
}
|
|
120
|
+
return lignes.join('\n');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// The description of <t>, whole, with its notes.
|
|
124
|
+
/** @param {Ticket} t */
|
|
125
|
+
function entiere(t) {
|
|
126
|
+
return [t.description ?? '', ...(t.notes ? [`## Notes\n\n${t.notes}`] : [])].join('\n\n');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// The comment of number <n> whole, under its number, its author and its date.
|
|
130
|
+
/** @param {Commentaire} c @param {number} n */
|
|
131
|
+
function commentaire(c, n) {
|
|
132
|
+
return `### Commentaire ${n} · ${c.author} · ${c.created_at}\n\n${c.text ?? ''}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// The line of the summary for the comment of number <n>.
|
|
136
|
+
/** @param {Commentaire} c @param {number} n */
|
|
137
|
+
function ligneDuCommentaire(c, n) {
|
|
138
|
+
const premiere = [
|
|
139
|
+
...(String(c.text ?? '')
|
|
140
|
+
.split('\n')
|
|
141
|
+
.find(l => l.trim() !== '')
|
|
142
|
+
?.trim() ?? ''),
|
|
143
|
+
];
|
|
144
|
+
const dite =
|
|
145
|
+
premiere.length > COUPE ? `${premiere.slice(0, COUPE).join('')}…` : premiere.join('');
|
|
146
|
+
return `${n}. ${c.author} · ${c.created_at} · ${dite}`;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** @param {Ticket} t @param {Commentaire[]} commentaires @param {Ticket[]} enfants */
|
|
150
|
+
function sommaire(t, commentaires, enfants) {
|
|
151
|
+
const { gardee, ecartees } = couper(t.description ?? '');
|
|
152
|
+
const blocs = [tete(t, enfants), gardee];
|
|
153
|
+
const hors = [
|
|
154
|
+
...(ecartees.length > 0 ? [`les sections ${ecartees.map(s => `« ${s} »`).join(', ')}`] : []),
|
|
155
|
+
...(t.notes ? ['des notes'] : []),
|
|
156
|
+
];
|
|
157
|
+
if (hors.length > 0) {
|
|
158
|
+
blocs.push(
|
|
159
|
+
`Hors du sommaire : ${hors.join(' ; ')}. \`npx grillhouse lire ${t.id} --description\` les rend.`
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
blocs.push(
|
|
163
|
+
commentaires.length === 0
|
|
164
|
+
? 'Commentaires : aucun commentaire.'
|
|
165
|
+
: [
|
|
166
|
+
`Commentaires (\`npx grillhouse lire ${t.id} <numéro>\` en rend un en entier) :`,
|
|
167
|
+
...commentaires.map((c, i) => ligneDuCommentaire(c, i + 1)),
|
|
168
|
+
].join('\n')
|
|
169
|
+
);
|
|
170
|
+
return blocs.join('\n\n');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// What the call asks of the ticket <id>: the text to write.
|
|
174
|
+
async function repondre(id, demande, bd) {
|
|
175
|
+
const [t] = /** @type {Ticket[]} */ (await liste(bd, ['show', id, '--json']));
|
|
176
|
+
if (!t) {
|
|
177
|
+
throw new Error('Beads ne le rend pas');
|
|
178
|
+
}
|
|
179
|
+
if (demande === '--description') {
|
|
180
|
+
return entiere(t);
|
|
181
|
+
}
|
|
182
|
+
const commentaires = /** @type {Commentaire[]} */ (await liste(bd, ['comments', id, '--json']));
|
|
183
|
+
if (demande !== undefined && demande !== '--tout') {
|
|
184
|
+
const n = Number(demande);
|
|
185
|
+
const c = commentaires[n - 1];
|
|
186
|
+
if (!c) {
|
|
187
|
+
throw new Error(
|
|
188
|
+
`aucun commentaire de numéro ${demande} (le ticket en porte ${commentaires.length})`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
return commentaire(c, n);
|
|
192
|
+
}
|
|
193
|
+
const enfants = /** @type {Ticket[]} */ (
|
|
194
|
+
await liste(bd, ['list', '--parent', id, '--all', '--limit', '0', '--json'])
|
|
195
|
+
);
|
|
196
|
+
if (demande === undefined) {
|
|
197
|
+
return sommaire(t, commentaires, enfants);
|
|
198
|
+
}
|
|
199
|
+
return [
|
|
200
|
+
tete(t, enfants),
|
|
201
|
+
entiere(t),
|
|
202
|
+
commentaires.length === 0
|
|
203
|
+
? 'Commentaires : aucun commentaire.'
|
|
204
|
+
: commentaires.map((c, i) => commentaire(c, i + 1)).join('\n\n'),
|
|
205
|
+
].join('\n\n');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The reading the arguments <args> of the command ask of Beads: its exit code and what it writes
|
|
210
|
+
* on each output, nothing written here.
|
|
211
|
+
* @param {string[]} args
|
|
212
|
+
* @param {{ bd: Bd }} options
|
|
213
|
+
* @returns {Promise<{ status: number, stdout: string, stderr: string }>}
|
|
214
|
+
*/
|
|
215
|
+
export async function lireLeTicket(args, { bd }) {
|
|
216
|
+
const [id, demande] = args;
|
|
217
|
+
const comprise = demande === undefined || OPTIONS.has(demande) || /^[1-9]\d*$/.test(demande);
|
|
218
|
+
if (args.length > 2 || !id || id.startsWith('-') || !comprise) {
|
|
219
|
+
return { status: 2, stdout: '', stderr: USAGE };
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
return { status: 0, stdout: `${await repondre(id, demande, bd)}\n`, stderr: '' };
|
|
223
|
+
} catch (e) {
|
|
224
|
+
const raison = /** @type {Error} */ (e).message;
|
|
225
|
+
return { status: 1, stdout: '', stderr: `grillhouse lire ${id} : ${raison}\n` };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
230
|
+
const r = await lireLeTicket(process.argv.slice(2), {
|
|
231
|
+
bd: args => lancerBd(args, process.cwd()),
|
|
232
|
+
});
|
|
233
|
+
process.stdout.write(r.stdout);
|
|
234
|
+
process.stderr.write(r.stderr);
|
|
235
|
+
process.exitCode = r.status;
|
|
236
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// The lines the register of finished agents already holds take for `cout` the price of their own
|
|
2
|
+
// tokens and for `jetons` their count (scripts/registre.mjs): a line written before took the total
|
|
3
|
+
// its session wrote, which holds the spending of its sub-agents, and the output of the first line of
|
|
4
|
+
// each response. Their tokens, cache and cost leave out the responses another transcript of the
|
|
5
|
+
// project retains: a line written before counted each copy. Mechanism: installation.md §5.4
|
|
6
|
+
// (packages/grillhouse/docs/architecture/).
|
|
7
|
+
//
|
|
8
|
+
// - `version`: null until the release that brings it, which `grillhouse sortie` numbers.
|
|
9
|
+
// - `migrer` reckons, for the project (the main tree of <projet>), each line of an agent whose
|
|
10
|
+
// transcript still exists: what the responses of all the agent's transcripts dated up to the
|
|
11
|
+
// line's end and retained by no other transcript count, at their tariff (scripts/tarifs.mjs), as
|
|
12
|
+
// the register writes a line (`depenseJusqua`). A line takes its tokens from them; it takes its
|
|
13
|
+
// cache too when one of its responses is retained elsewhere or its agent has several transcripts,
|
|
14
|
+
// and keeps it otherwise. Before it writes, it keeps a copy of the register beside it. Nothing
|
|
15
|
+
// else of a line changes: the lines of other projects, those without a transcript, the steps of
|
|
16
|
+
// the circuit and a torn line stay as they are. It says the number and the amount of the lines of
|
|
17
|
+
// the project without a transcript, which may hold sub-agents' spending. Played again, it changes
|
|
18
|
+
// and says nothing.
|
|
19
|
+
import { copyFileSync, existsSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import os from 'node:os';
|
|
21
|
+
import { REGISTRE } from '../adresse-du-registre.mjs';
|
|
22
|
+
import { arbrePrincipal, depenseJusqua } from '../registre.mjs';
|
|
23
|
+
import {
|
|
24
|
+
lireSansLesRetenuesAilleurs,
|
|
25
|
+
ROLE_DE_LA_NUIT,
|
|
26
|
+
ROLE_DU_CIRCUIT,
|
|
27
|
+
transcriptionsDuProjet,
|
|
28
|
+
} from '../tableau.mjs';
|
|
29
|
+
import { coutDe } from '../tarifs.mjs';
|
|
30
|
+
import { lacherVerrou, prendreVerrou } from '../verrou-de-fichier.mjs';
|
|
31
|
+
|
|
32
|
+
export const version = '0.54.0';
|
|
33
|
+
export const nom = 'cout des jetons au registre';
|
|
34
|
+
|
|
35
|
+
const lue = ligne => {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(ligne);
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// A path beside the register that holds no file yet.
|
|
44
|
+
function copieLibre() {
|
|
45
|
+
const base = `${REGISTRE}.avant-cout-des-jetons`;
|
|
46
|
+
let f = base;
|
|
47
|
+
for (let n = 2; existsSync(f); n++) {
|
|
48
|
+
f = `${base}.${n}`;
|
|
49
|
+
}
|
|
50
|
+
return f;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The tokens and costs of the register's lines of <projet> reckoned again, each response counted
|
|
55
|
+
* once; returns what it did.
|
|
56
|
+
*/
|
|
57
|
+
export function migrer(projet) {
|
|
58
|
+
if (!existsSync(REGISTRE)) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
const racine = arbrePrincipal(projet);
|
|
62
|
+
const fichiers = new Map();
|
|
63
|
+
for (const { agent, f } of transcriptionsDuProjet(racine, process.env.HOME || os.homedir())) {
|
|
64
|
+
fichiers.set(agent, [...(fichiers.get(agent) ?? []), f]);
|
|
65
|
+
}
|
|
66
|
+
const duProjet = e =>
|
|
67
|
+
e?.projet === racine && e.role !== ROLE_DU_CIRCUIT && e.role !== ROLE_DE_LA_NUIT;
|
|
68
|
+
// The transcripts of the agents that have a line, read before the lock, whose time they would
|
|
69
|
+
// outlast.
|
|
70
|
+
const inscrits = new Set(
|
|
71
|
+
readFileSync(REGISTRE, 'utf8')
|
|
72
|
+
.split('\n')
|
|
73
|
+
.map(lue)
|
|
74
|
+
.filter(duProjet)
|
|
75
|
+
.map(e => e.agent)
|
|
76
|
+
);
|
|
77
|
+
const lues = lireSansLesRetenuesAilleurs(
|
|
78
|
+
[...inscrits].flatMap(agent => fichiers.get(agent) ?? []),
|
|
79
|
+
[...fichiers.values()].flat()
|
|
80
|
+
);
|
|
81
|
+
const verrou = `${REGISTRE}.verrou`;
|
|
82
|
+
prendreVerrou(verrou, { attendre: true, perime: 30_000 });
|
|
83
|
+
try {
|
|
84
|
+
let changees = 0;
|
|
85
|
+
const sans = { lignes: 0, montant: 0 };
|
|
86
|
+
const apres = readFileSync(REGISTRE, 'utf8')
|
|
87
|
+
.split('\n')
|
|
88
|
+
.map(ligne => {
|
|
89
|
+
const e = lue(ligne);
|
|
90
|
+
if (!duProjet(e)) {
|
|
91
|
+
return ligne;
|
|
92
|
+
}
|
|
93
|
+
if (!fichiers.has(e.agent)) {
|
|
94
|
+
if (e.jetons || e.cache) {
|
|
95
|
+
sans.lignes++;
|
|
96
|
+
sans.montant += e.cout ?? 0;
|
|
97
|
+
}
|
|
98
|
+
return ligne;
|
|
99
|
+
}
|
|
100
|
+
// A line written since the reading, or whose transcript does not read, stays.
|
|
101
|
+
const siennes = fichiers.get(e.agent).map(f => lues.get(f));
|
|
102
|
+
if (!siennes.some(Boolean)) {
|
|
103
|
+
return ligne;
|
|
104
|
+
}
|
|
105
|
+
const { jetons, cache, modeles, ecartee } = depenseJusqua(siennes, Date.parse(e.fin));
|
|
106
|
+
const cout = coutDe(modeles);
|
|
107
|
+
const neuve = { jetons, cout, ...(ecartee || siennes.length > 1 ? { cache } : {}) };
|
|
108
|
+
const pareil =
|
|
109
|
+
(cout === e.cout || (cout !== null && Math.abs(cout - (e.cout ?? NaN)) < 1e-9)) &&
|
|
110
|
+
jetons === e.jetons &&
|
|
111
|
+
(neuve.cache === undefined || neuve.cache === e.cache);
|
|
112
|
+
if (pareil) {
|
|
113
|
+
return ligne;
|
|
114
|
+
}
|
|
115
|
+
changees++;
|
|
116
|
+
return JSON.stringify({ ...e, ...neuve });
|
|
117
|
+
});
|
|
118
|
+
if (changees === 0) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
copyFileSync(REGISTRE, copieLibre());
|
|
122
|
+
const neuf = `${REGISTRE}.neuf`;
|
|
123
|
+
writeFileSync(neuf, apres.join('\n'));
|
|
124
|
+
renameSync(neuf, REGISTRE);
|
|
125
|
+
return [
|
|
126
|
+
`registre des agents : jetons et coût recalculés, sans les réponses comptées dans une autre transcription, sur ${changees} ligne(s) du projet, la copie d’avant gardée à côté du registre`,
|
|
127
|
+
...(sans.lignes
|
|
128
|
+
? [
|
|
129
|
+
`registre des agents : ${sans.lignes} ligne(s) du projet sans transcription, laissées telles, pour ${Math.round(sans.montant * 100) / 100} $ ; elles peuvent inclure la dépense de sous-agents`,
|
|
130
|
+
]
|
|
131
|
+
: []),
|
|
132
|
+
];
|
|
133
|
+
} finally {
|
|
134
|
+
lacherVerrou(verrou);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// The `docs/agents/issue-tracker.md` of a project reads a ticket by `npx grillhouse lire`, its
|
|
2
|
+
// summary first, in place of `bd show` and `bd comments`, to read it and to find its handoff.
|
|
3
|
+
// Mechanism: installation.md §5.4 (packages/grillhouse/docs/architecture/).
|
|
4
|
+
//
|
|
5
|
+
// - `version`: null until the release that brings it, which `grillhouse sortie` numbers.
|
|
6
|
+
// - `migrer` replaces each of the two passages of the template it finds, the rest of the file as
|
|
7
|
+
// it is; a file absent, or without either passage, is not written.
|
|
8
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
|
|
11
|
+
export const version = '0.54.0';
|
|
12
|
+
export const nom = 'lire un ticket';
|
|
13
|
+
|
|
14
|
+
const FICHIER = 'docs/agents/issue-tracker.md';
|
|
15
|
+
// Each passage of the template that read a ticket, and what the template
|
|
16
|
+
// (templates/projet/docs/agents/issue-tracker.md) writes in its place.
|
|
17
|
+
const PASSAGES = [
|
|
18
|
+
// The sentence of reading.
|
|
19
|
+
[
|
|
20
|
+
'`bd show <id>`, then `bd comments <id>` (the handoff lives there).',
|
|
21
|
+
'`npx grillhouse lire <id>` gives its summary (title, state, description up to its criteria, one line per comment, the handoff among them). Before acting, play `npx grillhouse lire <id> --description` when the summary names a section left out or notes, and unfold by its number each comment the gesture needs, `npx grillhouse lire <id> <number>` (a handoff is read whole); `--tout` gives everything.',
|
|
22
|
+
],
|
|
23
|
+
// The end of the sentence of handoff.
|
|
24
|
+
[
|
|
25
|
+
'the next session finds it with `bd show` or `bd comments <id>`.',
|
|
26
|
+
'the next session finds it with `npx grillhouse lire <id>`, and unfolds it by its number (`--description` first when the summary names a section left out or notes).',
|
|
27
|
+
],
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
/** The passages that read a ticket replaced in the issue tracker of <projet>; returns what it did. */
|
|
31
|
+
export function migrer(projet) {
|
|
32
|
+
const fichier = path.join(projet, FICHIER);
|
|
33
|
+
if (!existsSync(fichier)) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
const texte = readFileSync(fichier, 'utf8');
|
|
37
|
+
const neuf = PASSAGES.reduce(
|
|
38
|
+
(courant, [ancien, nouveau]) => courant.replace(ancien, () => nouveau),
|
|
39
|
+
texte
|
|
40
|
+
);
|
|
41
|
+
if (neuf === texte) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
writeFileSync(fichier, neuf);
|
|
45
|
+
return [`${FICHIER} : un ticket se lit par \`npx grillhouse lire\`, son sommaire d'abord`];
|
|
46
|
+
}
|
package/scripts/migrations.mjs
CHANGED
|
@@ -53,7 +53,9 @@ import * as ciDeclencheeParLaFile from './migrations/0.48.0-ci-declenchee-par-la
|
|
|
53
53
|
import * as reservationDeTroisCoeurs from './migrations/0.49.0-reservation-de-trois-coeurs.mjs';
|
|
54
54
|
|
|
55
55
|
import * as reglagesHorsDeLaCharte from './migrations/0.50.0-reglages-hors-de-la-charte.mjs';
|
|
56
|
+
import * as lireUnTicket from './migrations/lire-un-ticket.mjs';
|
|
56
57
|
import * as serveursDeLIndex from './migrations/serveurs-de-l-index.mjs';
|
|
58
|
+
import * as coutDesJetons from './migrations/cout-des-jetons-au-registre.mjs';
|
|
57
59
|
import * as suiviDuSuperviseurRetire from './migrations/suivi-du-superviseur-retire.mjs';
|
|
58
60
|
|
|
59
61
|
/** The migrations of the core. */
|
|
@@ -81,7 +83,9 @@ export const MIGRATIONS = [
|
|
|
81
83
|
reservationDeTroisCoeurs,
|
|
82
84
|
reglagesHorsDeLaCharte,
|
|
83
85
|
serveursDeLIndex,
|
|
86
|
+
coutDesJetons,
|
|
84
87
|
suiviDuSuperviseurRetire,
|
|
88
|
+
lireUnTicket,
|
|
85
89
|
];
|
|
86
90
|
|
|
87
91
|
/**
|