Clear all persistent memories in a scope.
(self, chat_context: Any, action: str)
| 509 | return CommandResult(success=True) |
| 510 | |
| 511 | def _persistent_clear(self, chat_context: Any, action: str) -> CommandResult: |
| 512 | """Clear all persistent memories in a scope.""" |
| 513 | from mcp_cli.memory.models import MemoryScope |
| 514 | |
| 515 | store = self._get_store(chat_context) |
| 516 | if not store: |
| 517 | return CommandResult(success=False, error="Memory store not available.") |
| 518 | |
| 519 | # Parse: clear <scope> |
| 520 | parts = action.split(maxsplit=1) |
| 521 | if len(parts) < 2: |
| 522 | return CommandResult( |
| 523 | success=False, |
| 524 | error="Usage: /memory clear <workspace|global>", |
| 525 | ) |
| 526 | |
| 527 | try: |
| 528 | scope = MemoryScope(parts[1]) |
| 529 | except ValueError: |
| 530 | return CommandResult( |
| 531 | success=False, |
| 532 | error=f"Invalid scope: {parts[1]}. Use 'workspace' or 'global'.", |
| 533 | ) |
| 534 | |
| 535 | count = store.clear(scope) |
| 536 | chat_context._system_prompt_dirty = True |
| 537 | output.success(f"Cleared {count} memories from {scope.value} scope.") |
| 538 | return CommandResult(success=True) |
no test coverage detected