@roomi-fields/grillhouse 0.52.0 → 0.53.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/agents/direct.md +1 -1
- package/cadre/templates/projet/vitest.config.cjs +45 -0
- package/charte/superviseur.md +36 -37
- package/charte.md +1 -1
- package/dist/temporal/circuit/appel.d.ts +2 -0
- package/dist/temporal/circuit/appel.js +24 -2
- package/dist/temporal/circuit/appel.js.map +1 -1
- package/dist/temporal/circuit/client.d.ts +14 -5
- package/dist/temporal/circuit/client.js +41 -9
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/commande.js +17 -6
- package/dist/temporal/circuit/commande.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +9 -0
- package/dist/temporal/circuit/contrat.js +6 -0
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +25 -4
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/client.d.ts +35 -1
- package/dist/temporal/client.js +144 -1
- package/dist/temporal/client.js.map +1 -1
- package/dist/temporal/commande.js +31 -13
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/etat.d.ts +3 -1
- package/dist/temporal/etat.js +31 -17
- package/dist/temporal/etat.js.map +1 -1
- package/dist/temporal/file/activites.js +1 -1
- package/dist/temporal/file/activites.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +4 -5
- package/dist/temporal/file/contrat.js +2 -2
- package/dist/temporal/file/contrat.js.map +1 -1
- package/dist/temporal/file/deroule.js +7 -5
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +103 -53
- package/dist/temporal/installation.js +842 -237
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/nuits/deroule.js +3 -1
- package/dist/temporal/nuits/deroule.js.map +1 -1
- package/dist/temporal/places/deroule.js +2 -1
- package/dist/temporal/places/deroule.js.map +1 -1
- package/dist/temporal/sonde/deroule.js +2 -1
- package/dist/temporal/sonde/deroule.js.map +1 -1
- package/dist/temporal/tickets/deroule.js +4 -3
- package/dist/temporal/tickets/deroule.js.map +1 -1
- package/dist/temporal/travailleur.d.ts +7 -1
- package/dist/temporal/travailleur.js +49 -25
- package/dist/temporal/travailleur.js.map +1 -1
- package/docs/INTERFACE.md +17 -12
- package/docs/architecture/circuit.md +18 -15
- package/docs/architecture/entree.md +7 -8
- package/docs/architecture/greffon.md +30 -21
- package/docs/architecture/installation.md +87 -58
- package/docs/architecture/machine.md +1 -1
- package/docs/architecture/tests.md +14 -5
- package/docs/lexique.md +2 -2
- package/hooks/hooks.json +10 -0
- package/hooks/register.tsx +19 -25
- package/package.json +3 -2
- package/scripts/activites.mjs +5 -4
- package/scripts/aiguillage.mjs +1 -0
- package/scripts/circuit.mjs +254 -42
- package/scripts/circuits-du-serveur.mjs +3 -2
- package/scripts/circuits-tenus.d.mts +7 -0
- package/scripts/circuits-tenus.mjs +17 -0
- package/scripts/copie-de-montee.mjs +354 -0
- package/scripts/copies-du-depot.d.mts +13 -0
- package/scripts/copies-du-depot.mjs +66 -0
- package/scripts/copies-finies.mjs +6 -40
- package/scripts/crochets.mjs +16 -2
- package/scripts/direct.mjs +2 -2
- package/scripts/droits.mjs +2 -2
- package/scripts/engendres.mjs +5 -3
- package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
- package/scripts/etapes.mjs +11 -3
- package/scripts/faits-du-circuit.mjs +12 -5
- package/scripts/file-des-tickets.d.mts +13 -2
- package/scripts/file-des-tickets.mjs +44 -12
- package/scripts/greffons.mjs +42 -27
- package/scripts/grillhouse-maj.mjs +105 -85
- package/scripts/init.mjs +1 -1
- package/scripts/integration/file.mjs +5 -2
- package/scripts/integration/integrer.mjs +14 -4
- package/scripts/jointure.d.ts +16 -0
- package/scripts/langages/c/commandes.mjs +17 -7
- package/scripts/langages/cargo/commandes.mjs +87 -34
- package/scripts/langages/cargo/index.mjs +6 -3
- package/scripts/langages/cargo/sccache.mjs +15 -12
- package/scripts/langages/python/commandes.mjs +18 -8
- package/scripts/langages/python/squelette.mjs +2 -2
- package/scripts/langages/typescript/configurations-de-vitest.mjs +118 -0
- package/scripts/langages/typescript/index.mjs +2 -0
- package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +299 -0
- package/scripts/langages/typescript/squelette.mjs +20 -17
- package/scripts/langages/typescript/tests-de-nuit.mjs +3 -3
- package/scripts/langages/typescript/turbo-des-paquets.mjs +24 -37
- package/scripts/langages/typescript/vitest-config/base.mjs +1 -1
- package/scripts/langages/typescript/vitest-config/bornes.mjs +1 -1
- package/scripts/langages/typescript/vitest-config/cibles.mjs +2 -2
- package/scripts/langages/typescript/{vitest.nuit.config.mjs → vitest.nuit.config.cjs} +61 -50
- package/scripts/mesure/pression.mjs +5 -3
- package/scripts/montee.mjs +524 -0
- package/scripts/outil.mjs +5 -3
- package/scripts/paquet-npm.mjs +22 -0
- package/scripts/paquet.mjs +5 -5
- package/scripts/pre-compact.mjs +25 -0
- package/scripts/reponses-du-circuit.d.mts +17 -2
- package/scripts/reponses-du-circuit.mjs +78 -20
- package/scripts/resultats.mjs +40 -12
- package/scripts/retirer-les-copies-finies.mjs +4 -7
- package/scripts/seances.mjs +28 -3
- package/scripts/services-du-noyau.mjs +7 -2
- package/scripts/session-start.sh +18 -11
- package/scripts/sortie.mjs +4 -7
- package/scripts/sous-commandes.mjs +1 -0
- package/scripts/superviseur.mjs +110 -70
- package/scripts/tableau.mjs +127 -108
- package/scripts/ticket-du-circuit.mjs +22 -0
- package/scripts/transitions.d.mts +6 -9
- package/scripts/transitions.mjs +123 -36
- package/scripts/verrou-de-fichier.d.mts +11 -0
- package/skills/direct/SKILL.md +21 -11
- package/skills/explorateur/SKILL.md +6 -1
- package/skills/grill/SKILL.md +9 -7
- package/skills/grill/references/paquets.md +4 -4
- package/skills/pitmaster/SKILL.md +45 -33
- package/skills/pitmaster/references/consigne-agent.md +1 -1
- package/skills/relecteur/SKILL.md +8 -1
- package/skills/testwriter/SKILL.md +1 -1
- package/cadre/templates/projet/vitest.config.ts +0 -44
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
// The copy of a montée (`grillhouse maj`, scripts/montee.mjs): a working copy of its own on the
|
|
2
|
+
// branch `montee/<version>`, laid on the tip of main, in which the montée writes, installs, verifies
|
|
3
|
+
// and commits, so that the main tree changes only once main advanced, as bors and the merge queues
|
|
4
|
+
// enter only the tree they built. The mechanism is installation.md §5.2, under
|
|
5
|
+
// packages/grillhouse/docs/architecture/.
|
|
6
|
+
//
|
|
7
|
+
// - The copy is `.claude/worktrees/montee-<version>` of the main tree, or the one that already holds
|
|
8
|
+
// its branch.
|
|
9
|
+
// - What the montée wrote is kept, path by path with the content it left, in
|
|
10
|
+
// `<git common dir>/grillhouse/montee/<version>.json`, beside its commit: a replay puts those
|
|
11
|
+
// files back and writes them again.
|
|
12
|
+
// - A change of another (uncommitted, tracked or not, outside the ignored files) is set aside under
|
|
13
|
+
// the ref `refs/grillhouse/montee/<version>` while the montée writes and verifies, then laid back,
|
|
14
|
+
// as `git stash` does, by a ref of its own: the stash of a repository is shared by its copies.
|
|
15
|
+
// A file both changed is merged in three ways; a conflict leaves the other's content.
|
|
16
|
+
import { spawnSync } from 'node:child_process';
|
|
17
|
+
import {
|
|
18
|
+
chmodSync,
|
|
19
|
+
existsSync,
|
|
20
|
+
lstatSync,
|
|
21
|
+
mkdirSync,
|
|
22
|
+
mkdtempSync,
|
|
23
|
+
readFileSync,
|
|
24
|
+
readlinkSync,
|
|
25
|
+
renameSync,
|
|
26
|
+
rmSync,
|
|
27
|
+
symlinkSync,
|
|
28
|
+
writeFileSync,
|
|
29
|
+
} from 'node:fs';
|
|
30
|
+
import os from 'node:os';
|
|
31
|
+
import path from 'node:path';
|
|
32
|
+
import { JOURNAL } from './etat-du-depot.mjs';
|
|
33
|
+
|
|
34
|
+
/** The branch of the montée to the version `version`. */
|
|
35
|
+
export const brancheDeLaMontee = version => `montee/${version}`;
|
|
36
|
+
|
|
37
|
+
// git in `racine`: its result, the output as bytes with `binaire`.
|
|
38
|
+
function lancer(racine, args, { env = process.env, binaire = false } = {}) {
|
|
39
|
+
return spawnSync('git', ['-C', racine, ...args], {
|
|
40
|
+
env,
|
|
41
|
+
encoding: binaire ? 'buffer' : 'utf8',
|
|
42
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The output of git in `racine`, trimmed; throws its error. */
|
|
47
|
+
export function git(racine, ...args) {
|
|
48
|
+
const r = lancer(racine, args);
|
|
49
|
+
if (r.status !== 0) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`git ${args.join(' ')} : ${String(r.stderr ?? '').trim() || `code ${r.status}`}`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return r.stdout.trim();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// The paths of a NUL-separated output of git.
|
|
58
|
+
const chemins = texte => texte.split('\0').filter(Boolean);
|
|
59
|
+
|
|
60
|
+
// The paths of the copy that differ from HEAD, tracked or not, the ignored files left out.
|
|
61
|
+
export function changements(copie) {
|
|
62
|
+
const lire = args => {
|
|
63
|
+
const r = lancer(copie, args);
|
|
64
|
+
if (r.status !== 0) {
|
|
65
|
+
throw new Error(`git ${args.join(' ')} : ${r.stderr.trim()}`);
|
|
66
|
+
}
|
|
67
|
+
return chemins(r.stdout);
|
|
68
|
+
};
|
|
69
|
+
return [
|
|
70
|
+
...new Set([
|
|
71
|
+
...lire(['diff', '--name-only', '--no-renames', '-z', 'HEAD']),
|
|
72
|
+
...lire(['ls-files', '--others', '--exclude-standard', '-z']),
|
|
73
|
+
]),
|
|
74
|
+
].filter(f => !f.split('/').includes('node_modules'));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The files of `changements` the montée commits: all but the journal of Beads. */
|
|
78
|
+
export const fichiersEcrits = copie => changements(copie).filter(f => f !== JOURNAL);
|
|
79
|
+
|
|
80
|
+
// What the file `f` of the copy holds: `{ mode, contenu }`, null when absent.
|
|
81
|
+
function surLeDisque(copie, f) {
|
|
82
|
+
const p = path.join(copie, f);
|
|
83
|
+
let st;
|
|
84
|
+
try {
|
|
85
|
+
st = lstatSync(p);
|
|
86
|
+
} catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
if (st.isSymbolicLink()) {
|
|
90
|
+
return { mode: '120000', contenu: Buffer.from(readlinkSync(p)) };
|
|
91
|
+
}
|
|
92
|
+
if (!st.isFile()) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return { mode: st.mode & 0o111 ? '100755' : '100644', contenu: readFileSync(p) };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// What the commit `commit` holds at `f`, as `surLeDisque`.
|
|
99
|
+
function dansLeCommit(copie, commit, f) {
|
|
100
|
+
const entree = lancer(copie, ['ls-tree', '-z', commit, '--', f]).stdout;
|
|
101
|
+
const [mode, type, objet] = entree.split('\t')[0].split(' ');
|
|
102
|
+
if (type !== 'blob') {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return { mode, contenu: lancer(copie, ['cat-file', 'blob', objet], { binaire: true }).stdout };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const egaux = (a, b) =>
|
|
109
|
+
a === null || b === null ? a === b : a.mode === b.mode && a.contenu.equals(b.contenu);
|
|
110
|
+
|
|
111
|
+
// Writes `etat` at `f` of the copy, removes the file for null.
|
|
112
|
+
function poser(copie, f, etat) {
|
|
113
|
+
const p = path.join(copie, f);
|
|
114
|
+
rmSync(p, { force: true, recursive: true });
|
|
115
|
+
if (etat === null) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
mkdirSync(path.dirname(p), { recursive: true });
|
|
119
|
+
if (etat.mode === '120000') {
|
|
120
|
+
symlinkSync(String(etat.contenu), p);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
writeFileSync(p, etat.contenu);
|
|
124
|
+
chmodSync(p, etat.mode === '100755' ? 0o755 : 0o644);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// The empreinte of the content of `f` in the copy, null when absent.
|
|
128
|
+
const empreinte = (copie, f) => {
|
|
129
|
+
const etat = surLeDisque(copie, f);
|
|
130
|
+
if (etat === null) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const r = spawnSync('git', ['-C', copie, 'hash-object', '--stdin'], {
|
|
134
|
+
input: etat.contenu,
|
|
135
|
+
encoding: 'utf8',
|
|
136
|
+
});
|
|
137
|
+
return `${etat.mode} ${r.stdout.trim()}`;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const dossierCommun = racine =>
|
|
141
|
+
git(racine, 'rev-parse', '--path-format=absolute', '--git-common-dir');
|
|
142
|
+
const fichierDeLEtat = (racine, version) =>
|
|
143
|
+
path.join(dossierCommun(racine), 'grillhouse', 'montee', `${version}.json`);
|
|
144
|
+
const refMise = version => `refs/grillhouse/montee/${version}`;
|
|
145
|
+
|
|
146
|
+
/** What the montée to `version` kept of its former passes: `{ ecrits, commit }`. */
|
|
147
|
+
export function lireLEtat(racine, version) {
|
|
148
|
+
try {
|
|
149
|
+
const e = JSON.parse(readFileSync(fichierDeLEtat(racine, version), 'utf8'));
|
|
150
|
+
return { ecrits: e.ecrits ?? {}, commit: e.commit ?? null };
|
|
151
|
+
} catch {
|
|
152
|
+
return { ecrits: {}, commit: null };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Keeps the files `fichiers` the montée wrote, each with its content, and its commit. */
|
|
157
|
+
export function garderLEtat(copie, version, fichiers, commit = null) {
|
|
158
|
+
const f = fichierDeLEtat(copie, version);
|
|
159
|
+
mkdirSync(path.dirname(f), { recursive: true });
|
|
160
|
+
const ecrits = Object.fromEntries(fichiers.map(x => [x, empreinte(copie, x)]));
|
|
161
|
+
const provisoire = `${f}.${process.pid}`;
|
|
162
|
+
writeFileSync(provisoire, `${JSON.stringify({ ecrits, commit }, null, 2)}\n`);
|
|
163
|
+
renameSync(provisoire, f);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The tree of the commit `base` with the files `fichiers` as the copy holds them. */
|
|
167
|
+
export function arbreDe(copie, base, fichiers) {
|
|
168
|
+
const dossier = mkdtempSync(path.join(os.tmpdir(), 'grillhouse-montee-'));
|
|
169
|
+
const env = { ...process.env, GIT_INDEX_FILE: path.join(dossier, 'index') };
|
|
170
|
+
const jouer = args => {
|
|
171
|
+
const r = lancer(copie, args, { env });
|
|
172
|
+
if (r.status !== 0) {
|
|
173
|
+
throw new Error(`git ${args[0]} : ${r.stderr.trim()}`);
|
|
174
|
+
}
|
|
175
|
+
return r.stdout.trim();
|
|
176
|
+
};
|
|
177
|
+
try {
|
|
178
|
+
jouer(['read-tree', base]);
|
|
179
|
+
if (fichiers.length > 0) {
|
|
180
|
+
jouer(['--literal-pathspecs', 'add', '-A', '--', ...fichiers]);
|
|
181
|
+
}
|
|
182
|
+
return jouer(['write-tree']);
|
|
183
|
+
} finally {
|
|
184
|
+
rmSync(dossier, { recursive: true, force: true });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** Puts the copy on the commit `commit`, every change gone but the ignored files. */
|
|
189
|
+
export function remettreSur(copie, commit) {
|
|
190
|
+
git(copie, 'reset', '-q', '--hard', commit);
|
|
191
|
+
git(copie, 'clean', '-q', '-f', '-d', '-e', 'node_modules');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Sets aside the changes of the copy under the ref of the montée, and leaves the copy on HEAD.
|
|
195
|
+
function mettreDeCote(copie, version) {
|
|
196
|
+
const fichiers = changements(copie);
|
|
197
|
+
if (fichiers.length === 0) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const tete = git(copie, 'rev-parse', 'HEAD');
|
|
201
|
+
const arbre = arbreDe(copie, tete, fichiers);
|
|
202
|
+
const commit = git(
|
|
203
|
+
copie,
|
|
204
|
+
'commit-tree',
|
|
205
|
+
arbre,
|
|
206
|
+
'-p',
|
|
207
|
+
tete,
|
|
208
|
+
'-m',
|
|
209
|
+
'the changes of another, set aside by a montée'
|
|
210
|
+
);
|
|
211
|
+
git(copie, 'update-ref', refMise(version), commit);
|
|
212
|
+
remettreSur(copie, tete);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// The merge in three ways of `leur` (another's) onto `notre` since `base`: the content, or null on a
|
|
216
|
+
// conflict.
|
|
217
|
+
function fusion(base, notre, leur) {
|
|
218
|
+
if (!base || !notre || !leur || [base, notre, leur].some(e => e.mode === '120000')) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
const dossier = mkdtempSync(path.join(os.tmpdir(), 'grillhouse-montee-'));
|
|
222
|
+
try {
|
|
223
|
+
const f = (nom, e) => {
|
|
224
|
+
const p = path.join(dossier, nom);
|
|
225
|
+
writeFileSync(p, e.contenu);
|
|
226
|
+
return p;
|
|
227
|
+
};
|
|
228
|
+
const r = spawnSync(
|
|
229
|
+
'git',
|
|
230
|
+
['merge-file', '-p', f('notre', notre), f('base', base), f('leur', leur)],
|
|
231
|
+
{
|
|
232
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
return r.status === 0
|
|
236
|
+
? { mode: leur.mode === base.mode ? notre.mode : leur.mode, contenu: r.stdout }
|
|
237
|
+
: null;
|
|
238
|
+
} finally {
|
|
239
|
+
rmSync(dossier, { recursive: true, force: true });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Each change set aside against what the copy holds: `{ f, etat, conflit }`, `etat` what the copy
|
|
244
|
+
// takes (the other's content on a conflict).
|
|
245
|
+
function misesDeCote(copie, version) {
|
|
246
|
+
const ref = refMise(version);
|
|
247
|
+
if (lancer(copie, ['rev-parse', '--verify', '-q', ref]).status !== 0) {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
const diff = lancer(copie, ['diff', '--name-only', '--no-renames', '-z', `${ref}^`, ref]);
|
|
251
|
+
return chemins(diff.stdout).map(f => {
|
|
252
|
+
const base = dansLeCommit(copie, `${ref}^`, f);
|
|
253
|
+
const leur = dansLeCommit(copie, ref, f);
|
|
254
|
+
const notre = surLeDisque(copie, f);
|
|
255
|
+
if (egaux(notre, base) || egaux(notre, leur)) {
|
|
256
|
+
return { f, etat: leur, conflit: false };
|
|
257
|
+
}
|
|
258
|
+
const fondu = fusion(base, notre, leur);
|
|
259
|
+
return fondu ? { f, etat: fondu, conflit: false } : { f, etat: leur, conflit: true };
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** The files set aside that conflict with what the copy holds. */
|
|
264
|
+
export const conflits = (copie, version) =>
|
|
265
|
+
misesDeCote(copie, version)
|
|
266
|
+
.filter(m => m.conflit)
|
|
267
|
+
.map(m => m.f);
|
|
268
|
+
|
|
269
|
+
/** Lays back on the copy what was set aside; the files that conflicted. */
|
|
270
|
+
export function restaurer(copie, version) {
|
|
271
|
+
const mises = misesDeCote(copie, version);
|
|
272
|
+
for (const { f, etat } of mises) {
|
|
273
|
+
poser(copie, f, etat);
|
|
274
|
+
}
|
|
275
|
+
lancer(copie, ['update-ref', '-d', refMise(version)]);
|
|
276
|
+
return mises.filter(m => m.conflit).map(m => m.f);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// The folder of each copy of the repository, by its branch.
|
|
280
|
+
function copiesParBranche(principal) {
|
|
281
|
+
return new Map(
|
|
282
|
+
git(principal, 'worktree', 'list', '--porcelain')
|
|
283
|
+
.split('\n\n')
|
|
284
|
+
.map(b => [/^branch refs\/heads\/(.*)$/m.exec(b)?.[1], /^worktree (.*)$/m.exec(b)?.[1]])
|
|
285
|
+
.filter(([branche]) => branche)
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* The copy of the montée to `version` of the project at `principal`, laid on the commit `pointe`, the
|
|
291
|
+
* changes of another set aside: a new one, or the one a former montée kept, its files put back.
|
|
292
|
+
* Throws, the copy left as it is, when its branch carries a commit the montée did not write, named.
|
|
293
|
+
*/
|
|
294
|
+
export function preparerLaCopie(principal, version, pointe) {
|
|
295
|
+
const branche = brancheDeLaMontee(version);
|
|
296
|
+
const etat = lireLEtat(principal, version);
|
|
297
|
+
git(principal, 'worktree', 'prune');
|
|
298
|
+
const existe =
|
|
299
|
+
lancer(principal, ['rev-parse', '--verify', '-q', `refs/heads/${branche}`]).status === 0;
|
|
300
|
+
const tenue = copiesParBranche(principal).get(branche);
|
|
301
|
+
const copie = tenue ?? path.join(principal, '.claude', 'worktrees', `montee-${version}`);
|
|
302
|
+
if (existe) {
|
|
303
|
+
const autres = git(principal, 'log', '--format=%H %h %s', `${pointe}..${branche}`)
|
|
304
|
+
.split('\n')
|
|
305
|
+
.filter(l => l && l.split(' ')[0] !== etat.commit)
|
|
306
|
+
.map(l => l.slice(l.indexOf(' ') + 1));
|
|
307
|
+
if (autres.length > 0) {
|
|
308
|
+
throw new Error(
|
|
309
|
+
`la branche ${branche} porte des commits que la montée n'a pas écrits : ${autres.join(' ; ')}. Sa copie ${copie} reste telle quelle.`
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (!tenue) {
|
|
314
|
+
if (existsSync(copie)) {
|
|
315
|
+
throw new Error(
|
|
316
|
+
`${copie} existe et n'est pas la copie de la branche ${branche} : retire-le, puis rejoue la montée.`
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
mkdirSync(path.dirname(copie), { recursive: true });
|
|
320
|
+
git(principal, 'worktree', 'add', '-q', '-B', branche, copie, pointe);
|
|
321
|
+
return { copie, neuve: true };
|
|
322
|
+
}
|
|
323
|
+
// A pass that died while the changes of another were set aside: the copy takes them back first.
|
|
324
|
+
if (lancer(copie, ['rev-parse', '--verify', '-q', refMise(version)]).status === 0) {
|
|
325
|
+
remettreSur(copie, `${refMise(version)}^`);
|
|
326
|
+
restaurer(copie, version);
|
|
327
|
+
}
|
|
328
|
+
if (etat.commit && git(copie, 'rev-parse', 'HEAD') === etat.commit) {
|
|
329
|
+
git(copie, 'reset', '-q', '--mixed', `${etat.commit}~1`);
|
|
330
|
+
}
|
|
331
|
+
// The files the montée had written and nobody changed since go back to HEAD.
|
|
332
|
+
for (const [f, contenu] of Object.entries(etat.ecrits)) {
|
|
333
|
+
if (empreinte(copie, f) === contenu) {
|
|
334
|
+
poser(copie, f, dansLeCommit(copie, 'HEAD', f));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
mettreDeCote(copie, version);
|
|
338
|
+
remettreSur(copie, pointe);
|
|
339
|
+
return { copie, neuve: false };
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Removes the copy of the montée to `version`, its branch and what it kept, unless it holds a change
|
|
344
|
+
* of another; whether it is removed.
|
|
345
|
+
*/
|
|
346
|
+
export function retirerLaCopie(principal, copie, version) {
|
|
347
|
+
if (changements(copie).length > 0) {
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
git(principal, 'worktree', 'remove', '--force', copie);
|
|
351
|
+
git(principal, 'branch', '-q', '-D', brancheDeLaMontee(version));
|
|
352
|
+
rmSync(fichierDeLEtat(principal, version), { force: true });
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// The types of ./copies-du-depot.mjs, for the frame's TypeScript (src/temporal/installation.ts).
|
|
2
|
+
|
|
3
|
+
/** The copies of the porcelain output of `git worktree list`, the main tree first. */
|
|
4
|
+
export function copiesDe(sortie: string): {
|
|
5
|
+
chemin: string;
|
|
6
|
+
tete: string | undefined;
|
|
7
|
+
branche: string | undefined;
|
|
8
|
+
verrou: string | null;
|
|
9
|
+
}[];
|
|
10
|
+
/** The copies of the repository of <racine>, the main tree first; throws when git fails. */
|
|
11
|
+
export function copiesListees(racine: string): ReturnType<typeof copiesDe>;
|
|
12
|
+
/** The ids of the tickets of status <statut> of the project at <racine>, null when unread. */
|
|
13
|
+
export function ticketsDuStatut(racine: string, statut: string): Set<string> | null;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The copies of a repository and the statuses of its tickets, as git and bd say them: what the
|
|
2
|
+
// removal of the finished copies (./copies-finies.mjs) and the purge of the versions of the tool
|
|
3
|
+
// (src/temporal/installation.ts) both read.
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The copies of the porcelain output <sortie> of `git worktree list`, none for an empty one:
|
|
8
|
+
* `{ chemin, tete, branche, verrou }`, the main tree first; `verrou` the reason of a locked copy
|
|
9
|
+
* (`git worktree lock`), null for one unlocked.
|
|
10
|
+
* @param {string} sortie
|
|
11
|
+
*/
|
|
12
|
+
export function copiesDe(sortie) {
|
|
13
|
+
return sortie
|
|
14
|
+
.split('\n\n')
|
|
15
|
+
.map(bloc => bloc.split('\n'))
|
|
16
|
+
.filter(l => l[0]?.startsWith('worktree '))
|
|
17
|
+
.map(l => ({
|
|
18
|
+
chemin: l[0].slice('worktree '.length),
|
|
19
|
+
tete: l.find(x => x.startsWith('HEAD '))?.slice('HEAD '.length),
|
|
20
|
+
branche: l.find(x => x.startsWith('branch refs/heads/'))?.slice('branch refs/heads/'.length),
|
|
21
|
+
verrou:
|
|
22
|
+
l.find(x => x === 'locked' || x.startsWith('locked '))?.slice('locked '.length) ?? null,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The copies `git worktree list` names in the repository of <racine>, the main tree first.
|
|
28
|
+
* @param {string} racine
|
|
29
|
+
* @throws {Error} git failing, by what it says
|
|
30
|
+
*/
|
|
31
|
+
export function copiesListees(racine) {
|
|
32
|
+
const r = spawnSync('git', ['worktree', 'list', '--porcelain'], {
|
|
33
|
+
cwd: racine,
|
|
34
|
+
encoding: 'utf8',
|
|
35
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
36
|
+
});
|
|
37
|
+
if (r.status !== 0) {
|
|
38
|
+
throw new Error(String(r.stderr || r.error?.message || `code ${r.status}`).trim());
|
|
39
|
+
}
|
|
40
|
+
return copiesDe(r.stdout);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const LECTURE_MS = 60_000;
|
|
44
|
+
/**
|
|
45
|
+
* The ids of the tickets of status <statut> of the project at <racine>, null when they do not read
|
|
46
|
+
* within LECTURE_MS.
|
|
47
|
+
* @param {string} racine
|
|
48
|
+
* @param {string} statut
|
|
49
|
+
* @returns {Set<string> | null}
|
|
50
|
+
*/
|
|
51
|
+
export function ticketsDuStatut(racine, statut) {
|
|
52
|
+
const r = spawnSync('bd', ['list', '--status', statut, '--limit', '0', '--json'], {
|
|
53
|
+
cwd: racine,
|
|
54
|
+
encoding: 'utf8',
|
|
55
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
56
|
+
timeout: LECTURE_MS,
|
|
57
|
+
});
|
|
58
|
+
if (r.status !== 0) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
return new Set((JSON.parse(r.stdout || '[]') ?? []).map(t => String(t.id)));
|
|
63
|
+
} catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
import { spawnSync } from 'node:child_process';
|
|
76
76
|
import { existsSync, lstatSync, realpathSync, rmSync } from 'node:fs';
|
|
77
77
|
import path from 'node:path';
|
|
78
|
+
import { copiesDe, ticketsDuStatut } from './copies-du-depot.mjs';
|
|
78
79
|
import { PILOTE } from './fusion-du-changelog.mjs';
|
|
79
80
|
import { langageDe } from './langages.mjs';
|
|
80
81
|
import { nettoyerLeJournal } from './journal-des-etats.mjs';
|
|
@@ -107,21 +108,8 @@ const reel = p => {
|
|
|
107
108
|
}
|
|
108
109
|
};
|
|
109
110
|
|
|
110
|
-
// The copies
|
|
111
|
-
|
|
112
|
-
function lesCopies(racine) {
|
|
113
|
-
return git(racine, 'worktree', 'list', '--porcelain')
|
|
114
|
-
.stdout.split('\n\n')
|
|
115
|
-
.map(bloc => bloc.split('\n'))
|
|
116
|
-
.filter(l => l[0]?.startsWith('worktree '))
|
|
117
|
-
.map(l => ({
|
|
118
|
-
chemin: l[0].slice('worktree '.length),
|
|
119
|
-
tete: l.find(x => x.startsWith('HEAD '))?.slice('HEAD '.length),
|
|
120
|
-
branche: l.find(x => x.startsWith('branch refs/heads/'))?.slice('branch refs/heads/'.length),
|
|
121
|
-
verrou:
|
|
122
|
-
l.find(x => x === 'locked' || x.startsWith('locked '))?.slice('locked '.length) ?? null,
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
111
|
+
// The copies of `racine`, none when git does not list them.
|
|
112
|
+
const lesCopies = racine => copiesDe(git(racine, 'worktree', 'list', '--porcelain').stdout);
|
|
125
113
|
|
|
126
114
|
// What holds the copy <chemin> for a circuit or a live process (its lock), or null. <tenus> names
|
|
127
115
|
// the tickets whose circuit the server holds (it runs, or waits an answer), null when unread. A
|
|
@@ -453,25 +441,6 @@ export function retirerLesCopiesFinies(
|
|
|
453
441
|
return lignes;
|
|
454
442
|
}
|
|
455
443
|
|
|
456
|
-
// The ids of the tickets of status <statut>, null when they do not read within LECTURE_MS.
|
|
457
|
-
const LECTURE_MS = 60_000;
|
|
458
|
-
function tickets(racine, statut) {
|
|
459
|
-
const r = spawnSync('bd', ['list', '--status', statut, '--limit', '0', '--json'], {
|
|
460
|
-
cwd: racine,
|
|
461
|
-
encoding: 'utf8',
|
|
462
|
-
maxBuffer: 256 * 1024 * 1024,
|
|
463
|
-
timeout: LECTURE_MS,
|
|
464
|
-
});
|
|
465
|
-
if (r.status !== 0) {
|
|
466
|
-
return null;
|
|
467
|
-
}
|
|
468
|
-
try {
|
|
469
|
-
return new Set((JSON.parse(r.stdout || '[]') ?? []).map(t => String(t.id)));
|
|
470
|
-
} catch {
|
|
471
|
-
return null;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
444
|
// The directories the tools of the project's language write (`ignorer` of its module), none for a
|
|
476
445
|
// project that declares no language.
|
|
477
446
|
function ignoresDuLangage(racine) {
|
|
@@ -498,14 +467,11 @@ export function retirerLesCopiesDuDepot(racine, finies = [], tenus = null) {
|
|
|
498
467
|
tenus,
|
|
499
468
|
garder: [path.join(racine, NUIT)],
|
|
500
469
|
elaguer: finies,
|
|
501
|
-
lireEnCours: () =>
|
|
502
|
-
lireFermes: () =>
|
|
470
|
+
lireEnCours: () => ticketsDuStatut(racine, 'in_progress'),
|
|
471
|
+
lireFermes: () => ticketsDuStatut(racine, 'closed'),
|
|
503
472
|
ignorer: ignoresDuLangage(racine),
|
|
504
473
|
});
|
|
505
474
|
// The journal of states, bounded as the other working files (scripts/journal-des-etats.mjs).
|
|
506
475
|
const segments = nettoyerLeJournal(racine).retires;
|
|
507
|
-
return [
|
|
508
|
-
...lignes,
|
|
509
|
-
...segments.map(s => `✓ segment ${s} du journal des états retiré.`),
|
|
510
|
-
];
|
|
476
|
+
return [...lignes, ...segments.map(s => `✓ segment ${s} du journal des états retiré.`)];
|
|
511
477
|
}
|
package/scripts/crochets.mjs
CHANGED
|
@@ -111,9 +111,23 @@ function poserCrochet(projet, nom) {
|
|
|
111
111
|
return ecrit ? f : null;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
/**
|
|
115
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Places both frame hooks and the merge driver of the CHANGELOG in the project; returns the paths
|
|
116
|
+
* written. With `dansLArbre`, the hooks are placed only when git reads them from a folder of the
|
|
117
|
+
* project's working tree (a versioned `core.hooksPath`): the copy of a montée writes nothing in
|
|
118
|
+
* the repository it shares with the main tree.
|
|
119
|
+
* @param {string} projet
|
|
120
|
+
* @param {{ dansLArbre?: boolean }} [options]
|
|
121
|
+
*/
|
|
122
|
+
export function poserCrochets(projet, { dansLArbre = false } = {}) {
|
|
116
123
|
poserLePilote(projet);
|
|
124
|
+
const dossier = dossierDesCrochets(projet);
|
|
125
|
+
if (dansLArbre && (!dossier || path.relative(projet, dossier).startsWith('..'))) {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
if (dansLArbre && path.relative(projet, dossier).split(path.sep)[0] === '.git') {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
117
131
|
return Object.keys(CROCHETS)
|
|
118
132
|
.map(nom => poserCrochet(projet, nom))
|
|
119
133
|
.filter(Boolean);
|
package/scripts/direct.mjs
CHANGED
|
@@ -191,7 +191,7 @@ async function refuserUnCircuitVivant(id, ports) {
|
|
|
191
191
|
}
|
|
192
192
|
if (circuits.some(c => c.ticket === id && c.fin === null)) {
|
|
193
193
|
throw new Error(
|
|
194
|
-
`Le ticket ${id} a un circuit qui vit sur le serveur :
|
|
194
|
+
`Le ticket ${id} a un circuit qui vit sur le serveur : prends-le par \`npx bd update ${id} --status in_progress\` (ou la même commande \`bd\`), puis finis le circuit par \`npx grillhouse circuit ${id} --arreter\` ; si son déroulé en panne ne finit pas sur ce mot, termine-le au serveur par \`temporal workflow terminate --workflow-id '${await ports.deroule()}'\`. Le déroulé fini, repose l'étiquette par \`bd update ${id} --add-label direct\`, puis relance la commande.`
|
|
195
195
|
);
|
|
196
196
|
}
|
|
197
197
|
return null;
|
|
@@ -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, module superviseur, « Un ticket prend l'
|
|
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'un de trois circuits, tous menés par le moteur »).`
|
|
277
277
|
);
|
|
278
278
|
}
|
|
279
279
|
if (ticket.status === 'closed') {
|
package/scripts/droits.mjs
CHANGED
|
@@ -165,8 +165,8 @@ export const ROLES = {
|
|
|
165
165
|
porteSonTicket: true,
|
|
166
166
|
commandes: TOUTE_COMMANDE_ET_L_INDEX,
|
|
167
167
|
},
|
|
168
|
-
// The agent of a ticket
|
|
169
|
-
// writes the tests and the code of the whole ticket together, in the envelope of its plan.
|
|
168
|
+
// The agent of a direct ticket, in its circuit or on the way of rescue (`npx grillhouse direct`,
|
|
169
|
+
// scripts/direct.mjs): it writes the tests and the code of the whole ticket together, in the envelope of its plan.
|
|
170
170
|
direct: {
|
|
171
171
|
modules: ['preuve', 'tests'],
|
|
172
172
|
debogage: true,
|
package/scripts/engendres.mjs
CHANGED
|
@@ -204,11 +204,12 @@ export const aRejouer = (engendres, arbre, fichiers) =>
|
|
|
204
204
|
* Applies to the tree of <dansCopie> (git in the tree) the files <fichiers> of the lots <lots>
|
|
205
205
|
* (patch files) that an earlier application left out, those of a generated file the lots remove
|
|
206
206
|
* from the key: a deletion is done whatever main's version is, any other change is applied three
|
|
207
|
-
* ways, to the index too. Null, or the refusal
|
|
208
|
-
*
|
|
207
|
+
* ways, to the index too. Null, or the refusal; `surNonApplique` is called when the refusal is a
|
|
208
|
+
* lot that does not apply.
|
|
209
|
+
* @param {{ lots: string[], fichiers: string[], dansCopie: (...args: string[]) => import('node:child_process').SpawnSyncReturns<string>, surNonApplique?: () => void }} o
|
|
209
210
|
* @returns {string | null}
|
|
210
211
|
*/
|
|
211
|
-
export function poserLesRetires({ lots, fichiers, dansCopie }) {
|
|
212
|
+
export function poserLesRetires({ lots, fichiers, dansCopie, surNonApplique }) {
|
|
212
213
|
if (!fichiers.length) {
|
|
213
214
|
return null;
|
|
214
215
|
}
|
|
@@ -228,6 +229,7 @@ export function poserLesRetires({ lots, fichiers, dansCopie }) {
|
|
|
228
229
|
if (restent.length) {
|
|
229
230
|
const r = dansCopie('apply', '--3way', '--index', '--allow-empty', ...restent, p);
|
|
230
231
|
if (r.status !== 0) {
|
|
232
|
+
surNonApplique?.();
|
|
231
233
|
return `Le lot ${p} ne s'applique pas :\n${r.stdout}${r.stderr}`;
|
|
232
234
|
}
|
|
233
235
|
}
|