@roomi-fields/grillhouse 0.48.0 → 0.49.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.
Files changed (147) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +68 -0
  3. package/agents/direct.md +9 -0
  4. package/cadre/templates/projet/.github/workflows/ci.yml +6 -0
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +9 -2
  6. package/cadre/templates/projet/CLAUDE.md +9 -5
  7. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  8. package/cadre/templates/turbo/paquets.json +3 -1
  9. package/cadre/templates/turbo/sans-paquets.json +3 -1
  10. package/charte.md +40 -14
  11. package/dist/temporal/circuit/appel.d.ts +4 -1
  12. package/dist/temporal/circuit/appel.js +15 -1
  13. package/dist/temporal/circuit/appel.js.map +1 -1
  14. package/dist/temporal/circuit/client.d.ts +7 -1
  15. package/dist/temporal/circuit/client.js +54 -1
  16. package/dist/temporal/circuit/client.js.map +1 -1
  17. package/dist/temporal/circuit/commande.js +30 -57
  18. package/dist/temporal/circuit/commande.js.map +1 -1
  19. package/dist/temporal/circuit/contrat.d.ts +2 -1
  20. package/dist/temporal/circuit/contrat.js +2 -1
  21. package/dist/temporal/circuit/contrat.js.map +1 -1
  22. package/dist/temporal/circuit/deroule.js +9 -2
  23. package/dist/temporal/circuit/deroule.js.map +1 -1
  24. package/dist/temporal/file/contrat.d.ts +16 -2
  25. package/dist/temporal/file/contrat.js +27 -3
  26. package/dist/temporal/file/contrat.js.map +1 -1
  27. package/dist/temporal/file/deroule.js +4 -4
  28. package/dist/temporal/file/deroule.js.map +1 -1
  29. package/dist/temporal/nuits/activites.d.ts +1 -15
  30. package/dist/temporal/nuits/activites.js +3 -62
  31. package/dist/temporal/nuits/activites.js.map +1 -1
  32. package/dist/temporal/nuits/contrat.d.ts +3 -21
  33. package/dist/temporal/nuits/deroule.js +38 -74
  34. package/dist/temporal/nuits/deroule.js.map +1 -1
  35. package/dist/temporal/places/client.d.ts +3 -16
  36. package/dist/temporal/places/client.js +3 -26
  37. package/dist/temporal/places/client.js.map +1 -1
  38. package/dist/temporal/places/contrat.d.ts +15 -51
  39. package/dist/temporal/places/contrat.js +3 -13
  40. package/dist/temporal/places/contrat.js.map +1 -1
  41. package/dist/temporal/places/deroule.js +11 -61
  42. package/dist/temporal/places/deroule.js.map +1 -1
  43. package/dist/temporal/tickets/activites.js +4 -2
  44. package/dist/temporal/tickets/activites.js.map +1 -1
  45. package/dist/temporal/tickets/contrat.d.ts +2 -1
  46. package/docs/ARCHITECTURE.md +310 -115
  47. package/docs/CADRE.md +16 -13
  48. package/docs/INTERFACE.md +90 -25
  49. package/hooks/hooks.json +9 -0
  50. package/hooks/register.tsx +59 -5
  51. package/package.json +1 -1
  52. package/scripts/activites.mjs +271 -42
  53. package/scripts/aiguillage.mjs +4 -1
  54. package/scripts/bilan.mjs +125 -2
  55. package/scripts/circuit.mjs +233 -159
  56. package/scripts/circuits-cles.d.mts +3 -3
  57. package/scripts/circuits-cles.mjs +6 -5
  58. package/scripts/coeurs-dedies.mjs +4 -4
  59. package/scripts/commandes-composees.mjs +12 -5
  60. package/scripts/dette.d.ts +2 -1
  61. package/scripts/dette.mjs +49 -6
  62. package/scripts/direct.mjs +343 -0
  63. package/scripts/droits.mjs +19 -0
  64. package/scripts/effets.mjs +4 -4
  65. package/scripts/engendres.mjs +2 -1
  66. package/scripts/enveloppe/enveloppe.mjs +67 -13
  67. package/scripts/enveloppe/lancer.sh +14 -3
  68. package/scripts/enveloppe/paquets-du-plan.mjs +9 -0
  69. package/scripts/enveloppe/travail-de-la-copie.mjs +119 -21
  70. package/scripts/etapes.mjs +3 -3
  71. package/scripts/faits-du-circuit.mjs +12 -11
  72. package/scripts/fermeture-de-la-machine.d.mts +4 -4
  73. package/scripts/fermeture-de-la-machine.mjs +10 -20
  74. package/scripts/fichiers-nommes.mjs +27 -1
  75. package/scripts/file-des-tickets.d.mts +18 -1
  76. package/scripts/file-des-tickets.mjs +63 -15
  77. package/scripts/grillhouse-maj.mjs +13 -25
  78. package/scripts/groupe-cles.d.mts +6 -0
  79. package/scripts/groupe-cles.mjs +29 -1
  80. package/scripts/integration/file.mjs +148 -37
  81. package/scripts/jointure.d.ts +17 -3
  82. package/scripts/journal-des-etats.d.mts +16 -0
  83. package/scripts/journal-des-etats.mjs +44 -2
  84. package/scripts/journal.mjs +3 -0
  85. package/scripts/langages/c/commandes.mjs +5 -5
  86. package/scripts/langages/c/composants.mjs +13 -5
  87. package/scripts/langages/cargo/commandes.mjs +5 -6
  88. package/scripts/langages/python/commandes.mjs +5 -5
  89. package/scripts/langages/python/composants.mjs +10 -2
  90. package/scripts/langages/typescript/composants.mjs +10 -3
  91. package/scripts/langages/typescript/construire.mjs +2 -0
  92. package/scripts/langages/typescript/exemples.mjs +33 -1
  93. package/scripts/langages/typescript/index.mjs +19 -0
  94. package/scripts/langages/typescript/migrations/0.49.0-tests-equipes.mjs +32 -0
  95. package/scripts/langages/typescript/tests-de-nuit.mjs +152 -32
  96. package/scripts/langages/typescript/tests-du-poste.mjs +65 -23
  97. package/scripts/langages/typescript/titres-de-tests.mjs +11 -7
  98. package/scripts/langages/typescript/turbo-des-paquets.mjs +21 -4
  99. package/scripts/langages/typescript/verifier.mjs +3 -5
  100. package/scripts/langages/typescript/verrou-des-dependances.mjs +161 -0
  101. package/scripts/langages/typescript/vitest-config/cibles.mjs +57 -6
  102. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +11 -5
  103. package/scripts/langages/typescript/vitest.nuit.config.mjs +53 -5
  104. package/scripts/machine.mjs +1 -1
  105. package/scripts/mesure/base-de-passe.mjs +2 -1
  106. package/scripts/migrations/0.49.0-reservation-de-trois-coeurs.mjs +30 -0
  107. package/scripts/migrations.mjs +2 -0
  108. package/scripts/nuit.sh +97 -2
  109. package/scripts/paquet.mjs +16 -5
  110. package/scripts/paquets.d.ts +4 -0
  111. package/scripts/paquets.mjs +57 -0
  112. package/scripts/passe-de-la-machine.mjs +4 -7
  113. package/scripts/places-de-la-machine.mjs +55 -42
  114. package/scripts/places-du-serveur.mjs +2 -2
  115. package/scripts/plafond-de-la-machine.d.mts +7 -13
  116. package/scripts/plafond-de-la-machine.mjs +19 -35
  117. package/scripts/prefixe-des-tickets.mjs +1 -1
  118. package/scripts/references-changees.mjs +159 -0
  119. package/scripts/regles-des-places.d.mts +8 -31
  120. package/scripts/regles-des-places.mjs +14 -64
  121. package/scripts/repli-de-la-nuit.mjs +112 -0
  122. package/scripts/reponses-du-circuit.d.mts +2 -2
  123. package/scripts/reponses-du-circuit.mjs +21 -12
  124. package/scripts/reprise.mjs +27 -8
  125. package/scripts/resultats.mjs +21 -9
  126. package/scripts/seances.mjs +258 -40
  127. package/scripts/services-du-noyau.mjs +3 -0
  128. package/scripts/sous-commandes.mjs +24 -7
  129. package/scripts/superviseur.mjs +185 -39
  130. package/scripts/tableau.mjs +220 -89
  131. package/scripts/taches-du-graphe.mjs +84 -4
  132. package/scripts/ticket.mjs +345 -0
  133. package/scripts/transitions.d.mts +44 -0
  134. package/scripts/transitions.mjs +173 -13
  135. package/scripts/un-commit-par-ticket.mjs +4 -3
  136. package/scripts/verdict-de-la-nuit.mjs +47 -20
  137. package/scripts/verrou-de-fichier.mjs +2 -2
  138. package/scripts/verrous/ecriture-hors-enveloppe.mjs +86 -0
  139. package/scripts/verrous/verrou.mjs +17 -1
  140. package/skills/developpeur/SKILL.md +1 -1
  141. package/skills/direct/SKILL.md +57 -0
  142. package/skills/explorateur/SKILL.md +10 -6
  143. package/skills/pitmaster/SKILL.md +34 -14
  144. package/skills/pitmaster/references/consigne-agent.md +7 -1
  145. package/skills/relecteur/SKILL.md +8 -0
  146. package/skills/testwriter/SKILL.md +10 -0
  147. package/scripts/ticket.sh +0 -25
@@ -3,13 +3,13 @@
3
3
 
4
4
  /** What the command of closure does on the reservation in place. */
5
5
  export function decisionDeFermeture(
6
- reservation: { auteur?: 'nuit' | 'superviseur' } | null | undefined
7
- ): 'fermer' | 'deja-fermee' | 'nuit-tient';
6
+ reservation: object | null | undefined
7
+ ): 'fermer' | 'deja-fermee';
8
8
 
9
9
  /** What the command of reopening does on the reservation in place. */
10
10
  export function decisionDeReouverture(
11
- reservation: { auteur?: 'nuit' | 'superviseur' } | null | undefined
12
- ): 'rouvrir' | 'deja-ouverte' | 'nuit-tient';
11
+ reservation: object | null | undefined
12
+ ): 'rouvrir' | 'deja-ouverte';
13
13
 
14
14
  /** What still runs by project and by ticket, or « la machine est vide ». */
15
15
  export function direCeQuiTourne(o: {
@@ -9,29 +9,22 @@ import { duree } from './regles-des-places.mjs';
9
9
 
10
10
  /**
11
11
  * What the command of closure does on the reservation <reservation> of the machine (null without):
12
- * `'fermer'` when none stands, `'deja-fermee'` under the supervisor's own closure, `'nuit-tient'`
13
- * when the night holds the machine (an absent author is the night's): no second reservation.
14
- * @param {{ auteur?: 'nuit' | 'superviseur' } | null | undefined} reservation
15
- * @returns {'fermer' | 'deja-fermee' | 'nuit-tient'}
12
+ * `'fermer'` when none stands, `'deja-fermee'` under the supervisor's closure.
13
+ * @param {object | null | undefined} reservation
14
+ * @returns {'fermer' | 'deja-fermee'}
16
15
  */
17
16
  export function decisionDeFermeture(reservation) {
18
- if (!reservation) {
19
- return 'fermer';
20
- }
21
- return reservation.auteur === 'superviseur' ? 'deja-fermee' : 'nuit-tient';
17
+ return reservation ? 'deja-fermee' : 'fermer';
22
18
  }
23
19
 
24
20
  /**
25
21
  * What the command of reopening does on the reservation <reservation>: `'rouvrir'` the supervisor's
26
- * closure, `'deja-ouverte'` when none stands, `'nuit-tient'` for a night's, which it never lifts.
27
- * @param {{ auteur?: 'nuit' | 'superviseur' } | null | undefined} reservation
28
- * @returns {'rouvrir' | 'deja-ouverte' | 'nuit-tient'}
22
+ * closure, `'deja-ouverte'` when none stands.
23
+ * @param {object | null | undefined} reservation
24
+ * @returns {'rouvrir' | 'deja-ouverte'}
29
25
  */
30
26
  export function decisionDeReouverture(reservation) {
31
- if (!reservation) {
32
- return 'deja-ouverte';
33
- }
34
- return reservation.auteur === 'superviseur' ? 'rouvrir' : 'nuit-tient';
27
+ return reservation ? 'rouvrir' : 'deja-ouverte';
35
28
  }
36
29
 
37
30
  // The folder name of a root of project, « alpha » for « /depots/alpha ».
@@ -77,9 +70,8 @@ export function direCeQuiTourne({ prises, parts }) {
77
70
  }
78
71
 
79
72
  /**
80
- * The lines a command says once it has played: its <issue> (`fermee`, `deja-fermee`, `nuit-tient`
81
- * for the closure; `rouverte`, `deja-ouverte`, `nuit-tient` for the reopening), then, for a closure
82
- * or a night that holds the machine, what still runs. <reservation> is the one in place after the
73
+ * The lines a command says once it has played: its <issue> (`fermee`, `deja-fermee` for the
74
+ * closure; `rouverte`, `deja-ouverte` for the reopening), then, for a closure, what still runs. <reservation> is the one in place after the
83
75
  * command (its start gives how long the closure has lasted), <maintenant> the time in ms.
84
76
  * @param {{ issue: string, reservation: { depuis: number } | null,
85
77
  * prises: Parameters<typeof direCeQuiTourne>[0]['prises'],
@@ -96,8 +88,6 @@ export function direLaFermeture({ issue, reservation, prises, parts, maintenant
96
88
  `machine déjà fermée par le superviseur, depuis ${reservation ? duree(maintenant - reservation.depuis) : '?'}`,
97
89
  ...tourne,
98
90
  ];
99
- case 'nuit-tient':
100
- return ['la nuit tient la machine : elle garde sa réservation, aucune autre n’est prise', ...tourne];
101
91
  case 'rouverte':
102
92
  return ['machine rouverte : les circuits reprennent d’eux-mêmes à l’étape suivante'];
103
93
  case 'deja-ouverte':
@@ -2,7 +2,8 @@
2
2
  // in its « Architecture » section or in an acceptance criterion. A file named there is one the
3
3
  // ticket's plan covers by its own word: a write out of the plan in it extends the plan, with the
4
4
  // piece that names it. A parent directory, a base name alone, another section, and the documents
5
- // the responsable owns (ARCHITECTURE.md, CADRE.md, INTERFACE.md) are not named.
5
+ // the responsable owns (ARCHITECTURE.md, CADRE.md, INTERFACE.md) are not named. The plan keeps the
6
+ // component of the title that holds a file named there (`fichiersNommesAuTicket`).
6
7
 
7
8
  const DOCUMENTS_DU_RESPONSABLE = /(^|\/)(ARCHITECTURE|CADRE|INTERFACE)\.md$/;
8
9
 
@@ -53,3 +54,28 @@ export function fichierNommeAuTicket(description, chemin) {
53
54
  }
54
55
  return null;
55
56
  }
57
+
58
+ // The words of a description that may be a path: what its delimiters (`figureDans`) leave.
59
+ const MOTS = /[^\s`'"()[\],;:]+/g;
60
+
61
+ /**
62
+ * The files the description <description> names (`{ chemin, piece }`, in their order, each once):
63
+ * those of its words that <estUnFichier> says a file of the repository, by its path from the root,
64
+ * and that `fichierNommeAuTicket` reads as named.
65
+ */
66
+ export function fichiersNommesAuTicket(description, estUnFichier) {
67
+ const vus = new Set();
68
+ const nommes = [];
69
+ for (const [mot] of String(description ?? '').matchAll(MOTS)) {
70
+ const chemin = mot.replace(/\.$/, '');
71
+ if (vus.has(chemin) || chemin.startsWith('/') || chemin.startsWith('..')) {
72
+ continue;
73
+ }
74
+ vus.add(chemin);
75
+ const nomme = estUnFichier(chemin) ? fichierNommeAuTicket(description, chemin) : null;
76
+ if (nomme) {
77
+ nommes.push({ chemin, piece: nomme.piece });
78
+ }
79
+ }
80
+ return nommes;
81
+ }
@@ -18,9 +18,26 @@ export function aSonArchitecture(t: { description?: string }): boolean;
18
18
  /** The tickets of <tous> that start now, in the order they start. */
19
19
  export function ticketsAPartir<T extends TicketDeBeads>(
20
20
  tous: T[],
21
- o?: { enCours?: Set<string>; externes?: Record<string, TicketDeBeads[]> }
21
+ o?: {
22
+ enCours?: Set<string>;
23
+ externes?: Record<string, TicketDeBeads[]>;
24
+ surMain?: (id: string) => boolean;
25
+ }
22
26
  ): T[];
23
27
 
28
+ /** The tickets of <tous> in the queue that never start because their lot is on main. */
29
+ export function enFileSurMain<T extends TicketDeBeads>(
30
+ tous: T[],
31
+ o?: {
32
+ enCours?: Set<string>;
33
+ externes?: Record<string, TicketDeBeads[]>;
34
+ surMain?: (id: string) => boolean;
35
+ }
36
+ ): T[];
37
+
38
+ /** Whether the lot of a ticket is on the main of the main tree <racine>, as a function of its id. */
39
+ export function lotEstSurMain(racine: string): (id: string) => boolean;
40
+
24
41
  /**
25
42
  * What each ticket of the queue waits for from another project (`external:<project>:<capability>`
26
43
  * not delivered by a closed ticket `provides:<capability>`); `faute` names a project that
@@ -16,6 +16,12 @@
16
16
  // - A circuit alive whose ticket was closed outside it (delivered directly) holds no place: the
17
17
  // queue stops it (`fermesHorsCircuit`).
18
18
  // - A ticket whose dependency is open stays: the board says « attend <ticket> » (scripts/tableau.mjs).
19
+ // - A ticket whose lot is on main never starts again, left open or reopened, as a merge queue
20
+ // drops a merged entry whatever the state of its ticket (bors, GitHub's merge queue): work to
21
+ // do again on an integrated lot is a new ticket, and a lot withdrawn by a revert starts again.
22
+ // `lotEstSurMain` reads it (the one rule `lotSurMain` of ./integration/integrer.mjs), for a
23
+ // ticket that would start alone; `enFileSurMain` names it, for the board and the opening of
24
+ // the supervisor, who closes it.
19
25
  // - A dependency on another project (`external:<project>:<capability>`, Beads' cross-project
20
26
  // dependency) holds the ticket until the provider delivered the capability: a closed ticket of
21
27
  // that project labelled `provides:<capability>` (which `bd ship` sets; `export:` alone does
@@ -25,6 +31,7 @@
25
31
  import { spawnSync } from 'node:child_process';
26
32
  import path from 'node:path';
27
33
  import { ETAPES } from './etapes.mjs';
34
+ import { lotSurMain } from './integration/integrer.mjs';
28
35
 
29
36
  // Whether the description of <t> holds its section « ## Architecture »: the rule the queue and the
30
37
  // board both read.
@@ -89,29 +96,40 @@ export function attendDeLAutreProjet(t, externes) {
89
96
  }));
90
97
  }
91
98
 
99
+ // The tickets of <tous> in the queue that nothing of Beads holds: their section written, every
100
+ // dependency closed, every capability of another project delivered.
101
+ const prets = (tous, enCours, externes) => {
102
+ const fermes = new Set(tous.filter(t => t.status === 'closed').map(t => t.id));
103
+ return enFile(tous, enCours).filter(
104
+ t =>
105
+ aSonArchitecture(t) &&
106
+ (t.dependencies ?? []).every(
107
+ d =>
108
+ d.type !== 'blocks' ||
109
+ (d.depends_on_id.startsWith('external:') ? true : fermes.has(d.depends_on_id))
110
+ ) &&
111
+ dependancesExternes(t).every(d => livree(externes, d.projet, d.capacite))
112
+ );
113
+ };
114
+
92
115
  /**
93
116
  * The tickets of <tous> that start now, in the order they start.
94
117
  * @param {Array<{ id: string, status: string, priority?: number, labels?: string[],
95
118
  * created_at?: string, description?: string,
96
119
  * dependencies?: Array<{ type: string, depends_on_id: string }> }>} tous
97
120
  * every ticket of the project, the closed ones too
98
- * @param {{ enCours?: Set<string>, externes?: Record<string, typeof tous> }} [o] `enCours`, the
99
- * tickets whose circuit already runs; `externes`, the tickets of each other project by its name
121
+ * @param {{ enCours?: Set<string>, externes?: Record<string, typeof tous>,
122
+ * surMain?: (id: string) => boolean }} [o] `enCours`, the tickets whose circuit already runs;
123
+ * `externes`, the tickets of each other project by its name; `surMain`, whether the lot of a
124
+ * ticket is on main (`lotEstSurMain`), asked for a ticket that would start alone
100
125
  * @returns {typeof tous}
101
126
  */
102
- export function ticketsAPartir(tous, { enCours = new Set(), externes } = {}) {
103
- const fermes = new Set(tous.filter(t => t.status === 'closed').map(t => t.id));
104
- return enFile(tous, enCours)
105
- .filter(
106
- t =>
107
- aSonArchitecture(t) &&
108
- (t.dependencies ?? []).every(
109
- d =>
110
- d.type !== 'blocks' ||
111
- (d.depends_on_id.startsWith('external:') ? true : fermes.has(d.depends_on_id))
112
- ) &&
113
- dependancesExternes(t).every(d => livree(externes, d.projet, d.capacite))
114
- )
127
+ export function ticketsAPartir(
128
+ tous,
129
+ { enCours = new Set(), externes, surMain = () => false } = {}
130
+ ) {
131
+ return prets(tous, enCours, externes)
132
+ .filter(t => !surMain(t.id))
115
133
  .sort(
116
134
  (a, b) =>
117
135
  (a.priority ?? 2) - (b.priority ?? 2) ||
@@ -120,6 +138,36 @@ export function ticketsAPartir(tous, { enCours = new Set(), externes } = {}) {
120
138
  );
121
139
  }
122
140
 
141
+ /**
142
+ * The tickets of <tous> in the queue that never start because their lot is on main, sorted by id:
143
+ * those nothing else holds, as `ticketsAPartir` leaves them out.
144
+ * @param {Parameters<typeof ticketsAPartir>[0]} tous every ticket of the project
145
+ * @param {Parameters<typeof ticketsAPartir>[1]} [o]
146
+ * @returns {typeof tous}
147
+ */
148
+ export function enFileSurMain(tous, { enCours = new Set(), externes, surMain = () => false } = {}) {
149
+ return prets(tous, enCours, externes)
150
+ .filter(t => surMain(t.id))
151
+ .sort((a, b) => a.id.localeCompare(b.id, 'en', { numeric: true }));
152
+ }
153
+
154
+ /**
155
+ * Whether the lot of a ticket is on the main of the main tree <racine> (`lotSurMain`), as a
156
+ * function of its id; a prefix of the tickets that does not read holds no ticket, the circuit
157
+ * naming that fault.
158
+ * @param {string} racine
159
+ * @returns {(id: string) => boolean}
160
+ */
161
+ export function lotEstSurMain(racine) {
162
+ return id => {
163
+ try {
164
+ return lotSurMain({ racine }, id) !== null;
165
+ } catch {
166
+ return false;
167
+ }
168
+ };
169
+ }
170
+
123
171
  // The states of the steps of the integration (5.1, 5.2, 5.3): the circuit's own queue closes the
124
172
  // ticket at 5.2, then the circuit sorts its discoveries and ends.
125
173
  const DE_L_INTEGRATION = new Set(
@@ -123,10 +123,11 @@
123
123
  // as `npm install` brings what is installed to what is declared. A plugin that cannot be
124
124
  // installed, or a mod left at another version, has its line naming the command to type; the
125
125
  // update has finished its files, and the exit code is non-zero.
126
- // - The group: when the package.json declares `grillhouse.groupe` (scripts/groupe-cles.mjs), the
127
- // update sets in the Beads of the project each other project of the group as an
128
- // `external_projects.<name>` (its path relative to the project), the ones already set left alone; a group
129
- // badly declared is refused by its key before any work.
126
+ // - The group: when the package.json of the main tree of the project declares `grillhouse.groupe`
127
+ // (`groupeDe` of scripts/groupe-cles.mjs: the update launched in a copy of work reads the same
128
+ // group), the update sets in the Beads of the project each other project of the group as an
129
+ // `external_projects.<name>` (its path relative to the main tree), the ones already set left
130
+ // alone; a group badly declared is refused by its key before any work.
130
131
  // - The generated files: after the package.json, each generator of the declared language
131
132
  // (`miseAJour.generateurs` of its module) is run in the project by the project's command
132
133
  // (`node_modules/.bin/grillhouse`, its installed package) for the file it writes when the project
@@ -161,8 +162,9 @@ import { poserCrochets } from './crochets.mjs';
161
162
  import { ATTRIBUT } from './fusion-du-changelog.mjs';
162
163
  import { fluxSansEntree } from './flux-des-paquets.mjs';
163
164
  import { installerGreffons } from './greffons.mjs';
164
- import { lireGroupe, projetsExternes } from './groupe-cles.mjs';
165
+ import { groupeDe, projetsExternes } from './groupe-cles.mjs';
165
166
  import { migrer, restesAuProjet } from './migrations.mjs';
167
+ import { arbrePrincipal } from './outils-cles.mjs';
166
168
  import { langageDe, langagesDe } from './langages.mjs';
167
169
  import * as langagesDansLArchitecture from './migrations/0.27.0-langages-dans-l-architecture.mjs';
168
170
  import { CONFIG_BEADS, ecrireLePrefixe, prefixe, prefixeDuStore } from './prefixe-des-tickets.mjs';
@@ -343,30 +345,15 @@ export function versionDuProjet(projet) {
343
345
  const jouerBd = (args, cwd) =>
344
346
  spawnSync('bd', args, { cwd, encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 });
345
347
 
346
- // The group the package.json of <projet> declares (null without it); a fault throws, naming its
347
- // key (`grillhouse.groupe`) and its value.
348
- function lireDuGroupe(projet) {
349
- const pkg = path.join(projet, 'package.json');
350
- if (!existsSync(pkg)) {
351
- return null;
352
- }
353
- const { groupe, fautes } = lireGroupe(lireJson(pkg, {}), projet);
354
- if (fautes.length > 0) {
355
- throw new Error(
356
- `⛔ ${fautes.map(f => `${f.cle} vaut ${f.valeur}, pas un chemin de projet existant, une fois`).join(' ; ')}.`
357
- );
358
- }
359
- return groupe;
360
- }
361
-
362
348
  // The `external_projects` of the Beads of <projet>: the other projects of its <groupe>, each by its
363
- // name and its path relative to <projet> (`projetsExternes`); those it sets, by name (none when already set).
349
+ // name and its path relative to the main tree of <projet> (`projetsExternes`), which a copy shares
350
+ // with it; those it sets, by name (none when already set).
364
351
  function poserLesProjetsExternes(projet, groupe, bd) {
365
352
  if (groupe === null) {
366
353
  return [];
367
354
  }
368
355
  const poses = [];
369
- for (const [nom, chemin] of Object.entries(projetsExternes(groupe, projet))) {
356
+ for (const [nom, chemin] of Object.entries(projetsExternes(groupe, arbrePrincipal(projet)))) {
370
357
  const cle = `external_projects.${nom}`;
371
358
  const lu = bd(['config', 'get', cle], projet);
372
359
  if (lu.status === 0 && `${lu.stdout ?? ''}`.trim() === chemin) {
@@ -399,8 +386,9 @@ function cleActive(projet) {
399
386
  * none, the project keeping its own). Returns what changed.
400
387
  */
401
388
  export function mettreAJour(projet, source, { inscrite = VERSION, bd = jouerBd } = {}) {
402
- // The group declared, refused by its key before any work.
403
- const groupe = lireDuGroupe(projet);
389
+ // The group the project declares, read in its main tree (`groupeDe`), refused by its key before
390
+ // any work.
391
+ const groupe = groupeDe(projet);
404
392
  const bilan = {
405
393
  projetsExternes: [],
406
394
  dependances: [],
@@ -18,6 +18,12 @@ export function lireGroupe(
18
18
  racine: string
19
19
  ): { groupe: GroupeDeclare | null; fautes: Array<{ cle: string; valeur: string }> };
20
20
 
21
+ /**
22
+ * The group of the project that holds <dir> (its main tree or a copy), read in the package.json of
23
+ * its main tree; null without the key. Throws the faults of the key.
24
+ */
25
+ export function groupeDe(dir: string): GroupeDeclare | null;
26
+
21
27
  /** The `external_projects` of the Beads of the project at <racine>: the other projects of its group. */
22
28
  export function projetsExternes(
23
29
  groupe: { projets: ProjetDuGroupe[] },
@@ -5,9 +5,13 @@
5
5
  // `grillhouse maj` writes the other projects of the group as the `external_projects` of the Beads
6
6
  // of each (`bd ship` and `external:<project>:<capability>` dependencies resolve through them).
7
7
  // Any other value is a fault, named by its key before any work.
8
+ // The key is the project's: `groupeDe` reads it in the package.json of the main tree of the
9
+ // repository, never of a copy, and resolves its relative paths from that tree, so that a command
10
+ // launched in a copy of work reads the same group as one launched in the main tree.
8
11
  import { createHash } from 'node:crypto';
9
- import { existsSync } from 'node:fs';
12
+ import { existsSync, readFileSync } from 'node:fs';
10
13
  import path from 'node:path';
14
+ import { arbrePrincipal } from './outils-cles.mjs';
11
15
 
12
16
  /**
13
17
  * The group a package.json <pkg> declares, read from the project at <racine>.
@@ -58,6 +62,30 @@ export function lireGroupe(pkg, racine) {
58
62
  return { groupe: { id, projets }, fautes: [] };
59
63
  }
60
64
 
65
+ /**
66
+ * The group of the project that holds <dir>, from the package.json of its main tree, its relative
67
+ * paths resolved from that tree; null without the key, or without a package.json that reads.
68
+ * @param {string} dir a directory of the project: its main tree or a copy
69
+ * @returns {{ id: string, projets: { nom: string, chemin: string }[] } | null}
70
+ * @throws {Error} the faults of the key, each named by its key and its value
71
+ */
72
+ export function groupeDe(dir) {
73
+ const racine = arbrePrincipal(dir);
74
+ let pkg;
75
+ try {
76
+ pkg = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8'));
77
+ } catch {
78
+ return null;
79
+ }
80
+ const { groupe, fautes } = lireGroupe(pkg, racine);
81
+ if (fautes.length > 0) {
82
+ throw new Error(
83
+ `⛔ ${fautes.map(f => `${f.cle} vaut ${f.valeur}, pas un chemin de projet existant, une fois`).join(' ; ')}.`
84
+ );
85
+ }
86
+ return groupe;
87
+ }
88
+
61
89
  /**
62
90
  * The `external_projects` of the Beads of the project at <racine>: the other projects of its
63
91
  * <groupe>, `{ <nom>: <chemin> }`, each path relative to <racine>, the root of its main tree: