Skip to main content

AI-powered WordPress content management framework with precision editing

Project description

PraisonAI WPcli

AI-powered WordPress CLI tool for content management with precision editing capabilities.

Features

Core Features

  • ๐Ÿš€ Simple CLI - Intuitive commands with helpful prompts
  • โšก Fast - Auto-parallel mode for bulk operations (10x faster)
  • ๐ŸŽฏ Precise - Line-specific and occurrence-specific text replacements
  • ๐Ÿ”’ Safe - Auto-backup, preview mode, dry-run capabilities
  • ๐ŸŒ Multi-Server - Manage multiple WordPress installations
  • ๐Ÿ“ Smart - Auto-detects file formats and optimal settings

New in v1.0.5 ๐ŸŽ‰

  • ๐Ÿ“‚ Category Management - Full category support: set, add, remove, list, and search post categories
  • ๐Ÿ”— SSH Config Integration - Use ssh_host to reference ~/.ssh/config hosts directly in config.yaml
  • โœจ Enhanced Create/Update - Add --category and --category-id options to create and update commands

Previous Updates (v1.0.2)

  • ๐Ÿ”‘ SSH Config Support - Use ~/.ssh/config host aliases for simplified connection management
  • ๐Ÿ”ง WP-CLI Auto-Installer - One-command WP-CLI installation with automatic OS detection (Ubuntu, Debian, CentOS, RHEL, Fedora, Alpine, macOS)
  • ๐Ÿ” WordPress Auto-Detection - Automatically find WordPress installations on your server with multiple search strategies
  • โšก UV Package Manager - 10-100x faster dependency management with modern tooling
  • ๐Ÿ›ก๏ธ Enhanced Error Handling - Helpful error messages with installation instructions and troubleshooting
  • ๐Ÿ“Š Installation Verification - Automatic checks for WP-CLI and WordPress validity on startup

Installation

Using uv (Recommended - 10x faster!)

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone and install
git clone https://github.com/MervinPraison/PraisonAI-WPcli.git
cd PraisonAI-WPcli
uv sync

# Run commands
uv run praisonaiwp init

Using pip

pip install praisonaiwp

# Or install from source
git clone https://github.com/MervinPraison/PraisonAI-WPcli.git
cd PraisonAI-WPcli
pip install -e .

Quick Start

1. Initialize Configuration

praisonaiwp init

๐Ÿ’ก Pro Tips:

  • Use SSH config alias (e.g., wp-prod) - connection details loaded automatically!
  • Press Enter for WordPress path - auto-detection will find it for you
  • PHP binary is auto-detected, or specify for Plesk: /opt/plesk/php/8.3/bin/php

๐Ÿ”‘ SSH Config Support:

PraisonAIWP automatically reads from ~/.ssh/config. If you have multiple hosts configured:

# ~/.ssh/config
Host wp-prod
    HostName production.example.com
    User prod_user
    IdentityFile ~/.ssh/id_prod

Host wp-staging
    HostName staging.example.com
    User staging_user
    IdentityFile ~/.ssh/id_staging

Host wp-dev
    HostName localhost
    User dev_user
    Port 2222
    IdentityFile ~/.ssh/id_dev

Just enter the host alias (e.g., wp-prod, wp-staging, or wp-dev) when prompted for hostname, and PraisonAIWP will automatically load all connection details from your SSH config!

Choosing Between Multiple Configs:

  • Each host alias is independent

  • Use --server flag to specify which server to use:

    praisonaiwp create "Post" --server production
    praisonaiwp create "Post" --server staging
    
  • Configure multiple servers in ~/.praisonaiwp/config.yaml:

    servers:
      # Method 1: Using ssh_host (recommended)
      production:
        ssh_host: wp-prod  # Reference SSH config host
        wp_path: /var/www/html
        wp_cli: /usr/local/bin/wp
      
      # Method 2: Direct specification (traditional)
      staging:
        hostname: staging.example.com
        username: staging_user
        key_file: ~/.ssh/id_staging
        port: 22
        wp_path: /var/www/staging
        wp_cli: /usr/local/bin/wp
      
      # Method 3: Mix both (direct values override ssh_host)
      dev:
        ssh_host: wp-dev
        username: custom_user  # Override SSH config username
        wp_path: /var/www/dev
        wp_cli: /usr/local/bin/wp
    

    New in v1.0.5: Use ssh_host to reference SSH config hosts! Connection details (hostname, username, key_file, port) are automatically loaded from ~/.ssh/config. You can also specify connection details directly (traditional method) or mix both approaches - direct values always take precedence.

This will prompt you for:

  • Server hostname - Can be IP, hostname, or SSH config alias (e.g., wp-prod)
  • SSH username - Auto-loaded from SSH config if using alias
  • SSH key path - Auto-loaded from SSH config if using alias
  • WordPress path - Press Enter to auto-detect, or specify manually
  • PHP binary - Auto-detected, or specify custom path

2. Auto-Install WP-CLI (Optional)

If WP-CLI is not installed on your server:

# Automatically detect OS and install WP-CLI
praisonaiwp install-wp-cli -y

# Install with dependencies (curl, php)
praisonaiwp install-wp-cli --install-deps -y

# Custom installation path
praisonaiwp install-wp-cli --install-path /usr/bin/wp

# For Plesk servers
praisonaiwp install-wp-cli --php-bin /opt/plesk/php/8.3/bin/php -y

Supported Operating Systems:

  • โœ… Ubuntu (18.04, 20.04, 22.04, 24.04)
  • โœ… Debian (9, 10, 11, 12)
  • โœ… CentOS (7, 8, 9)
  • โœ… RHEL (7, 8, 9)
  • โœ… Fedora (35+)
  • โœ… Alpine Linux
  • โœ… macOS (with Homebrew)

What it does:

  1. Detects your server's operating system
  2. Downloads WP-CLI from official source
  3. Tests the download
  4. Makes it executable
  5. Installs to system path
  6. Verifies installation
  7. Updates your config automatically

3. Auto-Detect WordPress (Optional)

If you don't know your WordPress installation path:

# Find all WordPress installations
praisonaiwp find-wordpress

# Interactive selection from multiple installations
praisonaiwp find-wordpress --interactive

# Find and update config automatically
praisonaiwp find-wordpress --update-config

# Find on different server
praisonaiwp find-wordpress --server staging

Search Strategies:

  • Searches for wp-config.php in common directories
  • Checks predefined paths (/var/www/html, /var/www/vhosts/*/httpdocs, etc.)
  • Verifies each installation (wp-config, wp-content, wp-includes)
  • Extracts WordPress version
  • Interactive selection for multiple installations

Example Output:

โœ“ Found 2 WordPress installation(s)

โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ # โ”ƒ Path                                โ”ƒ Version โ”ƒ Components              โ”ƒ
โ”กโ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ 1 โ”‚ /var/www/html                       โ”‚ 6.4.2   โ”‚ config, content, includesโ”‚
โ”‚ 2 โ”‚ /var/www/vhosts/example.com/httpdocsโ”‚ 6.3.1   โ”‚ config, content, includesโ”‚
โ””โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

4. Create Posts

# Single post
praisonaiwp create "My Post Title" --content "Post content here"

# From file (auto-detects JSON/YAML/CSV)
praisonaiwp create posts.json

# Create 100 posts (automatically uses parallel mode!)
praisonaiwp create 100_posts.json

5. Update Posts

# Update all occurrences
praisonaiwp update 123 "old text" "new text"

# Update specific line only
praisonaiwp update 123 "old text" "new text" --line 10

# Update 2nd occurrence only
praisonaiwp update 123 "old text" "new text" --nth 2

# Preview changes first
praisonaiwp update 123 "old text" "new text" --preview

6. Find Text

# Find in specific post
praisonaiwp find "search text" 123

# Find across all posts
praisonaiwp find "search text"

# Find in pages
praisonaiwp find "search text" --type page

7. List Posts

# List all posts
praisonaiwp list

# List pages
praisonaiwp list --type page

# List drafts
praisonaiwp list --status draft

8. Manage Categories

# List all categories
praisonaiwp category list

# Search for categories
praisonaiwp category search "Technology"

# List categories for a specific post
praisonaiwp category list 123

# Set categories (replace all)
praisonaiwp category set 123 --category "Tech,AI"

# Add categories (append)
praisonaiwp category add 123 --category "Python"

# Remove categories
praisonaiwp category remove 123 --category "Uncategorized"

# Create post with categories
praisonaiwp create "My Post" --content "Hello" --category "Tech,AI"

# Update post categories
praisonaiwp update 123 --category "Tech,Python"

File Formats

JSON Format

[
  {
    "title": "Post Title",
    "content": "<p>Post content</p>",
    "status": "publish",
    "type": "post"
  }
]

YAML Format

- title: Post Title
  content: <p>Post content</p>
  status: publish
  type: post

CSV Format

title,content,status,type
"Post Title","<p>Post content</p>",publish,post

Configuration

Configuration is stored in ~/.praisonaiwp/config.yaml:

version: "1.0"
default_server: default

servers:
  default:
    hostname: example.com
    username: user
    key_file: ~/.ssh/id_ed25519
    port: 22
    wp_path: /var/www/html
    php_bin: /opt/plesk/php/8.3/bin/php
    wp_cli: /usr/local/bin/wp

settings:
  auto_backup: true
  parallel_threshold: 10
  parallel_workers: 10
  ssh_timeout: 30
  log_level: INFO

Advanced Usage

Line-Specific Replacement

When the same text appears multiple times but you only want to replace it at a specific line:

# Replace only at line 10
praisonaiwp update 123 "Welcome" "My Website" --line 10

Occurrence-Specific Replacement

Replace only the 1st, 2nd, or nth occurrence:

# Replace only the 2nd occurrence
praisonaiwp update 123 "Welcome" "My Website" --nth 2

Bulk Operations

Create 100 posts in ~8 seconds (vs 50+ seconds sequential):

# Automatically uses parallel mode for files with >10 posts
praisonaiwp create 100_posts.json

Troubleshooting

SSH Connection Issues

# Test SSH connection manually
ssh -i ~/.ssh/id_ed25519 user@hostname

# Fix key permissions
chmod 600 ~/.ssh/id_ed25519
chmod 600 ~/.ssh/config

WP-CLI Not Found

# Install WP-CLI automatically
praisonaiwp install-wp-cli -y

# Or check WP-CLI path manually
ssh user@hostname "which wp"

PHP MySQL Extension Missing

# Use Plesk PHP binary (edit config.yaml)
php_bin: /opt/plesk/php/8.3/bin/php

WordPress Path Not Found

# Auto-detect WordPress installation
praisonaiwp find-wordpress --update-config

Documentation

Development

# Clone repository
git clone https://github.com/MervinPraison/PraisonAI-WPcli.git
cd PraisonAI-WPcli

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Run with coverage
pytest --cov=praisonaiwp

# Format code
black praisonaiwp/

# Lint
flake8 praisonaiwp/

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

Author

Praison

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

praisonaiwp-1.0.10.tar.gz (57.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

praisonaiwp-1.0.10-py3-none-any.whl (46.5 kB view details)

Uploaded Python 3

File details

Details for the file praisonaiwp-1.0.10.tar.gz.

File metadata

  • Download URL: praisonaiwp-1.0.10.tar.gz
  • Upload date:
  • Size: 57.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for praisonaiwp-1.0.10.tar.gz
Algorithm Hash digest
SHA256 e0de154949503f5fd8ff2be90976f324359a80906712721db8d599f89a33e32a
MD5 87520653c4a27ea6b33492110db3335d
BLAKE2b-256 f4312afeb8c81d28f128613f9d524bf8d502f2cacfd0477fa32944c50bb17c84

See more details on using hashes here.

File details

Details for the file praisonaiwp-1.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for praisonaiwp-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 fae80b3eb0d51edc83f0cba2e0dcfd6d5a12a5dcd831bf0485937d74ccec95cc
MD5 d39b4bd5cf6174f4cdeab8cba07f4918
BLAKE2b-256 f033db433a47977ce38d974d87600e8ce863fb9a4c105a71761a17d13945c4fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page