palabre 0.6.4 → 0.8.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.
@@ -1,6 +1,7 @@
1
1
  import { createAgent } from "./adapters/index.js";
2
2
  import { AdapterError } from "./errors.js";
3
3
  import { createTranslator } from "./i18n.js";
4
+ export const MAX_ASK_AGENTS = 4;
4
5
  /**
5
6
  * Point d'entrée de l'orchestration.
6
7
  * Lance le ping-pong entre `agentA` et `agentB` pendant `options.turns` tours,
@@ -32,6 +33,19 @@ export async function runDebate(config, options, renderer, messages = createTran
32
33
  const transcript = [];
33
34
  let stopReason;
34
35
  for (let index = 0; index < options.turns; index += 1) {
36
+ const cancellation = cancellationFailureIfAborted(options, messages, {
37
+ phase: "debate",
38
+ turn: index + 1
39
+ });
40
+ if (cancellation) {
41
+ renderer?.error(cancellation);
42
+ return {
43
+ options,
44
+ messages: transcript,
45
+ stopReason,
46
+ failure: cancellation
47
+ };
48
+ }
35
49
  const current = agents[index % agents.length];
36
50
  const peer = agents[(index + 1) % agents.length];
37
51
  const turn = index + 1;
@@ -49,7 +63,8 @@ export async function runDebate(config, options, renderer, messages = createTran
49
63
  language: options.language,
50
64
  session: options.session,
51
65
  files: options.files,
52
- transcript
66
+ transcript,
67
+ signal: options.signal
53
68
  });
54
69
  }
55
70
  catch (error) {
@@ -88,12 +103,26 @@ export async function runDebate(config, options, renderer, messages = createTran
88
103
  let failure;
89
104
  if (options.summaryEnabled) {
90
105
  try {
106
+ const cancellation = cancellationFailureIfAborted(options, messages, {
107
+ phase: "summary",
108
+ agent: resolveSummaryAgentName(options),
109
+ turn: transcript.length + 1
110
+ });
111
+ if (cancellation) {
112
+ renderer?.error(cancellation);
113
+ return {
114
+ options,
115
+ messages: transcript,
116
+ stopReason,
117
+ failure: cancellation
118
+ };
119
+ }
91
120
  summary = await generateSummary(config, options, transcript, renderer, messages);
92
121
  }
93
122
  catch (error) {
94
123
  failure = toDebateFailure(error, {
95
124
  phase: "summary",
96
- agent: options.summaryAgent ?? options.agentB,
125
+ agent: resolveSummaryAgentName(options),
97
126
  turn: transcript.length + 1
98
127
  });
99
128
  renderer?.error(failure);
@@ -107,6 +136,141 @@ export async function runDebate(config, options, renderer, messages = createTran
107
136
  failure
108
137
  };
109
138
  }
139
+ /**
140
+ * Lance le mode ask : plusieurs agents répondent indépendamment au même sujet,
141
+ * puis un agent de synthèse résume fidèlement chaque réponse et les compare.
142
+ */
143
+ export async function runAsk(config, options, renderer, messages = createTranslator("fr")) {
144
+ const askAgentNames = resolveAskAgentNames(options);
145
+ if (askAgentNames.length === 0) {
146
+ throw new Error(messages.common.noAgentDefined("ask agent"));
147
+ }
148
+ if (askAgentNames.length > MAX_ASK_AGENTS) {
149
+ throw new Error(messages.common.tooManyAskAgents(MAX_ASK_AGENTS));
150
+ }
151
+ const agentEntries = askAgentNames.map((name) => {
152
+ const agentConfig = withRuntimeOverrides(config.agents[name], modelForAgent(options, name), options.pullModels);
153
+ if (!agentConfig) {
154
+ throw new Error(messages.common.unknownAgent(name));
155
+ }
156
+ return [name, agentConfig];
157
+ });
158
+ warnIfOllamaHasNoContext(options, agentEntries.map(([name, agentConfig]) => [name, agentConfig]), renderer, messages);
159
+ renderer?.start(options, agentEntries.map(([name, agentConfig]) => ({
160
+ name,
161
+ role: agentConfig.role,
162
+ type: agentConfig.type
163
+ })));
164
+ const agents = agentEntries.map(([name, agentConfig]) => createAgent(name, agentConfig));
165
+ const transcript = [];
166
+ for (let index = 0; index < agents.length; index += 1) {
167
+ const current = agents[index];
168
+ const response = index + 1;
169
+ const cancellation = cancellationFailureIfAborted(options, messages, {
170
+ phase: "ask",
171
+ agent: current.name,
172
+ role: current.role,
173
+ turn: response
174
+ });
175
+ if (cancellation) {
176
+ renderer?.error(cancellation);
177
+ return {
178
+ options,
179
+ messages: transcript,
180
+ failure: cancellation
181
+ };
182
+ }
183
+ if (renderer?.askResponseStart) {
184
+ renderer.askResponseStart(response, agents.length, current.name, current.role);
185
+ }
186
+ else {
187
+ renderer?.turnStart(response, agents.length, current.name, current.role);
188
+ }
189
+ renderer?.thinkingStart(current.name, current.role);
190
+ let agentResponse;
191
+ try {
192
+ agentResponse = await current.generate({
193
+ topic: options.topic,
194
+ turn: response,
195
+ totalTurns: agents.length,
196
+ selfName: current.name,
197
+ peerName: "independent-agents",
198
+ selfRole: current.role,
199
+ mode: "ask",
200
+ language: options.language,
201
+ session: options.session,
202
+ files: options.files,
203
+ transcript: [],
204
+ signal: options.signal
205
+ });
206
+ }
207
+ catch (error) {
208
+ const failure = toDebateFailure(error, {
209
+ phase: "ask",
210
+ agent: current.name,
211
+ role: current.role,
212
+ turn: response
213
+ });
214
+ renderer?.error(failure);
215
+ return {
216
+ options,
217
+ messages: transcript,
218
+ failure
219
+ };
220
+ }
221
+ finally {
222
+ renderer?.thinkingEnd();
223
+ }
224
+ const message = {
225
+ agent: current.name,
226
+ role: current.role,
227
+ content: agentResponse.content,
228
+ createdAt: new Date().toISOString()
229
+ };
230
+ transcript.push(message);
231
+ if (renderer?.askResponseMessage) {
232
+ renderer.askResponseMessage(message.content);
233
+ }
234
+ else {
235
+ renderer?.message(message.content);
236
+ }
237
+ }
238
+ let summary;
239
+ let failure;
240
+ if (options.summaryEnabled) {
241
+ try {
242
+ const summaryAgentName = resolveSummaryAgentName(options);
243
+ const cancellation = cancellationFailureIfAborted(options, messages, {
244
+ phase: "summary",
245
+ agent: summaryAgentName,
246
+ turn: transcript.length + 1
247
+ });
248
+ if (cancellation) {
249
+ renderer?.error(cancellation);
250
+ return {
251
+ options,
252
+ messages: transcript,
253
+ failure: cancellation
254
+ };
255
+ }
256
+ summary = await generateSummary(config, options, transcript, renderer, messages);
257
+ }
258
+ catch (error) {
259
+ failure = toDebateFailure(error, {
260
+ phase: "summary",
261
+ agent: resolveSummaryAgentName(options),
262
+ turn: transcript.length + 1
263
+ });
264
+ renderer?.error(failure);
265
+ }
266
+ }
267
+ return {
268
+ options,
269
+ messages: transcript,
270
+ summary,
271
+ failure
272
+ };
273
+ }
110
274
  /**
111
275
  * Heuristique d'arrêt sur accord explicite.
112
276
  * Ne s'active qu'après un tour complet (nombre pair de messages) pour éviter les faux positifs.
@@ -161,7 +325,7 @@ function warnIfOllamaHasNoContext(options, agents, renderer, messages = createTr
161
325
  * @throws {Error} si l'agent de synthèse est absent de `config.agents`.
162
326
  */
163
327
  async function generateSummary(config, options, transcript, renderer, messages = createTranslator("fr")) {
164
- const summaryAgentName = options.summaryAgent ?? options.agentB;
328
+ const summaryAgentName = resolveSummaryAgentName(options);
165
329
  const summaryModel = options.summaryModel ?? modelForAgent(options, summaryAgentName);
166
330
  const summaryConfig = withRuntimeOverrides(config.agents[summaryAgentName], summaryModel, options.pullModels);
167
331
  if (!summaryConfig) {
@@ -173,15 +337,16 @@ async function generateSummary(config, options, transcript, renderer, messages =
173
337
  const response = await summaryAgent.generate({
174
338
  topic: options.topic,
175
339
  turn: transcript.length + 1,
176
- totalTurns: options.turns,
340
+ totalTurns: options.mode === "ask" ? transcript.length : options.turns,
177
341
  selfName: summaryAgent.name,
178
- peerName: "transcript",
342
+ peerName: options.mode === "ask" ? "ask-responses" : "transcript",
179
343
  selfRole: summaryAgent.role,
180
344
  mode: "summary",
181
345
  language: options.language,
182
346
  session: options.session,
183
347
  files: options.files,
184
- transcript
348
+ transcript,
349
+ signal: options.signal
185
350
  }).finally(() => renderer?.thinkingEnd());
186
351
  const summary = {
187
352
  agent: summaryAgent.name,
@@ -192,6 +357,34 @@ async function generateSummary(config, options, transcript, renderer, messages =
192
357
  renderer?.message(summary.content);
193
358
  return summary;
194
359
  }
360
+ function cancellationFailureIfAborted(options, messages, context) {
361
+ if (!options.signal?.aborted) {
362
+ return undefined;
363
+ }
364
+ return {
365
+ phase: context.phase,
366
+ agent: context.agent,
367
+ role: context.role,
368
+ turn: context.turn,
369
+ kind: "cancelled",
370
+ message: messages.orchestrator.cancelled
371
+ };
372
+ }
373
+ function resolveAskAgentNames(options) {
374
+ const agents = options.askAgents && options.askAgents.length > 0
375
+ ? options.askAgents
376
+ : [options.agentA, options.agentB];
377
+ return agents.filter((agent, index) => Boolean(agent) && agents.indexOf(agent) === index);
378
+ }
379
+ function resolveSummaryAgentName(options) {
380
+ if (options.summaryAgent) {
381
+ return options.summaryAgent;
382
+ }
383
+ if (options.mode === "ask" && options.askAgents && options.askAgents.length > 0) {
384
+ return options.askAgents[options.askAgents.length - 1] ?? options.agentB;
385
+ }
386
+ return options.agentB;
387
+ }
195
388
  function toDebateFailure(error, context) {
196
389
  if (error instanceof AdapterError) {
197
390
  return {
package/dist/output.js CHANGED
@@ -7,7 +7,8 @@ import { createTranslator } from "./i18n.js";
7
7
  */
8
8
  export async function writeDebateMarkdown(outputDir, options, debateMessages, summary, stopReason, messages = createTranslator("fr"), failure) {
9
9
  const safeDate = new Date().toISOString().replace(/[:.]/g, "-");
10
- const fileName = `palabre-${slugifyTopic(options.topic)}-${safeDate}.debate.md`;
10
+ const extension = options.mode === "ask" ? "ask" : "debate";
11
+ const fileName = `palabre-${slugifyTopic(options.topic)}-${safeDate}.${extension}.md`;
11
12
  const filePath = path.resolve(outputDir, fileName);
12
13
  await mkdir(path.dirname(filePath), { recursive: true });
13
14
  await writeFile(filePath, renderDebateMarkdown(options, debateMessages, summary, stopReason, messages, failure), "utf8");
@@ -30,7 +31,7 @@ function slugifyTopic(topic) {
30
31
  */
31
32
  export function renderDebateMarkdown(options, debateMessages, summary, stopReason, messages = createTranslator("fr"), failure) {
32
33
  const lines = [
33
- messages.output.title,
34
+ options.mode === "ask" ? messages.output.askTitle : messages.output.title,
34
35
  "",
35
36
  ...renderSessionHeader(options, debateMessages, stopReason, messages),
36
37
  "",
@@ -38,7 +39,7 @@ export function renderDebateMarkdown(options, debateMessages, summary, stopReaso
38
39
  "",
39
40
  ...renderFileList(options.files, messages),
40
41
  "",
41
- messages.output.exchangesTitle,
42
+ options.mode === "ask" ? messages.output.askResponsesTitle : messages.output.exchangesTitle,
42
43
  ""
43
44
  ];
44
45
  for (const message of debateMessages) {
@@ -90,12 +91,19 @@ function normalizeMarkdownForWindowsPreview(content) {
90
91
  function renderSessionHeader(options, debateMessages, stopReason, messages) {
91
92
  const rows = [
92
93
  [messages.output.fields.subject, options.topic],
93
- [messages.output.fields.agents, `${options.agentA} <-> ${options.agentB}`],
94
+ [messages.output.fields.mode, options.mode],
95
+ [messages.output.fields.agents, formatAgentsForHeader(options)],
94
96
  [messages.output.fields.autoPullOllama, options.pullModels ? messages.output.yes : messages.output.no],
95
- [messages.output.fields.summary, options.summaryEnabled ? options.summaryAgent ?? options.agentB : messages.output.disabled],
96
- [messages.output.fields.requestedTurns, String(options.turns)],
97
- [messages.output.fields.playedTurns, String(debateMessages.length)],
98
- [messages.output.fields.earlyStop, stopReason ?? messages.output.no],
97
+ [messages.output.fields.summary, options.summaryEnabled ? formatSummaryAgent(options) : messages.output.disabled],
98
+ [
99
+ options.mode === "ask" ? messages.output.fields.requestedResponses : messages.output.fields.requestedTurns,
100
+ String(options.mode === "ask" ? options.askAgents?.length ?? debateMessages.length : options.turns)
101
+ ],
102
+ [
103
+ options.mode === "ask" ? messages.output.fields.receivedResponses : messages.output.fields.playedTurns,
104
+ String(debateMessages.length)
105
+ ],
106
+ [messages.output.fields.earlyStop, options.mode === "debate" ? stopReason ?? messages.output.no : messages.output.no],
99
107
  [messages.output.fields.localDate, options.session.localDate],
100
108
  [messages.output.fields.timeZone, options.session.timeZone],
101
109
  [messages.output.fields.cwd, options.session.cwd],
@@ -116,3 +124,18 @@ function renderFileList(files, messages) {
116
124
  }
117
125
  return files.map((file) => `- \`${file.path}\` (${file.sizeBytes} ${messages.output.fileSizeUnit})`);
118
126
  }
127
+ function formatSummaryAgent(options) {
128
+ if (options.summaryAgent) {
129
+ return options.summaryAgent;
130
+ }
131
+ if (options.mode === "ask" && options.askAgents && options.askAgents.length > 0) {
132
+ return options.askAgents[options.askAgents.length - 1] ?? options.agentB;
133
+ }
134
+ return options.agentB;
135
+ }
136
+ function formatAgentsForHeader(options) {
137
+ if (options.mode === "ask") {
138
+ return (options.askAgents && options.askAgents.length > 0 ? options.askAgents : [options.agentA, options.agentB]).join(", ");
139
+ }
140
+ return `${options.agentA} <-> ${options.agentB}`;
141
+ }
package/dist/presets.js CHANGED
@@ -16,6 +16,14 @@ const presets = {
16
16
  agentA: "opencode",
17
17
  agentB: "codex"
18
18
  },
19
+ "codex-vibe": {
20
+ agentA: "codex",
21
+ agentB: "vibe"
22
+ },
23
+ "vibe-codex": {
24
+ agentA: "vibe",
25
+ agentB: "codex"
26
+ },
19
27
  "codex-antigravity": {
20
28
  agentA: "codex",
21
29
  agentB: "antigravity"
@@ -32,6 +40,14 @@ const presets = {
32
40
  agentA: "opencode",
33
41
  agentB: "claude"
34
42
  },
43
+ "claude-vibe": {
44
+ agentA: "claude",
45
+ agentB: "vibe"
46
+ },
47
+ "vibe-claude": {
48
+ agentA: "vibe",
49
+ agentB: "claude"
50
+ },
35
51
  "claude-antigravity": {
36
52
  agentA: "claude",
37
53
  agentB: "antigravity"
@@ -48,6 +64,14 @@ const presets = {
48
64
  agentA: "opencode",
49
65
  agentB: "gemini"
50
66
  },
67
+ "gemini-vibe": {
68
+ agentA: "gemini",
69
+ agentB: "vibe"
70
+ },
71
+ "vibe-gemini": {
72
+ agentA: "vibe",
73
+ agentB: "gemini"
74
+ },
51
75
  "gemini-antigravity": {
52
76
  agentA: "gemini",
53
77
  agentB: "antigravity"
@@ -64,6 +88,22 @@ const presets = {
64
88
  agentA: "antigravity",
65
89
  agentB: "opencode"
66
90
  },
91
+ "opencode-vibe": {
92
+ agentA: "opencode",
93
+ agentB: "vibe"
94
+ },
95
+ "vibe-opencode": {
96
+ agentA: "vibe",
97
+ agentB: "opencode"
98
+ },
99
+ "antigravity-vibe": {
100
+ agentA: "antigravity",
101
+ agentB: "vibe"
102
+ },
103
+ "vibe-antigravity": {
104
+ agentA: "vibe",
105
+ agentB: "antigravity"
106
+ },
67
107
  "opencode-ollama": {
68
108
  agentA: "opencode",
69
109
  agentB: "ollama-local"
@@ -72,6 +112,14 @@ const presets = {
72
112
  agentA: "ollama-local",
73
113
  agentB: "opencode"
74
114
  },
115
+ "vibe-ollama": {
116
+ agentA: "vibe",
117
+ agentB: "ollama-local"
118
+ },
119
+ "ollama-vibe": {
120
+ agentA: "ollama-local",
121
+ agentB: "vibe"
122
+ },
75
123
  "codex-ollama": {
76
124
  agentA: "codex",
77
125
  agentB: "ollama-local"
package/dist/prompt.js CHANGED
@@ -1,13 +1,16 @@
1
1
  import { createTranslator } from "./i18n.js";
2
2
  /**
3
3
  * Formate le prompt complet transmis à l'adapter.
4
- * Dispatche vers le format de synthèse si `input.mode === "summary"`, sinon construit le prompt de débat standard.
4
+ * Dispatche vers le format ask ou synthèse si demandé, sinon construit le prompt de débat standard.
5
5
  */
6
6
  export function formatAgentPrompt(input) {
7
7
  const messages = createTranslator(input.language ?? "fr").prompt;
8
8
  if (input.mode === "summary") {
9
9
  return formatSummaryPrompt(input, messages);
10
10
  }
11
+ if (input.mode === "ask") {
12
+ return formatAskPrompt(input, messages);
13
+ }
11
14
  const transcript = formatTranscript(input.transcript);
12
15
  return [
13
16
  messages.subject(input.topic),
@@ -41,13 +44,43 @@ export function formatAgentPrompt(input) {
41
44
  .filter(Boolean)
42
45
  .join("\n");
43
46
  }
47
+ /** Formate le prompt d'une réponse indépendante en mode ask. */
48
+ function formatAskPrompt(input, messages) {
49
+ return [
50
+ messages.subject(input.topic),
51
+ "",
52
+ messages.askIntro(input.selfName),
53
+ messages.role(input.selfName, input.selfRole),
54
+ messages.roleInstruction(input.selfRole),
55
+ "",
56
+ messages.sessionTitle,
57
+ messages.sessionSource,
58
+ messages.localDate(input.session.localDate),
59
+ messages.timeZone(input.session.timeZone),
60
+ messages.cwd(input.session.cwd),
61
+ messages.sessionStartedAt(input.session.startedAt),
62
+ "",
63
+ messages.responseLanguageInstruction,
64
+ "",
65
+ messages.objectiveTitle,
66
+ ...messages.askObjectives,
67
+ "",
68
+ input.files.length > 0 ? messages.fileContextTitle : "",
69
+ formatFileContext(input.files),
70
+ input.files.length > 0 ? "" : "",
71
+ messages.answerTitle
72
+ ]
73
+ .filter(Boolean)
74
+ .join("\n");
75
+ }
44
76
  /** Formate le prompt de synthèse finale. Impose un format structuré : Consensus / Désaccords / Actions / Conclusion. */
45
77
  function formatSummaryPrompt(input, messages) {
46
78
  const transcript = formatTranscript(input.transcript);
79
+ const isAskSummary = input.peerName === "ask-responses";
47
80
  return [
48
81
  messages.subject(input.topic),
49
82
  "",
50
- messages.summaryIntro(input.selfName),
83
+ isAskSummary ? messages.askSummaryIntro(input.selfName) : messages.summaryIntro(input.selfName),
51
84
  messages.role(input.selfName, input.selfRole),
52
85
  messages.roleInstruction("summarizer"),
53
86
  "",
@@ -61,29 +94,47 @@ function formatSummaryPrompt(input, messages) {
61
94
  messages.responseLanguageInstruction,
62
95
  "",
63
96
  messages.objectiveTitle,
64
- ...messages.summaryObjectives,
97
+ ...(isAskSummary ? messages.askSummaryObjectives : messages.summaryObjectives),
65
98
  "",
66
99
  input.files.length > 0 ? messages.fileContextTitle : "",
67
100
  formatFileContext(input.files),
68
101
  input.files.length > 0 ? "" : "",
69
- messages.transcriptTitle,
102
+ isAskSummary ? messages.askResponsesTitle : messages.transcriptTitle,
70
103
  transcript || messages.noMessage,
71
104
  "",
72
105
  messages.expectedFormatTitle,
106
+ ...(isAskSummary ? askSummaryHeadings(messages) : debateSummaryHeadings(messages)),
107
+ "",
108
+ isAskSummary ? messages.askFinalProseInstruction : messages.finalProseInstruction,
109
+ "",
110
+ messages.summaryAnswerTitle
111
+ ]
112
+ .filter(Boolean)
113
+ .join("\n");
114
+ }
115
+ function debateSummaryHeadings(messages) {
116
+ return [
73
117
  messages.consensusHeading,
74
118
  "",
75
119
  messages.disagreementsHeading,
76
120
  "",
77
121
  messages.actionsHeading,
78
122
  "",
79
- messages.conclusionHeading,
123
+ messages.conclusionHeading
124
+ ];
125
+ }
126
+ function askSummaryHeadings(messages) {
127
+ return [
128
+ messages.askAgentSummariesHeading,
80
129
  "",
81
- messages.finalProseInstruction,
130
+ messages.askComparisonHeading,
82
131
  "",
83
- messages.summaryAnswerTitle
84
- ]
85
- .filter(Boolean)
86
- .join("\n");
132
+ messages.askWatchpointsHeading,
133
+ "",
134
+ messages.actionsHeading,
135
+ "",
136
+ messages.conclusionHeading
137
+ ];
87
138
  }
88
139
  /** Formate les fichiers projet en blocs de code annotés pour l'injection dans le prompt. */
89
140
  function formatFileContext(files) {
@@ -33,7 +33,7 @@ class PrettyConsoleRenderer {
33
33
  this.c("cyan", `┌─ ${title} ${"─".repeat(Math.max(1, 54 - title.length))}`),
34
34
  this.c("cyan", `│`) + ` ${this.messages.renderers.subject(options.topic)}`,
35
35
  this.c("cyan", `│`) + ` ${this.messages.renderers.agents(formatAgentPair(options, agents))}`,
36
- this.c("cyan", `│`) + ` ${this.messages.renderers.responsesSummary(options.turns, formatSummary(options, this.messages))}`,
36
+ this.c("cyan", `│`) + ` ${this.messages.renderers.responsesSummary(formatResponseCount(options), formatSummary(options, this.messages))}`,
37
37
  this.c("cyan", `│`) + ` ${this.messages.renderers.context(formatContext(options, this.messages))}`,
38
38
  this.c("cyan", `│`) + ` ${this.messages.renderers.options(options.earlyStopOnAgreement, options.pullModels)}`,
39
39
  this.c("cyan", `└${"─".repeat(57)}`),
@@ -58,6 +58,15 @@ class PrettyConsoleRenderer {
58
58
  ""
59
59
  ].join("\n"));
60
60
  }
61
+ askResponseStart(response, totalResponses, agent, role) {
62
+ this.renderingSummary = false;
63
+ process.stdout.write([
64
+ "",
65
+ this.c("orange", `◆ ${agent}`) + this.dim(` · ${role} · réponse ${response}/${totalResponses}`),
66
+ this.dim("─".repeat(60)),
67
+ ""
68
+ ].join("\n"));
69
+ }
61
70
  /** Démarre le spinner de réflexion (ou affiche une ligne fixe si non interactif). */
62
71
  thinkingStart(agent, role) {
63
72
  this.thinkingEnd();
@@ -89,6 +98,9 @@ class PrettyConsoleRenderer {
89
98
  const trimmed = content.trim();
90
99
  process.stdout.write(`${this.renderingSummary ? this.formatSummaryMessage(trimmed) : trimmed}\n`);
91
100
  }
101
+ askResponseMessage(content) {
102
+ this.message(content);
103
+ }
92
104
  /** Affiche l'en-tête de section synthèse et active le mode formatage de résumé. */
93
105
  summaryStart(agent, role) {
94
106
  this.renderingSummary = true;
@@ -153,7 +165,7 @@ class PlainConsoleRenderer {
153
165
  start(options, agents = []) {
154
166
  process.stdout.write(this.messages.renderers.subject(options.topic) + "\n");
155
167
  process.stdout.write(this.messages.renderers.agents(formatAgentPair(options, agents)) + "\n");
156
- process.stdout.write(this.messages.renderers.responsesSummaryContext(options.turns, formatSummary(options, this.messages), formatContext(options, this.messages)) + "\n");
168
+ process.stdout.write(this.messages.renderers.responsesSummaryContext(formatResponseCount(options), formatSummary(options, this.messages), formatContext(options, this.messages)) + "\n");
157
169
  }
158
170
  /** Écrit un avertissement sur `stderr`. */
159
171
  warning(message) {
@@ -167,6 +179,9 @@ class PlainConsoleRenderer {
167
179
  turnStart(turn, totalTurns, agent, role) {
168
180
  process.stdout.write(`\n[${turn}/${totalTurns}] ${agent} (${role})...\n`);
169
181
  }
182
+ askResponseStart(response, totalResponses, agent, role) {
183
+ process.stdout.write(`\n[${response}/${totalResponses}] ${agent} (${role})...\n`);
184
+ }
170
185
  /** No-op : pas de spinner en mode plain. */
171
186
  thinkingStart(_agent, _role) { }
172
187
  /** No-op : pas de spinner à arrêter en mode plain. */
@@ -175,6 +190,9 @@ class PlainConsoleRenderer {
175
190
  message(content) {
176
191
  process.stdout.write(`${content.trim()}\n`);
177
192
  }
193
+ askResponseMessage(content) {
194
+ this.message(content);
195
+ }
178
196
  /** Affiche l'en-tête de la section synthèse en texte brut. */
179
197
  summaryStart(agent, role) {
180
198
  process.stdout.write(`\n[${this.messages.renderers.summaryTitle}] ${agent} (${role})...\n`);
@@ -194,6 +212,12 @@ class PlainConsoleRenderer {
194
212
  * @param agents - Infos de démarrage des agents (type, rôle, nom).
195
213
  */
196
214
  function formatAgentPair(options, agents) {
215
+ if (options.mode === "ask") {
216
+ if (agents.length > 0) {
217
+ return agents.map(formatAgentLabel).join(", ");
218
+ }
219
+ return (options.askAgents ?? [options.agentA, options.agentB]).join(", ");
220
+ }
197
221
  if (agents.length >= 2) {
198
222
  return `${formatAgentLabel(agents[0])} <-> ${formatAgentLabel(agents[1])}`;
199
223
  }
@@ -214,7 +238,19 @@ function formatAgentLabel(agent) {
214
238
  * @param options - Options du débat.
215
239
  */
216
240
  function formatSummary(options, messages) {
217
- return options.summaryEnabled ? options.summaryAgent ?? options.agentB : messages.renderers.disabled;
241
+ if (!options.summaryEnabled) {
242
+ return messages.renderers.disabled;
243
+ }
244
+ if (options.summaryAgent) {
245
+ return options.summaryAgent;
246
+ }
247
+ if (options.mode === "ask" && options.askAgents && options.askAgents.length > 0) {
248
+ return options.askAgents[options.askAgents.length - 1] ?? options.agentB;
249
+ }
250
+ return options.agentB;
251
+ }
252
+ function formatResponseCount(options) {
253
+ return options.mode === "ask" ? options.askAgents?.length ?? 2 : options.turns;
218
254
  }
219
255
  /**
220
256
  * Renvoie un résumé du contexte injecté (nombre de fichiers ou mention d'absence).