ocerebro 0.2.1 → 0.2.2
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.
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/src/mcp/server.py +46 -37
package/package.json
CHANGED
package/pyproject.toml
CHANGED
package/src/mcp/server.py
CHANGED
|
@@ -296,20 +296,16 @@ class CerebroMCP:
|
|
|
296
296
|
),
|
|
297
297
|
Tool(
|
|
298
298
|
name="cerebro_capture_memory",
|
|
299
|
-
description="
|
|
299
|
+
description="Salva uma memória diretamente em ~/.claude/memory/ (formato nativo Claude Code). Chame uma vez por memória com o conteúdo Markdown completo.",
|
|
300
300
|
inputSchema={
|
|
301
301
|
"type": "object",
|
|
302
302
|
"properties": {
|
|
303
|
-
"
|
|
303
|
+
"memory_content": {
|
|
304
304
|
"type": "string",
|
|
305
|
-
"description": "
|
|
306
|
-
},
|
|
307
|
-
"memory_dir": {
|
|
308
|
-
"type": "string",
|
|
309
|
-
"description": "Diretório de memória (opcional)"
|
|
305
|
+
"description": "Conteúdo Markdown completo com frontmatter obrigatório: name, description, type (user|feedback|project|reference)"
|
|
310
306
|
}
|
|
311
307
|
},
|
|
312
|
-
"required": ["
|
|
308
|
+
"required": ["memory_content"]
|
|
313
309
|
}
|
|
314
310
|
),
|
|
315
311
|
Tool(
|
|
@@ -651,40 +647,53 @@ class CerebroMCP:
|
|
|
651
647
|
{full_prompt}
|
|
652
648
|
|
|
653
649
|
---
|
|
654
|
-
INSTRUÇÃO:
|
|
655
|
-
|
|
650
|
+
INSTRUÇÃO CRÍTICA: Analise esta conversa usando o prompt acima.
|
|
651
|
+
Para CADA memória identificada, chame cerebro_capture_memory UMA vez:
|
|
652
|
+
|
|
653
|
+
cerebro_capture_memory(memory_content="---\\nname: <nome>\\ndescription: <descrição>\\ntype: <user|feedback|project|reference>\\n---\\n\\n<conteúdo>")
|
|
656
654
|
|
|
657
|
-
|
|
655
|
+
NÃO use FileWrite. NÃO use FileEdit. APENAS cerebro_capture_memory.
|
|
656
|
+
Uma chamada por memória. O sistema salva e indexa automaticamente.
|
|
658
657
|
"""
|
|
659
658
|
|
|
660
659
|
def _capture_memory(self, args: Dict[str, Any]) -> str:
|
|
661
|
-
"""
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
660
|
+
"""Salva uma memória no diretório nativo do Claude Code."""
|
|
661
|
+
import re
|
|
662
|
+
from datetime import datetime
|
|
663
|
+
from src.core.paths import get_memory_index
|
|
664
|
+
|
|
665
|
+
content = args.get("memory_content", "")
|
|
666
|
+
if not content:
|
|
667
|
+
return "Erro: 'memory_content' é obrigatório"
|
|
668
|
+
|
|
669
|
+
name_match = re.search(r'name:\s*(.*)', content)
|
|
670
|
+
if not name_match:
|
|
671
|
+
return "Erro: frontmatter 'name' é obrigatório no memory_content"
|
|
672
|
+
|
|
673
|
+
mem_name = name_match.group(1).strip().lower().replace(' ', '-')
|
|
674
|
+
mem_dir = get_auto_mem_path()
|
|
675
|
+
mem_dir.mkdir(parents=True, exist_ok=True)
|
|
676
|
+
|
|
677
|
+
file_path = mem_dir / f"{mem_name}.md"
|
|
678
|
+
file_path.write_text(content, encoding="utf-8")
|
|
679
|
+
|
|
680
|
+
desc_match = re.search(r'description:\s*(.*)', content)
|
|
681
|
+
type_match = re.search(r'type:\s*(.*)', content)
|
|
682
|
+
desc = desc_match.group(1).strip() if desc_match else "sem descrição"
|
|
683
|
+
m_type = type_match.group(1).strip() if type_match else "project"
|
|
684
|
+
ts = datetime.now().strftime("%Y-%m-%d")
|
|
685
|
+
entry = f"- [{m_type}] {mem_name}.md ({ts}): {desc}\n"
|
|
686
|
+
|
|
687
|
+
index_path = get_memory_index(mem_dir)
|
|
688
|
+
if index_path.exists():
|
|
689
|
+
existing = index_path.read_text(encoding="utf-8")
|
|
690
|
+
if mem_name not in existing:
|
|
691
|
+
with open(index_path, "a", encoding="utf-8") as f:
|
|
692
|
+
f.write(entry)
|
|
693
|
+
else:
|
|
694
|
+
index_path.write_text(f"# Memórias do Projeto\n\n{entry}", encoding="utf-8")
|
|
685
695
|
|
|
686
|
-
|
|
687
|
-
"""
|
|
696
|
+
return f"✅ Memória '{mem_name}' salva em {file_path}"
|
|
688
697
|
|
|
689
698
|
def _remember(self, args: Dict[str, Any]) -> str:
|
|
690
699
|
"""Revisão e promoção de memórias"""
|