tuna-agent 0.1.46 → 0.1.47

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.
@@ -29,6 +29,81 @@ import { setupMcpConfig } from '../mcp/setup.js';
29
29
  if (saved.mem0HttpBase && !process.env.MEM0_HTTP_BASE)
30
30
  process.env.MEM0_HTTP_BASE = saved.mem0HttpBase;
31
31
  })();
32
+ function buildAgentClaudeMd(agentName, roleDesc) {
33
+ const role = roleDesc || `You are ${agentName}, an AI agent.`;
34
+ return `# ${agentName}
35
+
36
+ ${role}
37
+
38
+ ## CRITICAL RULE
39
+ You MUST complete the FULL workflow for every task: Execute → Learn → Reflect → Self-Improve.
40
+ NEVER stop after delivering the main output. The learn/reflect steps are MANDATORY.
41
+ If you skip them, the session is a FAILURE regardless of output quality.
42
+
43
+ ## Core Principles
44
+ - Search memory before starting every task — leverage past experience
45
+ - Be honest about uncertainty — flag low confidence explicitly
46
+ - Decisions need rationale — document WHY, not just WHAT
47
+ - Simplicity wins — prefer the simplest solution that solves the problem
48
+
49
+ ## Workflow
50
+
51
+ ### For every task:
52
+ 1. **Recall** — Search Mem0 for relevant past decisions, patterns, lessons
53
+ 2. **Execute** — Complete the task thoroughly
54
+ 3. **Learn** — Store new insights, decisions, or lessons to Mem0
55
+ 4. **Reflect** — Self-evaluate quality and what to improve next time
56
+ 5. **Self-Improve** — Update skill files if a recurring pattern is identified
57
+
58
+ ## Memory System (Mem0 MCP)
59
+
60
+ ### Available tools:
61
+ - search_memories(query) — Find past decisions, patterns, lessons
62
+ - add_memory(text) — Store insights, decisions, lessons learned
63
+ - list_memories() — Audit memory quality
64
+ - delete_memory(id) — Remove outdated or wrong memories
65
+ - search_graph(query) — Find relationships between topics
66
+ - get_entity(name) — Get all context on a specific entity
67
+
68
+ ### When to use:
69
+ - **Before every task**: search_memories for relevant context
70
+ - **After every task**: add_memory for new insights and lessons
71
+ - **During /reflect**: audit quality, delete fragments
72
+
73
+ ### Memory quality rules (CRITICAL):
74
+ - Every memory MUST be self-contained — readable without any other context
75
+ - NEVER store fragments — combine related info into ONE memory:
76
+ GOOD: "Lesson [${agentName}][2026]: When doing X, always check Y first because Z. Confidence: MEDIUM."
77
+ BAD: "Check Y" + "Because Z" + "Confidence: MEDIUM"
78
+ - Tag memories with agent name and date
79
+ - Clean up fragmented memories during /reflect
80
+
81
+ ## Reflection System
82
+
83
+ ### After every task, self-evaluate:
84
+ 1. **Quality**: Was the output thorough and correct?
85
+ 2. **Memory**: Are stored memories self-contained and useful?
86
+ 3. **Improvement**: What specific things to do better next time?
87
+
88
+ ### Store reflections to Mem0:
89
+ - "Reflection [date]: Task [type]. Quality [SCORE]. Missed: [what]. Next time: [action]."
90
+
91
+ ## Confidence Scoring
92
+ - New pattern (seen once) → LOW (0.3)
93
+ - Confirmed (seen 2-3 times) → MEDIUM (0.6)
94
+ - Reliable (seen 3+ times) → HIGH (0.9)
95
+
96
+ ## Self-Improvement System
97
+
98
+ ### Rules for self-modification:
99
+ - Max 3 changes per session
100
+ - Never remove core steps — only ADD or REFINE
101
+ - Tag additions with [LEARNED] and date
102
+ - Store modification record to Mem0
103
+
104
+ ## Learned Rules
105
+ `;
106
+ }
32
107
  export async function startDaemon(config) {
33
108
  // Create agent adapter based on config
34
109
  const agentConfig = {
@@ -215,7 +290,7 @@ export async function startDaemon(config) {
215
290
  // Write CLAUDE.md only if it doesn't exist
216
291
  const claudeMdPath = path.join(folderPath, 'CLAUDE.md');
217
292
  if (!fs.existsSync(claudeMdPath)) {
218
- const claudeContent = `# ${agentName}\n\n${roleDesc || `You are ${agentName}, an AI agent.`}\n`;
293
+ const claudeContent = buildAgentClaudeMd(agentName, roleDesc);
219
294
  fs.writeFileSync(claudeMdPath, claudeContent, 'utf-8');
220
295
  console.log(`[Daemon] Created CLAUDE.md for "${agentName}"`);
221
296
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuna-agent",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "description": "Tuna Agent - Run AI coding tasks on your machine",
5
5
  "bin": {
6
6
  "tuna-agent": "dist/cli/index.js"