tuna-agent 0.1.82 → 0.1.83

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.
@@ -185,7 +185,22 @@ export class ClaudeCodeAdapter {
185
185
  let firstChunkIso = '';
186
186
  let turnAccumulatedText = '';
187
187
  let messageCount = 0; // Track message_start events to detect new turns
188
- let lastSentContent = ''; // Dedup: skip sending same message twice
188
+ let lastSentContent = ''; // Dedup: skip sending same/similar message twice
189
+ // Normalize text for similarity comparison (strip markdown, collapse whitespace)
190
+ const normalize = (s) => s.replace(/[#*_`~\-|>]/g, '').replace(/\s+/g, ' ').trim().toLowerCase();
191
+ const isSimilar = (a, b) => {
192
+ if (!a || !b)
193
+ return false;
194
+ const na = normalize(a), nb = normalize(b);
195
+ if (na === nb)
196
+ return true;
197
+ // Check if one contains the other (common with slight variations)
198
+ if (na.length > 20 && nb.length > 20) {
199
+ if (na.includes(nb) || nb.includes(na))
200
+ return true;
201
+ }
202
+ return false;
203
+ };
189
204
  console.log(`[ClaudeCode] Agent Team round ${round + 1}: ${userMessage.substring(0, 80)}${currentInputFiles?.length ? ` (+${currentInputFiles.length} images)` : ''}`);
190
205
  const defaultWorkspace = path.join(os.homedir(), 'tuna-workspace');
191
206
  const cwd = task.repoPath || defaultWorkspace;
@@ -233,7 +248,7 @@ export class ClaudeCodeAdapter {
233
248
  console.log(`[ClaudeCode] ✂️ Splitting bubble — finalizing ${turnAccumulatedText.length} chars from previous turn`);
234
249
  ws.sendPMStreamEnd(task.id, streamMsgId);
235
250
  const simplified = simplifyMarkdown(turnAccumulatedText);
236
- if (simplified !== lastSentContent) {
251
+ if (!isSimilar(simplified, lastSentContent)) {
237
252
  ws.sendPMMessage(task.id, {
238
253
  sender: 'pm',
239
254
  content: simplified,
@@ -338,7 +353,7 @@ export class ClaudeCodeAdapter {
338
353
  // Send finalized message for the last turn's remaining text (skip if duplicate)
339
354
  if (turnAccumulatedText.trim()) {
340
355
  const simplified = simplifyMarkdown(turnAccumulatedText);
341
- if (simplified !== lastSentContent) {
356
+ if (!isSimilar(simplified, lastSentContent)) {
342
357
  ws.sendPMMessage(task.id, {
343
358
  sender: 'pm',
344
359
  content: simplified,
@@ -347,7 +362,7 @@ export class ClaudeCodeAdapter {
347
362
  lastSentContent = simplified;
348
363
  }
349
364
  else {
350
- console.log(`[ClaudeCode] ⏭️ Skipping duplicate final message (${simplified.length} chars)`);
365
+ console.log(`[ClaudeCode] ⏭️ Skipping similar final message (${simplified.length} chars)`);
351
366
  }
352
367
  }
353
368
  // Last round → close
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuna-agent",
3
- "version": "0.1.82",
3
+ "version": "0.1.83",
4
4
  "description": "Tuna Agent - Run AI coding tasks on your machine",
5
5
  "bin": {
6
6
  "tuna-agent": "dist/cli/index.js"