adachsoft / file-edit-tool
AI tool SPI implementations for safe file fragment and line-range editing.
v0.1.0
2026-11-23 10:01 UTC
Requires
- php: >=8.3
- adachsoft/ai-tool-call: ^2.0
- adachsoft/collection: ^3.0
- adachsoft/file-tool-security-policy: ^1.0
- adachsoft/text-editor: ^0.1.0
Requires (Dev)
- adachsoft/php-code-style: ^0.7.3
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^12.4
- rector/rector: ^2.8
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-23 09:02:07 UTC
README
A PHP library that provides AI tool SPI implementations for editing files within a configured directory. It offers exact-fragment replacement and one-based line-range replacement, with path, extension, and file-pattern restrictions applied before file access.
Features
- Replace one or all occurrences of an exact text fragment.
- Replace an inclusive range of lines with new content.
- Restrict access to a base directory and configure allowed or denied extensions and paths.
- Return structured per-file results for tool calls.
Installation
composer require adachsoft/file-edit-tool
Requirements
- PHP 8.3 or later.
- Composer.
Usage
Create a tool using its factory and configure a base directory. The tool accepts paths relative to that directory; configure only directories and file patterns that the tool is permitted to edit.
use AdachSoft\AiToolCall\SPI\Collection\ConfigMap;
use AdachSoft\FileEditTool\Factory\FileEditFragmentToolFactory;
$tool = (new FileEditFragmentToolFactory())->create(new ConfigMap([
'base_dir' => __DIR__ . '/workspace',
'allow_extensions' => ['md', 'txt'],
]));
See the usage examples for fragment and line-range calls.