tuna-agent 0.1.42 → 0.1.43
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.
|
@@ -107,10 +107,12 @@ export class ClaudeCodeAdapter {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
// Pre-task Memory Recall: search Mem0 for relevant past learnings
|
|
110
|
+
const defaultWorkspaceForRecall = path.join(os.homedir(), 'tuna-workspace');
|
|
111
|
+
const recallAgentName = path.basename(task.repoPath || defaultWorkspaceForRecall);
|
|
110
112
|
if (process.env.MEM0_SSH_HOST && task.description.length >= 20) {
|
|
111
113
|
try {
|
|
112
114
|
const { callMem0SearchMemory } = await import('../mcp/setup.js');
|
|
113
|
-
const memories = await callMem0SearchMemory(task.description,
|
|
115
|
+
const memories = await callMem0SearchMemory(task.description, recallAgentName, 5);
|
|
114
116
|
if (memories.length > 0) {
|
|
115
117
|
const memoryContext = memories.map(m => `- ${m}`).join('\n');
|
|
116
118
|
userMessage = `${task.description}\n\n<past_learnings>\nRelevant lessons from previous tasks:\n${memoryContext}\n</past_learnings>`;
|
|
@@ -747,8 +749,9 @@ export class ClaudeCodeAdapter {
|
|
|
747
749
|
return;
|
|
748
750
|
}
|
|
749
751
|
// Step 2: Store the AI-generated reflection in Mem0
|
|
752
|
+
const agentFolderNameForReflection = path.basename(cwd);
|
|
750
753
|
console.log(`[Reflection] Storing: "${aiReflection.substring(0, 100)}..."`);
|
|
751
|
-
await callMem0AddMemory(aiReflection,
|
|
754
|
+
await callMem0AddMemory(aiReflection, agentFolderNameForReflection);
|
|
752
755
|
this.metrics.reflectionCount++;
|
|
753
756
|
this.metrics.memoryCount++;
|
|
754
757
|
this.metrics.lastReflectionAt = new Date().toISOString();
|
|
@@ -762,7 +765,7 @@ export class ClaudeCodeAdapter {
|
|
|
762
765
|
? `Task failed: "${task.description.substring(0, 150)}". Error: ${resultSummary.substring(0, 200)}`
|
|
763
766
|
: `Task completed: "${task.description.substring(0, 150)}". Result: ${resultSummary.substring(0, 200)}`;
|
|
764
767
|
const { callMem0AddMemory } = await import('../mcp/setup.js');
|
|
765
|
-
await callMem0AddMemory(fallback,
|
|
768
|
+
await callMem0AddMemory(fallback, path.basename(cwd));
|
|
766
769
|
}
|
|
767
770
|
catch {
|
|
768
771
|
// Both AI and fallback failed — give up silently
|
|
@@ -785,7 +788,7 @@ export class ClaudeCodeAdapter {
|
|
|
785
788
|
try {
|
|
786
789
|
console.log(`[Rating→Mem0] Storing rating for task "${data.taskTitle}" (${data.score > 0 ? '👍' : '👎'})`);
|
|
787
790
|
const { callMem0AddMemory } = await import('../mcp/setup.js');
|
|
788
|
-
await callMem0AddMemory(memoryText,
|
|
791
|
+
await callMem0AddMemory(memoryText, path.basename(data.cwd));
|
|
789
792
|
console.log(`[Rating→Mem0] Rating stored successfully`);
|
|
790
793
|
}
|
|
791
794
|
catch (err) {
|
|
@@ -805,7 +808,7 @@ export class ClaudeCodeAdapter {
|
|
|
805
808
|
try {
|
|
806
809
|
console.log(`[Self-Improve] Running pattern detection (every ${ClaudeCodeAdapter.PATTERN_CHECK_INTERVAL} tasks, count=${this.taskCount})`);
|
|
807
810
|
const { callMem0Patterns } = await import('../mcp/setup.js');
|
|
808
|
-
const patterns = await callMem0Patterns(
|
|
811
|
+
const patterns = await callMem0Patterns(path.basename(cwd), 3);
|
|
809
812
|
if (patterns.length === 0) {
|
|
810
813
|
console.log(`[Self-Improve] No patterns detected yet`);
|
|
811
814
|
return;
|