ocerebro 0.1.9 → 0.2.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.
@@ -187,41 +187,77 @@ def merge_configs(existing: dict, new: dict) -> dict:
187
187
  return result
188
188
 
189
189
 
190
- def setup_slash_commands(project_path: Path) -> bool:
191
- """Cria slash commands /cerebro no .claude/commands/ do projeto."""
190
+ def setup_slash_commands(project_path: Path | None = None, global_commands: bool = True) -> bool:
191
+ """Cria slash commands /cerebro no .claude/commands/ do projeto e global."""
192
192
 
193
- commands_dir = project_path / ".claude" / "commands"
194
- commands_dir.mkdir(parents=True, exist_ok=True)
193
+ if project_path:
194
+ commands_dir = project_path / ".claude" / "commands"
195
+ commands_dir.mkdir(parents=True, exist_ok=True)
195
196
 
196
- dream_cmd = commands_dir / "cerebro-dream.md"
197
- if not dream_cmd.exists():
198
- dream_cmd.write_text("""---
197
+ dream_cmd = commands_dir / "cerebro-dream.md"
198
+ if not dream_cmd.exists():
199
+ dream_cmd.write_text("""---
199
200
  description: Extrair memórias da sessão atual
200
201
  ---
201
202
  Execute: ocerebro dream --since 7 --apply
202
203
  Mostre o relatório completo do que foi salvo.
203
204
  """, encoding="utf-8")
204
- print(f"[OK] Slash command criado: {dream_cmd}")
205
+ print(f"[OK] Slash command criado: {dream_cmd}")
205
206
 
206
- status_cmd = commands_dir / "cerebro-status.md"
207
- if not status_cmd.exists():
208
- status_cmd.write_text("""---
207
+ status_cmd = commands_dir / "cerebro-status.md"
208
+ if not status_cmd.exists():
209
+ status_cmd.write_text("""---
209
210
  description: Ver status da memória do projeto
210
211
  ---
211
212
  Execute: ocerebro status
212
213
  Liste quantas memórias existem por tipo.
213
214
  """, encoding="utf-8")
214
- print(f"[OK] Slash command criado: {status_cmd}")
215
+ print(f"[OK] Slash command criado: {status_cmd}")
215
216
 
216
- gc_cmd = commands_dir / "cerebro-gc.md"
217
- if not gc_cmd.exists():
218
- gc_cmd.write_text("""---
217
+ gc_cmd = commands_dir / "cerebro-gc.md"
218
+ if not gc_cmd.exists():
219
+ gc_cmd.write_text("""---
219
220
  description: Limpeza de memórias antigas
220
221
  ---
221
222
  Execute: ocerebro gc --threshold 30
222
223
  Mostre o que será arquivado antes de confirmar.
223
224
  """, encoding="utf-8")
224
- print(f"[OK] Slash command criado: {gc_cmd}")
225
+ print(f"[OK] Slash command criado: {gc_cmd}")
226
+
227
+ # Slash commands globais em ~/.claude/commands/
228
+ if global_commands:
229
+ global_commands_dir = Path.home() / ".claude" / "commands"
230
+ global_commands_dir.mkdir(parents=True, exist_ok=True)
231
+
232
+ dream_global = global_commands_dir / "cerebro-dream.md"
233
+ if not dream_global.exists():
234
+ dream_global.write_text("""---
235
+ description: Extrair memórias da sessão atual (global)
236
+ ---
237
+ Execute: ocerebro dream --since 7 --apply
238
+ Mostre o relatório completo do que foi salvo.
239
+ """, encoding="utf-8")
240
+ print(f"[OK] Slash command global criado: {dream_global}")
241
+
242
+ status_global = global_commands_dir / "cerebro-status.md"
243
+ if not status_global.exists():
244
+ status_global.write_text("""---
245
+ description: Ver status da memória (global)
246
+ ---
247
+ Execute: ocerebro status
248
+ Liste quantas memórias existem por tipo.
249
+ """, encoding="utf-8")
250
+ print(f"[OK] Slash command global criado: {status_global}")
251
+
252
+ gc_global = global_commands_dir / "cerebro-gc.md"
253
+ if not gc_global.exists():
254
+ gc_global.write_text("""---
255
+ description: Limpeza de memórias antigas (global)
256
+ ---
257
+ Execute: ocerebro gc --threshold 30
258
+ Mostre o que será arquivado antes de confirmar.
259
+ """, encoding="utf-8")
260
+ print(f"[OK] Slash command global criado: {gc_global}")
225
261
 
226
262
  return True
227
263
 
@@ -358,6 +394,23 @@ def setup_claude(auto: bool = True) -> bool:
358
394
  existing_config["mcp"] = {}
359
395
  existing_config["mcp"]["enabled"] = True
360
396
 
397
+ # Adiciona hook para dream automatico ao final da sessao
398
+ if "hooks" not in existing_config:
399
+ existing_config["hooks"] = {}
400
+
401
+ # Hook Stop: roda dream ao final de cada sessao
402
+ existing_config["hooks"]["Stop"] = [
403
+ {
404
+ "matcher": "",
405
+ "hooks": [
406
+ {
407
+ "type": "command",
408
+ "command": f"{python_cmd} -m src.cli.main dream --since 1 --apply --silent"
409
+ }
410
+ ]
411
+ }
412
+ ]
413
+
361
414
  config_path.write_text(
362
415
  json.dumps(existing_config, indent=2, ensure_ascii=False),
363
416
  encoding="utf-8"
@@ -503,7 +556,7 @@ def main():
503
556
  project = Path(sys.argv[2]) if len(sys.argv) > 2 else Path.cwd()
504
557
  setup_ocerebro_dir(project)
505
558
  setup_hooks(project)
506
- setup_slash_commands(project)
559
+ setup_slash_commands(project=project)
507
560
  setup_claude(auto=True)
508
561
  sys.exit(0)
509
562
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocerebro",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "OCerebro - Sistema de Memoria para Agentes (Claude Code/MCP)",
5
5
  "main": "bin/ocerebro.js",
6
6
  "bin": {
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ocerebro"
7
- version = "0.1.9"
7
+ version = "0.2.0"
8
8
  description = "OCerebro - Sistema de Memoria para Agentes (Claude Code/MCP)"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
package/src/cli/main.py CHANGED
@@ -363,6 +363,7 @@ def main():
363
363
  dream_parser = subparsers.add_parser("dream", help="Extração automática de memórias")
364
364
  dream_parser.add_argument("--since", type=int, default=7, dest="since_days")
365
365
  dream_parser.add_argument("--apply", action="store_true", dest="apply")
366
+ dream_parser.add_argument("--silent", action="store_true", dest="silent", help="Não imprimir output (para hooks)")
366
367
 
367
368
  # Comando: remember
368
369
  remember_parser = subparsers.add_parser("remember", help="Revisão e promoção de memórias")
@@ -434,6 +435,8 @@ def main():
434
435
  )
435
436
  elif args.command == "dream":
436
437
  result = cli.dream(since_days=args.since_days, dry_run=not args.apply)
438
+ if getattr(args, 'silent', False):
439
+ sys.exit(0)
437
440
  elif args.command == "remember":
438
441
  result = cli.remember(dry_run=not args.apply)
439
442
  elif args.command == "gc":
@@ -442,6 +445,8 @@ def main():
442
445
  parser.print_help()
443
446
  sys.exit(1)
444
447
 
448
+ if getattr(args, 'silent', False):
449
+ sys.exit(0)
445
450
  print(result)
446
451
 
447
452