matesofmate / rector-extension
Rector extension for Symfony AI Mate providing inspect, dry-run preview, and apply workflows
Package info
github.com/MatesOfMate/rector-extension
Type:symfony-ai-mate
pkg:composer/matesofmate/rector-extension
Requires
- php: >=8.2
- matesofmate/common: ^0.3 || ^0.4@dev
- symfony/ai-mate: ^0.11 || dev-main
- symfony/process: ^6.4|^7.0|^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^10.0
- rector/rector: ^2.0
Suggests
- helgesverre/toon: Install for TOON-encoded MCP responses; JSON remains the fallback when it is not available
This package is auto-updated.
Last update: 2026-08-15 21:14:48 UTC
README
Rector refactoring tools for AI assistants. This package inspects project-local Rector setup, previews changes in dry-run mode, and applies refactors through a dedicated write-capable tool.
Features
- inspect project-local Rector installation, configuration, and Composer scripts
- preview Rector changes with
--dry-runenforced - encoded output with three consistent detail modes
- dedicated write-capable apply workflow
- custom command support for Docker or wrapper-based setups
Installation
composer require --dev matesofmate/rector-extension vendor/bin/mate init
In current AI Mate setups, extension discovery is handled automatically after Composer install and update. Run vendor/bin/mate discover when you want to refresh discovery artifacts such as mate/AGENT_INSTRUCTIONS.md.
Useful Mate commands:
vendor/bin/mate debug:extensions vendor/bin/mate debug:capabilities vendor/bin/mate mcp:tools:list --extension=matesofmate/rector-extension
Use the generated wrapper for Codex:
./bin/codex
Custom Command Configuration
If Rector must run through Docker or another wrapper command, configure matesofmate_rector.custom_command.
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $container): void { $container->parameters()->set('matesofmate_rector.custom_command', [ 'docker', 'compose', 'exec', 'php', 'vendor/bin/rector', ]); };
Requirements
- PHP 8.2+
- Symfony AI Mate 0.11+ required
- Rector installed in the target project, or
matesofmate_rector.custom_commandconfigured - A Rector configuration such as
rector.php
This extension does not install Rector, generate rector.php, or modify Rector configuration.
Available Tools
rector-inspectrector-previewrector-apply
All tools return encoded strings through Mate's core ResponseEncoder. Install the suggested helgesverre/toon package if you want TOON responses; otherwise the same payload falls back to JSON.
Output Modes
defaultsummarydetailed
Every response reports a status. Rector uses a dedicated exit code to signal that it found
code to change, so a preview that reports pending changes is a SUCCESS with a non-zero
changed_file_count. FAILED means Rector itself could not process the code — parse errors
and similar problems are listed under errors together with error_count.
Safe Workflow
- Run
rector-inspectto confirm the project has Rector and a configuration. - Run
rector-previewto execute Rector with--dry-run. - Review changed files, rule names, diffs, output, and diagnostics.
- Run
rector-applywhen Rector changes should be written.
rector-preview always adds --dry-run and never writes project source files. rector-apply never adds --dry-run; it writes Rector changes and does not run tests, commit changes, stage files, or invoke Rector again afterward.
Development
composer install
composer test
composer lint
composer fix
License
MIT