Skip to content

feat: Add CLI scripts for PowerMem#214

Merged
Teingi merged 1 commit into
oceanbase:mainfrom
knqiufan:main
Jan 31, 2026
Merged

feat: Add CLI scripts for PowerMem#214
Teingi merged 1 commit into
oceanbase:mainfrom
knqiufan:main

Conversation

@knqiufan

Copy link
Copy Markdown
Contributor

This PR implements a Command-Line Interface (CLI) tool for PowerMem, enabling developers and system administrators to interact with PowerMem directly from the command line without writing Python scripts.

close #136

Solution Description

Features Implemented

1. Memory Operations (pmem add/search/get/update/delete/list/delete-all)

  • Add new memories with user/agent/run ID support
  • Search memories with filters and similarity threshold
  • Get, update, and delete individual memories
  • List all memories with pagination and sorting
  • Batch delete with safety confirmation

2. Configuration Management (pmem config show/validate/test)

  • Display current configuration (with secret masking)
  • Validate configuration files with strict mode
  • Test connectivity to database, LLM, and embedder

3. Statistics (pmem stats)

  • View memory statistics filtered by user/agent ID
  • Support detailed statistics with --detailed flag

4. Management Commands (pmem manage backup/restore/cleanup/migrate)

  • Export memories to JSON backup files
  • Restore memories from backup with dry-run support
  • Clean up forgotten memories based on retention scores
  • Migrate data between stores

5. Interactive Mode (pmem interactive or pmem shell)

  • REPL-like experience for quick operations
  • Session-level default user/agent ID settings
  • Built-in help and command history

Technical Implementation

  • CLI Framework: Uses click (existing dependency)
  • Output Formats: JSON (--json), Table (default), Plain text
  • Configuration: Reuses existing .env and auto_config() system
  • Shell Completion: Supports bash, zsh, fish, and PowerShell (--install-completion)
  • Entry Points: pmem and powermem-cli commands

File Structure

src/powermem/cli/
├── init.py # CLI package entry
├── main.py # Main command group + completion
├── commands/
│ ├── memory.py # Memory operations
│ ├── config.py # Configuration commands
│ ├── stats.py # Statistics command
│ ├── manage.py # Management commands
│ └── interactive.py # Interactive mode
└── utils/
└── output.py # Output formatting utilities

Usage Examples

Memory operations

pmem add "User prefers dark mode" --user-id user123
pmem search "user preferences" --user-id user123 --json
pmem list --user-id user123 --limit 50

Configuration

pmem config show
pmem config validate --strict
pmem config test --verbose

Statistics

pmem stats --user-id user123

Management

pmem manage backup --output backup.json
pmem manage restore --input backup.json --dry-run
pmem manage cleanup --threshold 0.1 --dry-run

Interactive mode

pmem interactive

Shell completion

pmem --install-completion bash

@Teingi

Teingi commented Jan 31, 2026

Copy link
Copy Markdown
Member

Got it. Reviewing now.

@Teingi Teingi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Teingi Teingi merged commit aeac976 into oceanbase:main Jan 31, 2026
15 of 16 checks passed
@Teingi Teingi self-assigned this Feb 10, 2026
@Teingi Teingi added this to the v1.0.0 milestone Feb 10, 2026
@Teingi Teingi added this to PowerMem Feb 10, 2026
@github-project-automation github-project-automation Bot moved this to Done in PowerMem Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Feature]: Command-Line Interface (CLI) Tool

2 participants