@roomi-fields/grillhouse 0.52.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.
Files changed (155) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +96 -0
  3. package/agents/direct.md +1 -1
  4. package/cadre/templates/projet/docs/agents/issue-tracker.md +2 -2
  5. package/cadre/templates/projet/vitest.config.cjs +45 -0
  6. package/charte/superviseur.md +36 -37
  7. package/charte.md +13 -1
  8. package/dist/temporal/circuit/appel.d.ts +2 -0
  9. package/dist/temporal/circuit/appel.js +24 -2
  10. package/dist/temporal/circuit/appel.js.map +1 -1
  11. package/dist/temporal/circuit/client.d.ts +14 -5
  12. package/dist/temporal/circuit/client.js +41 -9
  13. package/dist/temporal/circuit/client.js.map +1 -1
  14. package/dist/temporal/circuit/commande.js +17 -6
  15. package/dist/temporal/circuit/commande.js.map +1 -1
  16. package/dist/temporal/circuit/contrat.d.ts +9 -0
  17. package/dist/temporal/circuit/contrat.js +6 -0
  18. package/dist/temporal/circuit/contrat.js.map +1 -1
  19. package/dist/temporal/circuit/deroule.js +29 -12
  20. package/dist/temporal/circuit/deroule.js.map +1 -1
  21. package/dist/temporal/client.d.ts +35 -1
  22. package/dist/temporal/client.js +144 -1
  23. package/dist/temporal/client.js.map +1 -1
  24. package/dist/temporal/commande.js +31 -13
  25. package/dist/temporal/commande.js.map +1 -1
  26. package/dist/temporal/etat.d.ts +3 -1
  27. package/dist/temporal/etat.js +31 -17
  28. package/dist/temporal/etat.js.map +1 -1
  29. package/dist/temporal/file/activites.js +1 -1
  30. package/dist/temporal/file/activites.js.map +1 -1
  31. package/dist/temporal/file/contrat.d.ts +4 -5
  32. package/dist/temporal/file/contrat.js +2 -2
  33. package/dist/temporal/file/contrat.js.map +1 -1
  34. package/dist/temporal/file/deroule.js +7 -5
  35. package/dist/temporal/file/deroule.js.map +1 -1
  36. package/dist/temporal/installation.d.ts +116 -53
  37. package/dist/temporal/installation.js +898 -241
  38. package/dist/temporal/installation.js.map +1 -1
  39. package/dist/temporal/nuits/deroule.js +3 -1
  40. package/dist/temporal/nuits/deroule.js.map +1 -1
  41. package/dist/temporal/places/deroule.js +2 -1
  42. package/dist/temporal/places/deroule.js.map +1 -1
  43. package/dist/temporal/sonde/deroule.js +2 -1
  44. package/dist/temporal/sonde/deroule.js.map +1 -1
  45. package/dist/temporal/tickets/deroule.js +4 -3
  46. package/dist/temporal/tickets/deroule.js.map +1 -1
  47. package/dist/temporal/travailleur.d.ts +7 -1
  48. package/dist/temporal/travailleur.js +49 -25
  49. package/dist/temporal/travailleur.js.map +1 -1
  50. package/docs/INTERFACE.md +37 -12
  51. package/docs/architecture/circuit.md +21 -18
  52. package/docs/architecture/entree.md +10 -11
  53. package/docs/architecture/greffon.md +45 -27
  54. package/docs/architecture/installation.md +92 -59
  55. package/docs/architecture/machine.md +2 -2
  56. package/docs/architecture/tests.md +15 -6
  57. package/docs/lexique.md +2 -2
  58. package/hooks/hooks.json +10 -0
  59. package/hooks/register.tsx +59 -39
  60. package/package.json +3 -2
  61. package/scripts/activites.mjs +5 -4
  62. package/scripts/aiguillage.mjs +5 -2
  63. package/scripts/bd-garde.mjs +69 -0
  64. package/scripts/ci-de-main.mjs +259 -56
  65. package/scripts/circuit.mjs +274 -47
  66. package/scripts/circuits-du-serveur.mjs +3 -2
  67. package/scripts/circuits-tenus.d.mts +7 -0
  68. package/scripts/circuits-tenus.mjs +17 -0
  69. package/scripts/commandes-composees.mjs +1 -1
  70. package/scripts/copie-de-montee.mjs +354 -0
  71. package/scripts/copies-du-depot.d.mts +13 -0
  72. package/scripts/copies-du-depot.mjs +66 -0
  73. package/scripts/copies-finies.mjs +6 -40
  74. package/scripts/crochets.mjs +16 -2
  75. package/scripts/direct.mjs +2 -2
  76. package/scripts/droits.mjs +13 -6
  77. package/scripts/engendres.mjs +5 -3
  78. package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
  79. package/scripts/etapes.mjs +11 -3
  80. package/scripts/faits-du-circuit.mjs +12 -5
  81. package/scripts/file-des-tickets.d.mts +13 -2
  82. package/scripts/file-des-tickets.mjs +71 -21
  83. package/scripts/greffons.mjs +42 -27
  84. package/scripts/grillhouse-maj.mjs +105 -85
  85. package/scripts/init.mjs +1 -1
  86. package/scripts/integration/file.mjs +5 -2
  87. package/scripts/integration/integrer.mjs +14 -4
  88. package/scripts/jointure.d.ts +16 -0
  89. package/scripts/langages/c/commandes.mjs +18 -8
  90. package/scripts/langages/cargo/commandes.mjs +88 -35
  91. package/scripts/langages/cargo/index.mjs +6 -3
  92. package/scripts/langages/cargo/sccache.mjs +15 -12
  93. package/scripts/langages/cargo/tailles-des-tests.mjs +115 -6
  94. package/scripts/langages/python/commandes.mjs +19 -9
  95. package/scripts/langages/python/squelette.mjs +2 -2
  96. package/scripts/langages/typescript/code-mort.mjs +36 -3
  97. package/scripts/langages/typescript/configurations-de-vitest.mjs +118 -0
  98. package/scripts/langages/typescript/index.mjs +2 -0
  99. package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +370 -0
  100. package/scripts/langages/typescript/mise-a-jour.mjs +49 -12
  101. package/scripts/langages/typescript/parcours.mjs +5 -1
  102. package/scripts/langages/typescript/squelette.mjs +20 -17
  103. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -3
  104. package/scripts/langages/typescript/turbo-des-paquets.mjs +24 -37
  105. package/scripts/langages/typescript/vitest-config/base.mjs +1 -1
  106. package/scripts/langages/typescript/vitest-config/bornes.mjs +1 -1
  107. package/scripts/langages/typescript/vitest-config/cibles.mjs +2 -2
  108. package/scripts/langages/typescript/{vitest.nuit.config.mjs → vitest.nuit.config.cjs} +61 -50
  109. package/scripts/langages.d.mts +6 -0
  110. package/scripts/langages.mjs +6 -0
  111. package/scripts/lire.mjs +236 -0
  112. package/scripts/mesure/pression.mjs +5 -3
  113. package/scripts/migrations/cout-des-jetons-au-registre.mjs +136 -0
  114. package/scripts/migrations/lire-un-ticket.mjs +46 -0
  115. package/scripts/migrations.mjs +4 -0
  116. package/scripts/montee.mjs +588 -0
  117. package/scripts/nuit.sh +21 -12
  118. package/scripts/outil.mjs +5 -3
  119. package/scripts/paquet-npm.mjs +22 -0
  120. package/scripts/paquet.mjs +5 -5
  121. package/scripts/pre-compact.mjs +25 -0
  122. package/scripts/registre.d.mts +7 -1
  123. package/scripts/registre.mjs +114 -102
  124. package/scripts/reponses-du-circuit.d.mts +17 -2
  125. package/scripts/reponses-du-circuit.mjs +78 -20
  126. package/scripts/resultats.mjs +55 -17
  127. package/scripts/retirer-les-copies-finies.mjs +4 -7
  128. package/scripts/seances.mjs +28 -3
  129. package/scripts/services-du-noyau.mjs +7 -2
  130. package/scripts/session-start.sh +18 -11
  131. package/scripts/sortie.mjs +4 -7
  132. package/scripts/sous-commandes.mjs +2 -0
  133. package/scripts/suiveur.mjs +12 -4
  134. package/scripts/superviseur.mjs +135 -84
  135. package/scripts/tableau.mjs +651 -224
  136. package/scripts/tarifs.mjs +67 -0
  137. package/scripts/ticket-du-circuit.mjs +25 -4
  138. package/scripts/transitions.d.mts +6 -14
  139. package/scripts/transitions.mjs +126 -49
  140. package/scripts/verdict-de-la-nuit.mjs +2 -2
  141. package/scripts/verrou-de-fichier.d.mts +11 -0
  142. package/skills/direct/SKILL.md +21 -11
  143. package/skills/explorateur/SKILL.md +16 -6
  144. package/skills/grill/SKILL.md +9 -7
  145. package/skills/grill/references/paquets.md +4 -4
  146. package/skills/mesure/SKILL.md +4 -3
  147. package/skills/pitmaster/SKILL.md +56 -35
  148. package/skills/pitmaster/references/consigne-agent.md +1 -1
  149. package/skills/pitmaster/references/erreurs.md +4 -2
  150. package/skills/pitmaster/references/tour.md +11 -4
  151. package/skills/relecteur/SKILL.md +8 -1
  152. package/skills/testwriter/SKILL.md +1 -1
  153. package/types/index.d.ts +3 -1
  154. package/cadre/templates/projet/vitest.config.ts +0 -44
  155. package/scripts/base-des-workflows.mjs +0 -58
@@ -14,13 +14,16 @@
14
14
  // that is not a shell (sh, bash, dash, zsh). It holds as long as that process lives.
15
15
  // - <source> is the one of the SessionStart hook (`startup` without one). Free, or held by a
16
16
  // process that is gone: taken. Held by the session itself: kept, and nothing is said after a
17
- // compaction or a resume. After a /clear, the session that holds the lock receives « ## Reprise
18
- // de la supervision après un /clear » (load `grillhouse:pitmaster`, take up the note of
19
- // resumption, no whole round, put the owner's pending question again at the first turn), then
20
- // what a session that takes the lock receives. Held by another live session: the section « ## Un
21
- // autre superviseur tient ce dépôt » names its process and since when, and asks to say so to the
22
- // owner and to launch no circuit. A declared milestone ends with the context that declared it: it
23
- // is removed at every opening of the holder but after a compaction.
17
+ // resume. After a /clear, the session that holds the lock receives « ## Reprise de la
18
+ // supervision après un /clear » (load `grillhouse:pitmaster`, take up the note of resumption, no
19
+ // whole round, put the owner's pending question again at the first turn), and after a compaction
20
+ // « ## Reprise de la supervision après un compactage » (the same, with: finish the work in hand,
21
+ // hold the summary as more recent than the note on what came after it, put the pending question
22
+ // again if it still waits); then what a session that takes the lock receives. Held by another
23
+ // live session: the section « ## Un autre superviseur tient ce dépôt » names its process and
24
+ // since when, and asks to say so to the owner and to launch no circuit. A declared milestone ends
25
+ // with the context that declared it: it is removed at every opening of the holder. The hook
26
+ // plays no opening for the compaction of a subagent (scripts/session-start.sh).
24
27
  // - The session whose opening takes the lock (`ouvertureDuSuperviseur`) receives « ## Les questions
25
28
  // des circuits », then, when the repository has circuits (read from the Temporal server in one
26
29
  // call, scripts/circuits-du-serveur.mjs), « ## Les circuits du dépôt »: each circuit that runs;
@@ -42,12 +45,19 @@
42
45
  // and declares nothing. Exit 2 and the reason on the error stream, nothing written, on a file
43
46
  // that is absent or empty, a session that does not hold the lock, a session of a role or a copy.
44
47
  //
45
- // npx grillhouse superviseur --renouveler <dossier> <arretA> <messageA>
48
+ // npx grillhouse superviseur --renouveler <dossier> <arretA> <messageA> [sans-reponse]
46
49
  //
47
- // - Played by the greffon at each period: writes the message of resumption when the renewal is due
48
- // (`renouvellement`), nothing otherwise.
50
+ // - Played by the greffon at each period: writes the line `{"reprise": <message>}` when the session
51
+ // is to be compacted (`renouvellement`: the message of resumption at a milestone that is due,
52
+ // empty after 55 minutes of idleness), nothing otherwise. `sans-reponse` says that <arretA> is
53
+ // the end of a turn with no answer, which serves idleness alone.
49
54
  //
50
- // npx grillhouse superviseur --relever [<dossier>] [--compaction]
55
+ // npx grillhouse pre-compact
56
+ //
57
+ // - Played by the PreCompact hook (scripts/pre-compact.mjs): the instructions of the summary of a
58
+ // compaction (`consignesDuResume`).
59
+ //
60
+ // npx grillhouse superviseur --relever [<dossier>]
51
61
  //
52
62
  // - One reading of the circuits for the greffon (mods/grillhouse/hooks/register.tsx), which runs
53
63
  // it at each period and submits what it writes. It reads and writes nothing unless the session
@@ -55,10 +65,9 @@
55
65
  // reads. It writes the message (`texteDesQuestions`) when `relever` gives something, nothing
56
66
  // otherwise; exit 1 and the fault on the error stream when `grillhouse.rappel` of the project is
57
67
  // at fault, or when the reading of another project of the group fails, the message of the others
58
- // then written all the same. The message ends with the request to write the note and declare a
59
- // milestone after a compaction (`--compaction`), and once for each night
60
- // (`grillhouse.plageDeNuit`) at a reading where no question of a circuit waits for the
61
- // supervisor.
68
+ // then written all the same. The message ends, once for each night (`grillhouse.plageDeNuit`),
69
+ // with the request to write the note and declare a milestone, at a reading where no question of a
70
+ // circuit waits for the supervisor.
62
71
  // - `superviseur --lue <dossier> <lueA> <envoyeesAvant>` marks read the questions sent up to
63
72
  // `envoyeesAvant`; `superviseur --chez-le-responsable <dossier> <ticket>` marks a question
64
73
  // carried to the owner: silent until the circuit answers.
@@ -69,9 +78,10 @@
69
78
  // and the opening lists it; one answered leaves the file
70
79
  // `.claude/worktrees/questions-remontees.json`. A stop is kept there by its ticket, the run of
71
80
  // its workflow, the rank of its question in that run and its stop, with the times of the first
72
- // going up and of the last presentation. The alert of the CI of main (a red, or a CI not read,
73
- // scripts/ci-de-main.mjs) is given once per passage (`.claude/worktrees/ci-de-main-rendue.json`),
74
- // cleared at the next green. A circuit integrated gives nothing: it is read on the board.
81
+ // going up and of the last presentation. The alert of the CI of main (a red, a CI not read, or
82
+ // main no longer judged, scripts/ci-de-main.mjs) is given once per passage
83
+ // (`.claude/worktrees/ci-de-main-rendue.json`), cleared when the reading tells nothing. A circuit
84
+ // integrated gives nothing: it is read on the board.
75
85
  // - The reading covers the project and each other project of its group (`grillhouse.groupe`) that
76
86
  // no other live session of supervision holds, each under its name and its folder.
77
87
  import { spawnSync } from 'node:child_process';
@@ -107,6 +117,7 @@ import {
107
117
  lireLesExternes,
108
118
  lireLesTickets,
109
119
  lotEstSurMain,
120
+ reporteJusqua,
110
121
  } from './file-des-tickets.mjs';
111
122
 
112
123
  const VERROU_SUPERVISEUR = 'grillhouse-superviseur.lock';
@@ -115,10 +126,14 @@ const VERROU_SUPERVISEUR = 'grillhouse-superviseur.lock';
115
126
  const NOTE_DE_REPRISE = 'grillhouse-reprise.md';
116
127
  const JALON = 'grillhouse-jalon.json';
117
128
  const DEMANDE_DE_NUIT = 'grillhouse-demande-de-nuit.json';
118
- // The message the greffon submits once the /clear of a renewal is done; the note, the questions and
119
- // the circuits come with the opening.
129
+ // The message the greffon submits once the compaction of a milestone is installed; the note, the
130
+ // questions and the circuits come with the opening.
120
131
  const MESSAGE_DE_REPRISE =
121
- "Reprends la supervision : ta séance vient de se renouveler au jalon que tu as déclaré. L'ouverture te donne la note de reprise, les questions et les circuits : suis-la.";
132
+ "Reprends la supervision : ta séance vient d'être compactée au jalon que tu as déclaré. L'ouverture te donne la note de reprise, les questions et les circuits : suis-la.";
133
+ // How long a session without a turn stays before it is compacted: its prompt cache lasts one hour.
134
+ const INACTIVITE_MS = 55 * 60_000;
135
+ // The output of a hook of Claude Code stays under this many characters.
136
+ const PLAFOND_DU_CROCHET = 10_000;
122
137
  const COQUILLES = new Set(['sh', 'bash', 'dash', 'zsh']);
123
138
  // The name of the process of a session of the engine.
124
139
  const MOTEUR = 'claude';
@@ -181,15 +196,10 @@ function estAuDessus(pid) {
181
196
  return false;
182
197
  }
183
198
 
184
- // The time in ms of <texte>, a `defer_until` as Beads writes it: the local wall time of the
185
- // machine, followed by a « Z » it does not mean (`bd update --defer 17:30` gives `…T17:30:00Z`);
186
- // NaN without one.
187
- const heureMurale = texte => Date.parse(String(texte ?? '').replace(/Z$/, ''));
188
-
189
199
  /**
190
200
  * Of the tickets <tickets> (as `bd show --json` gives them), the ids of those whose question does
191
201
  * not wait for the supervisor at <maintenant> (ms): closed, or deferred to a later time
192
- * (`defer_until`, the answer `--reporter <heure>`), as a review's snooze hides a request until its
202
+ * (`reporteJusqua` of ./file-des-tickets.mjs), as a review's snooze hides a request until its
193
203
  * hour, then shows it again.
194
204
  * @param {{ id: string, status?: string, defer_until?: string }[]} tickets
195
205
  * @param {number} maintenant
@@ -198,7 +208,7 @@ const heureMurale = texte => Date.parse(String(texte ?? '').replace(/Z$/, ''));
198
208
  export function horsAttente(tickets, maintenant) {
199
209
  return new Set(
200
210
  tickets
201
- .filter(t => t.status === 'closed' || heureMurale(t.defer_until) > maintenant)
211
+ .filter(t => t.status === 'closed' || reporteJusqua(t, maintenant) !== null)
202
212
  .map(t => t.id)
203
213
  );
204
214
  }
@@ -236,7 +246,8 @@ const ou = c => {
236
246
  const etatsDe = racine => path.join(racine, '.claude', 'worktrees');
237
247
 
238
248
  // The alert of the CI of main of the project at <racine> (scripts/ci-de-main.mjs), read for the
239
- // supervisor: `{ cle, texte }` for a red or a CI not read, null for a green (the alert clears),
249
+ // supervisor: `{ cle, texte }` for a red, a CI not read or main no longer judged, null when there is
250
+ // nothing to tell (the alert clears),
240
251
  // undefined for a project with no CI to read. The lots entered since the last green are named by
241
252
  // git; nothing is kept but the reading, for five minutes.
242
253
  export function ciDeMainDe(racine, o = {}) {
@@ -245,7 +256,8 @@ export function ciDeMainDe(racine, o = {}) {
245
256
  }
246
257
 
247
258
  // The alert of the CI of main given by the waits of the repository at <racine>, its key: kept while
248
- // it stands, so that one is given once, cleared at the next green and given again if it comes back.
259
+ // it stands, so that one is given once, cleared when the reading tells nothing and given again if it
260
+ // comes back.
249
261
  const ciDeMainRendue = racine => path.join(etatsDe(racine), 'ci-de-main-rendue.json');
250
262
  function lireLaCiDeMainRendue(racine) {
251
263
  try {
@@ -267,8 +279,8 @@ function ecrireLaCiDeMainRendue(racine, cle) {
267
279
  }
268
280
  }
269
281
 
270
- // The alert of the CI of main <alerte> (`{ cle, texte }`, null at a green) as a question, when it is
271
- // not the one already given; the file keeps the key that stands.
282
+ // The alert of the CI of main <alerte> (`{ cle, texte }`, null when the reading tells nothing) as a
283
+ // question, when it is not the one already given; the file keeps the key that stands.
272
284
  function releverLaCiDeMain(racine, alerte, toutes) {
273
285
  const avant = lireLaCiDeMainRendue(racine);
274
286
  const cle = alerte?.cle ?? null;
@@ -379,8 +391,8 @@ export function marquerChezLeResponsable(racine, { cle, depuisA }) {
379
391
  * given is presented now, and one that goes up has its `depuis` set now. The file is written whole
380
392
  * with the stops that still stand, their circuit waiting for the supervisor: a question answered
381
393
  * so leaves it, and the next stop of its circuit is new. The alert of the CI of main <ciDeMain>
382
- * (`{ cle, texte }`; null at a green, which clears it; undefined when it is not read, which keeps
383
- * what was given) is given once per passage. A circuit integrated gives nothing. The result is the
394
+ * (`{ cle, texte }`; null when the reading tells nothing, which clears it; undefined when it is not
395
+ * read, which keeps what was given) is given once per passage. A circuit integrated gives nothing. The result is the
384
396
  * questions given, each marked `representee` when it comes back, then the alert of the CI of main.
385
397
  * @param {string} racine
386
398
  * @param {import('./circuits-du-serveur.mjs').CircuitDuServeur[]} circuits
@@ -805,30 +817,70 @@ export async function ajouterLaQuestion(dossier, fichier, { env = process.env }
805
817
  }
806
818
 
807
819
  /**
808
- * The message of resumption when the renewal of the session of supervision of <dossier> is due,
809
- * empty otherwise (`superviseur --renouveler`): the session holds the lock, a milestone it declared
810
- * stands, and a quiet Stop (<arretA>, ms, 0 without one) is later than it. A message of the owner
811
- * (<messageA>, ms, 0 without one) later than the declaration cancels the milestone. The reading
812
- * keeps a milestone that is due: the opening that follows the /clear removes it.
820
+ * Whether the session of supervision of <dossier> is to be compacted (`superviseur --renouveler`),
821
+ * the session holding the lock: at a milestone it declared, once a quiet Stop (<arretA>, ms, 0
822
+ * without one) is later than it, with the message of resumption; else once that Stop is 55 minutes
823
+ * old, with an empty message, a note or a milestone or not. With <sansReponse>, <arretA> is the end
824
+ * of a turn that gave no answer, not a Stop: it serves idleness alone and plays no milestone. A message of the owner (<messageA>, ms,
825
+ * 0 without one) later than the declaration cancels the milestone. The reading keeps a milestone
826
+ * that is due: the opening that follows the compaction removes it.
813
827
  * @param {string} dossier
814
- * @param {{ arretA: number, messageA: number, env?: Record<string, string | undefined> }} options
815
- * @returns {Promise<string>}
828
+ * @param {{ arretA: number, messageA: number, sansReponse?: boolean,
829
+ * env?: Record<string, string | undefined> }} options
830
+ * @returns {Promise<{ reprise: string } | null>} null when nothing is to be done
816
831
  */
817
- export async function renouvellement(dossier, { arretA, messageA, env = process.env }) {
832
+ export async function renouvellement(
833
+ dossier,
834
+ { arretA, messageA, sansReponse = false, env = process.env },
835
+ ) {
818
836
  const session = laSeanceQuiTient(dossier, env);
819
837
  if (session.refus) {
820
- return '';
838
+ return null;
821
839
  }
822
840
  const f = path.join(session.commun, JALON);
823
841
  const jalon = lireJson(f);
824
- if (!jalon || jalon.tenant !== session.tenant) {
842
+ if (jalon && jalon.tenant === session.tenant) {
843
+ if (messageA > jalon.declareA) {
844
+ rmSync(f, { force: true });
845
+ } else if (!sansReponse && arretA > jalon.declareA) {
846
+ return { reprise: MESSAGE_DE_REPRISE };
847
+ }
848
+ }
849
+ return arretA > 0 && Date.now() - arretA >= INACTIVITE_MS ? { reprise: '' } : null;
850
+ }
851
+
852
+ /**
853
+ * The instructions of the summary of a compaction of the session of supervision of <dossier>
854
+ * (`grillhouse pre-compact`): the file of the note of resumption, the request to keep what it says
855
+ * and what the conversation holds of more recent, then its text, cut so that the whole stays under
856
+ * the cap of a hook's output. Empty without a note, for a session that does not hold the lock, a
857
+ * session of a role or a copy.
858
+ * @param {string} dossier
859
+ * @param {{ env?: Record<string, string | undefined> }} [options]
860
+ * @returns {string}
861
+ */
862
+ export function consignesDuResume(dossier, { env = process.env } = {}) {
863
+ const session = laSeanceQuiTient(dossier, env);
864
+ if (session.refus) {
825
865
  return '';
826
866
  }
827
- if (messageA > jalon.declareA) {
828
- rmSync(f, { force: true });
867
+ const note = path.join(session.commun, NOTE_DE_REPRISE);
868
+ const texte = lireTexte(note).trimEnd();
869
+ if (!texte) {
829
870
  return '';
830
871
  }
831
- return arretA > jalon.declareA ? MESSAGE_DE_REPRISE : '';
872
+ const tete = [
873
+ `La note de reprise de la supervision est au fichier \`${note}\`.`,
874
+ "Garde dans le résumé ce qu'elle dit et ce que la conversation porte de plus récent qu'elle. Son texte :",
875
+ '',
876
+ '',
877
+ ].join('\n');
878
+ const coupe = '\n[Note coupée : lis son fichier en entier.]';
879
+ // One character is left to the newline the command ends with.
880
+ const place = PLAFOND_DU_CROCHET - 2 - tete.length;
881
+ return texte.length <= place
882
+ ? `${tete}${texte}`
883
+ : `${tete}${texte.slice(0, Math.max(0, place - coupe.length))}${coupe}`;
832
884
  }
833
885
 
834
886
  // The section the opening gives of the note of resumption <note>; empty when none is written.
@@ -844,18 +896,27 @@ function laNote(note) {
844
896
  : '';
845
897
  }
846
898
 
847
- // What the opening that follows a /clear asks, before the circuits and the note.
848
- const APRES_CLEAR = [
849
- '## Reprise de la supervision après un /clear',
850
- 'Charge la compétence `grillhouse:pitmaster`, puis reprends la note de reprise donnée plus bas ; ne fais aucun tour complet.',
851
- 'À ton premier tour, quel que soit le message qui l’ouvre, repose au responsable la question que la note tient en attente.',
852
- ].join('\n');
899
+ // What the opening that follows a /clear or a compaction asks, before the circuits and the note, by
900
+ // the source of the SessionStart hook.
901
+ const REPRISES = {
902
+ clear: [
903
+ '## Reprise de la supervision après un /clear',
904
+ 'Charge la compétence `grillhouse:pitmaster`, puis reprends la note de reprise donnée plus bas ; ne fais aucun tour complet.',
905
+ 'À ton premier tour, quel que soit le message qui l’ouvre, repose au responsable la question que la note tient en attente.',
906
+ ].join('\n'),
907
+ compact: [
908
+ '## Reprise de la supervision après un compactage',
909
+ 'Charge la compétence `grillhouse:pitmaster`, puis reprends la note de reprise donnée plus bas ; ne fais aucun tour complet, et finis le travail en cours.',
910
+ 'Tiens le résumé du compactage pour plus récent que la note sur ce qui lui est postérieur.',
911
+ 'Repose au responsable la question que la note tient en attente, si elle attend encore.',
912
+ ].join('\n'),
913
+ };
853
914
 
854
915
  /**
855
916
  * The check of the supervisor at the opening of a session in <dossier> (greffon.md, §5.2): what it
856
917
  * says (empty when nothing), the lock taken when it is free. <source> is the one of the
857
- * SessionStart hook. The session that takes the lock, and the holder after a /clear, receive the
858
- * circuits and the note of resumption; every opening of the holder but after a compaction removes
918
+ * SessionStart hook. The session that takes the lock, and the holder after a /clear or a
919
+ * compaction, receive the circuits and the note of resumption; every opening of the holder removes
859
920
  * the declared milestone.
860
921
  * @param {string} dossier the directory the session opens in
861
922
  * @param {{ source?: string, env?: Record<string, string | undefined>, circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} [options]
@@ -875,14 +936,13 @@ export async function ouvertureDuSuperviseur(
875
936
  if (!tenait && !prendreVerrou(verrou, { attendre: false, pid: moi })) {
876
937
  return unAutreSuperviseur(verrou, moi);
877
938
  }
878
- if (source !== 'compact') {
879
- rmSync(path.join(commun, JALON), { force: true });
880
- }
881
- if (tenait && source !== 'clear') {
939
+ rmSync(path.join(commun, JALON), { force: true });
940
+ const reprise = Object.hasOwn(REPRISES, source) ? REPRISES[source] : '';
941
+ if (tenait && !reprise) {
882
942
  return '';
883
943
  }
884
944
  return [
885
- source === 'clear' ? APRES_CLEAR : '',
945
+ reprise,
886
946
  await circuitsALOuverture(path.dirname(commun), { circuitsDe }),
887
947
  laNote(path.join(commun, NOTE_DE_REPRISE)),
888
948
  ]
@@ -947,18 +1007,17 @@ const demandeDuJalon = raison =>
947
1007
  * interval and state. A fault in the reading of one of these projects costs the others nothing: it
948
1008
  * is thrown once all are read, each project at fault named with its reason, the message of the
949
1009
  * others in the `texte` of the error. Last comes the request to write the note of resumption and
950
- * declare a milestone: after a compaction (<compaction>), and once for each night of the project
951
- * (`grillhouse.plageDeNuit`) at a reading where every project read says that no question waits for
952
- * the supervisor.
1010
+ * declare a milestone, once for each night of the project (`grillhouse.plageDeNuit`), at a reading
1011
+ * where every project read says that no question waits for the supervisor.
953
1012
  * @param {string} racine
954
- * @param {{ env?: Record<string, string | undefined>, compaction?: boolean, circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} [options]
1013
+ * @param {{ env?: Record<string, string | undefined>, circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} [options]
955
1014
  * @returns {Promise<string>}
956
1015
  * @throws {Error} `grillhouse.rappel` of the project of the session is at fault, named with its
957
1016
  * value; or the reading of another project of the group failed (its `texte`: the others' message)
958
1017
  */
959
1018
  export async function releverPourLeGreffon(
960
1019
  racine,
961
- { env = process.env, circuitsDe = circuitsDuServeur, compaction = false } = {}
1020
+ { env = process.env, circuitsDe = circuitsDuServeur } = {}
962
1021
  ) {
963
1022
  const depot = depotDuSuperviseur(racine, env);
964
1023
  if (depot.refus) {
@@ -980,13 +1039,7 @@ export async function releverPourLeGreffon(
980
1039
  const demandeNocturne = path.join(commun, DEMANDE_DE_NUIT);
981
1040
  const nuit = nuitEnCours(Date.now(), plageDeNuit(racine));
982
1041
  const aDemander = nuit !== null && lireJson(demandeNocturne)?.nuit !== nuit;
983
- const apresCompaction = compaction ? demandeDuJalon('une compaction a eu lieu') : '';
984
- const parts = [];
985
- try {
986
- parts.push(await leReleveDe(racine, circuitsDe, { nocturne: aDemander }));
987
- } catch (e) {
988
- throw Object.assign(e, { texte: apresCompaction });
989
- }
1042
+ const parts = [await leReleveDe(racine, circuitsDe, { nocturne: aDemander })];
990
1043
  const fautes = [];
991
1044
  for (const p of voisinsSansSuperviseur(racine)) {
992
1045
  try {
@@ -995,10 +1048,10 @@ export async function releverPourLeGreffon(
995
1048
  fautes.push(`${path.basename(p.chemin)} : ${e.message}`);
996
1049
  }
997
1050
  }
998
- let demande = apresCompaction;
1051
+ let demande = '';
999
1052
  if (aDemander && !fautes.length && parts.every(p => p.attend === false)) {
1000
1053
  ecrireEntier(demandeNocturne, `${JSON.stringify({ nuit })}\n`);
1001
- demande ||= demandeDuJalon('la nuit a commencé');
1054
+ demande = demandeDuJalon('la nuit a commencé');
1002
1055
  }
1003
1056
  const texte = [...parts.map(p => p.texte), demande].filter(Boolean).join('\n\n');
1004
1057
  if (fautes.length) {
@@ -1092,22 +1145,20 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
1092
1145
  }
1093
1146
  process.exitCode = code;
1094
1147
  } else if (process.argv[2] === '--renouveler') {
1095
- // superviseur --renouveler <dossier> <arretA> <messageA> (the greffon, at each period).
1096
- const [, , , dossier, arretA, messageA] = process.argv;
1097
- const texte = await renouvellement(dossier ?? process.cwd(), {
1148
+ // superviseur --renouveler <dossier> <arretA> <messageA> [sans-reponse] (the greffon, at each
1149
+ // period).
1150
+ const [, , , dossier, arretA, messageA, fin] = process.argv;
1151
+ const rendu = await renouvellement(dossier ?? process.cwd(), {
1098
1152
  arretA: Number(arretA),
1099
1153
  messageA: Number(messageA),
1154
+ sansReponse: fin === 'sans-reponse',
1100
1155
  });
1101
- if (texte) {
1102
- process.stdout.write(`${texte}\n`);
1156
+ if (rendu) {
1157
+ process.stdout.write(`${JSON.stringify(rendu)}\n`);
1103
1158
  }
1104
1159
  } else if (process.argv[2] === '--relever') {
1105
- const args = process.argv.slice(3);
1106
- const dossier = args.find(a => a !== '--compaction') ?? process.cwd();
1107
1160
  try {
1108
- const texte = await releverPourLeGreffon(racineDe(dossier), {
1109
- compaction: args.includes('--compaction'),
1110
- });
1161
+ const texte = await releverPourLeGreffon(racineDe(process.argv[3] ?? process.cwd()));
1111
1162
  if (texte) {
1112
1163
  process.stdout.write(`${texte}\n`);
1113
1164
  }