adachsoft / file-content-tool
Secure AI tools for byte-range and line-range file reading and contextual file search.
Requires
- php: ^8.3
- adachsoft/ai-tool-call: ^1.0 || ^2.0
- adachsoft/collection: ^3.0
- adachsoft/file-tool-security-policy: ^1.0
- adachsoft/normalized-safe-path: ^0.1 || ^0.2
- adachsoft/text-search: ^0.2.0
Requires (Dev)
- adachsoft/php-code-style: ^0.7.3
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^12.5
- 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 08:35:50 UTC
README
adachsoft/file-content-tool provides AI tool adapters for controlled file access. Applications can read bounded byte ranges, read selected lines, and search file contents with contextual matches.
Requirements
The library requires PHP and Composer dependencies declared in composer.json.
Capabilities
- Read a bounded byte range or an inclusive, one-based line range.
- Search file contents using plain text, case-sensitive text, regular expressions, or similarity matching.
- Return match text, offsets, line and column positions, and surrounding context.
- Authorize file access through
adachsoft/file-tool-security-policybefore file I/O.
Search matching and context calculation are provided by adachsoft/text-search. File search rejects files larger than the configured limit, which defaults to 1 MiB.
Installation
composer require adachsoft/file-content-tool
Usage
Create tools through FileReadRangeToolFactory, FileReadLinesToolFactory, or FileSearchInFileToolFactory. Each factory accepts the SPI ConfigMap; configure a base_path and any required file or extension policies before registering the tool with your AI tool-call integration.
See the integration example for a factory setup and the tool request format.
The factories are the intended construction API. Request, result, handler, validator, serializer, and support classes are implementation details.