Add a persistent memory.
(self, chat_context: Any, action: str)
| 447 | return CommandResult(success=True, data=rows) |
| 448 | |
| 449 | def _persistent_add(self, chat_context: Any, action: str) -> CommandResult: |
| 450 | """Add a persistent memory.""" |
| 451 | from mcp_cli.memory.models import MemoryScope |
| 452 | |
| 453 | store = self._get_store(chat_context) |
| 454 | if not store: |
| 455 | return CommandResult(success=False, error="Memory store not available.") |
| 456 | |
| 457 | # Parse: add <scope> <key> <content...> |
| 458 | parts = action.split(maxsplit=3) |
| 459 | if len(parts) < 4: |
| 460 | return CommandResult( |
| 461 | success=False, |
| 462 | error="Usage: /memory add <workspace|global> <key> <content>", |
| 463 | ) |
| 464 | |
| 465 | try: |
| 466 | scope = MemoryScope(parts[1]) |
| 467 | except ValueError: |
| 468 | return CommandResult( |
| 469 | success=False, |
| 470 | error=f"Invalid scope: {parts[1]}. Use 'workspace' or 'global'.", |
| 471 | ) |
| 472 | |
| 473 | key, content = parts[2], parts[3] |
| 474 | entry = store.remember(scope, key, content) |
| 475 | chat_context._system_prompt_dirty = True |
| 476 | output.success(f"Remembered '{entry.key}' in {scope.value} scope.") |
| 477 | return CommandResult(success=True) |
| 478 | |
| 479 | def _persistent_remove(self, chat_context: Any, action: str) -> CommandResult: |
| 480 | """Remove a persistent memory.""" |
no test coverage detected