Skip to content

Contributing

Harish Dhanraj Sugandhi edited this page Mar 4, 2026 · 1 revision

Contributing

Development Setup

Prerequisites

  • WordPress 6.9+ development environment
  • PHP 7.4+
  • Node.js 18+ and npm
  • Composer

Installation

# Clone the repository
git clone https://github.com/earth9890/openwp-agent.git
cd openwp-agent

# Install PHP dependencies
composer install

# Install Node dependencies
npm install

Development Build

# Start development server with hot reload
npm run start

# Production build
npm run build

Build Commands

Command Description
npm run start Dev build with hot reload (wp-scripts)
npm run build Production build
npm run lint:js Lint JavaScript (wp-scripts lint-js)
npm run lint:css Lint CSS (wp-scripts lint-style)
npm run format Format JS source files
composer test Run PHPUnit tests

Internationalization

npm run i18n         # Generate .pot file
npm run i18n:po      # Update .po translations
npm run i18n:mo      # Compile .mo files
npm run i18n:json    # Generate JSON translations for JS

Code Standards

PHP

  • PSR-4 autoloading under OpenWP\Inc\ namespace
  • WordPress Coding Standards (WPCS) compliance
  • PHPStan for static analysis
  • PHPCS security audit sniffs

JavaScript

  • WordPress script linting rules
  • React best practices
  • Tailwind CSS utility classes

Architecture Patterns

Adding a New Action

  1. Create handler class in inc/Actions/:
namespace OpenWP\Inc\Actions;

class My_Actions {
    public static function my_action($params, $context) {
        // Implementation
        return ['result' => 'value'];
    }
}
  1. Register in Action_Bootstrap (inc/Core/Action_Bootstrap.php):
$this->register(
    'my_action',
    [My_Actions::class, 'my_action'],
    'edit_posts',         // capability
    'low',                // risk level
    true,                 // mutates
    false,                // requires backup
    [                     // input schema
        'required' => ['param1'],
        'properties' => [
            'param1' => ['type' => 'string'],
        ],
    ],
    'openwp/my-category', // category
    [                      // output schema
        'type' => 'object',
        'properties' => ['result' => ['type' => 'string']],
    ]
);

Adding an MCP Tool Module

  1. Create module class implementing ToolModuleInterface:
namespace OpenWP\Inc\MCP\Modules;

class MyTools implements ToolModuleInterface {
    public function tools(): array {
        return [
            [
                'name' => 'my_tool',
                'description' => 'Does something',
                'inputSchema' => [...],
                'accessLevel' => 'read',  // read|write|admin
            ],
        ];
    }

    public function call(string $name, array $args): array {
        // Implementation
    }
}
  1. Register in Tool_Registry

Singleton Pattern

All service classes use the Get_Instance trait:

use OpenWP\Inc\Traits\Get_Instance;

class MyService {
    use Get_Instance;

    private function __construct() {
        // initialization
    }
}

Directory Map

Directory Namespace Purpose
inc/Actions/ OpenWP\Inc\Actions Action handlers
inc/Agent/ OpenWP\Inc\Agent LLM orchestration
inc/API/ OpenWP\Inc\API REST controllers
inc/Backup/ OpenWP\Inc\Backup Backup service
inc/Core/ OpenWP\Inc\Core Bootstrap + settings
inc/Database/ OpenWP\Inc\Database Migrations + tables
inc/Logs/ OpenWP\Inc\Logs Audit + approvals
inc/MCP/ OpenWP\Inc\MCP MCP server
inc/Memory/ OpenWP\Inc\Memory Agent memory
inc/Providers/ OpenWP\Inc\Providers LLM clients
inc/Security/ OpenWP\Inc\Security Security layer

Testing

# Run PHPUnit tests
composer test

Release Process

The project uses Grunt for release automation:

  • grunt-bumpup - Version bumping
  • grunt-contrib-clean - Clean build artifacts
  • grunt-contrib-copy - Copy files to release directory
  • grunt-contrib-compress - Create ZIP archive
  • grunt-rtlcss - Generate RTL stylesheets

Clone this wiki locally