Skip to content

Latest commit

 

History

History
63 lines (48 loc) · 2.85 KB

File metadata and controls

63 lines (48 loc) · 2.85 KB

AGENTS.md — CLI Abilities Bridge

Project Overview

WordPress plugin that exposes WP-CLI as a single ability via the WordPress Abilities API. AI agents pass commands as plain text strings — the same way they would use bash — instead of parsing hundreds of individual tool definitions. Works on both single-site and multisite WordPress installations.

Build Commands

# No build step — plain PHP plugin with no compiled assets or Composer dependencies

Project Structure

cli-abilities-bridge/
├── cli-abilities-bridge.php       # Plugin entry point (bootstraps on plugins_loaded)
├── inc/
│   ├── class-wp-cli-abilities.php     # Registers single wp-cli/execute ability
│   ├── class-command-executor.php     # Tokenizes + executes commands via array-based proc_open
│   ├── class-command-cache.php        # Blocklist for dangerous commands
│   ├── class-command-permissions.php  # Per-command permission classification (read/write/destructive)
│   ├── class-system-commands.php      # System CLI commands (whois, dig, curl, etc.)
│   └── class-system-executor.php      # System command execution with timeout + SSRF protection
├── composer.json
└── readme.txt

Code Style & Conventions

  • PHP version: >= 7.4
  • WordPress Coding Standards: tabs for indentation, snake_case functions, Yoda conditions
  • File naming: class-{name}.php pattern in inc/
  • No autoloader: Files are manually require_once'd in the main plugin file
  • Text domain: cli-abilities-bridge
  • Single-site and multisite: Works on both; multisite context (--url) is added automatically when relevant

Key Patterns

  • Singleton pattern via get_instance() on main classes
  • Hooks into plugins_loaded — bails early if wp_register_ability() doesn't exist
  • Classes use WordPress-style naming (underscored, not namespaced)
  • Constants defined with CLI_ABILITIES_BRIDGE_DIR prefix
  • Array-based proc_open for WP-CLI execution (bypasses shell — no injection risk)
  • Command string tokenizer handles single/double quotes and backslash escaping

Local Development Environment

The shared WordPress dev install for testing this plugin is at ../wordpress (relative to this repo root).

WP-CLI is configured via wp-cli.yml in this repo root — run wp commands directly from here without specifying --path.

wp plugin activate $(basename $PWD)   # activate this plugin
wp plugin deactivate $(basename $PWD) # deactivate
wp db reset --yes && cd ../wordpress && ./reset.sh  # full reset