Search by

adachsoft / file-edit-tool

Arkadiusz Adach

AI tool SPI implementations for safe file fragment and line-range editing.

Package info

gitlab.com/a.adach/file-edit-tool

Issues

pkg:composer/adachsoft/file-edit-tool

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-11-23 10:01 UTC

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.