List persistent memories.
(self, chat_context: Any, action: str)
| 400 | return getattr(chat_context, "memory_store", None) |
| 401 | |
| 402 | def _persistent_list(self, chat_context: Any, action: str) -> CommandResult: |
| 403 | """List persistent memories.""" |
| 404 | from mcp_cli.memory.models import MemoryScope |
| 405 | |
| 406 | store = self._get_store(chat_context) |
| 407 | if not store: |
| 408 | return CommandResult(success=False, error="Memory store not available.") |
| 409 | |
| 410 | # Parse optional scope filter |
| 411 | parts = action.split() |
| 412 | scope_filter = parts[1] if len(parts) > 1 else None |
| 413 | |
| 414 | scopes = ( |
| 415 | [MemoryScope(scope_filter)] |
| 416 | if scope_filter |
| 417 | else [MemoryScope.WORKSPACE, MemoryScope.GLOBAL] |
| 418 | ) |
| 419 | |
| 420 | rows = [] |
| 421 | for scope in scopes: |
| 422 | for entry in store.list_entries(scope): |
| 423 | rows.append( |
| 424 | { |
| 425 | "Scope": scope.value, |
| 426 | "Key": entry.key, |
| 427 | "Content": ( |
| 428 | entry.content[:60] + "..." |
| 429 | if len(entry.content) > 60 |
| 430 | else entry.content |
| 431 | ), |
| 432 | "Updated": entry.updated_at.strftime("%Y-%m-%d %H:%M"), |
| 433 | } |
| 434 | ) |
| 435 | |
| 436 | if not rows: |
| 437 | output.info("No persistent memories found.") |
| 438 | return CommandResult(success=True) |
| 439 | |
| 440 | table = format_table( |
| 441 | rows, |
| 442 | title=None, |
| 443 | columns=["Scope", "Key", "Content", "Updated"], |
| 444 | ) |
| 445 | output.rule("[bold]Persistent Memories[/bold]", style="primary") |
| 446 | output.print_table(table) |
| 447 | return CommandResult(success=True, data=rows) |
| 448 | |
| 449 | def _persistent_add(self, chat_context: Any, action: str) -> CommandResult: |
| 450 | """Add a persistent memory.""" |
no test coverage detected