adachsoft / project-map-tool
AI tool adapter for hierarchical project maps
Requires
- php: ^8.3
- adachsoft/ai-tool-call: ^1.0 || ^2.0
- adachsoft/file-tool-security-policy: ^1.0
- adachsoft/project-map: ^0.1.0
Requires (Dev)
- adachsoft/php-code-style: ^0.8.0
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13.0
- rector/rector: ^2.9
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
project-map-tool is an AI tool adapter for hierarchical project maps. It exposes a bounded, operation-based tool (project_map) that agents can use to read and maintain a structured view of a repository: its modules, components, configuration, tests, and documentation, together with the responsibilities and relationships that matter for a task.
The adapter builds on top of adachsoft/project-map, applies adachsoft/file-tool-security-policy to every file-related operation, and implements the tool SPI defined by adachsoft/ai-tool-call.
Capabilities
- Summary and discovery — check whether a map exists, locate the index, and list available maps.
- Map reading — read a selected map or the whole index as structured data.
- Map maintenance — create or update verified nodes (
upsert_node) and remove obsolete ones (remove_node), with automatic map bootstrapping for new maps. - Validation — validate a single map or all maps after changes.
- Security — every node path is checked against configurable path, extension, and forbidden-pattern policies before any operation touches the file system.
- Operation allowlist — restrict the tool to a subset of operations per agent via configuration.
Supported operations: get_summary, read_index, read_map, upsert_node, remove_node, validate_map, validate_all.
Requirements
- PHP 8.3 or higher.
- Composer for dependency management.
The adapter requires the following Composer packages (resolved automatically):
| Package | Version |
|---|---|
adachsoft/ai-tool-call | ^1.0 \|\| ^2.0 |
adachsoft/file-tool-security-policy | ^1.0 |
adachsoft/project-map | ^0.1.0 |
Installation
composer require adachsoft/project-map-tool
Usage
Create the tool through ProjectMapToolFactory, configure it with your project root, and either register it with your AI tool runtime or invoke it directly with ToolCallRequestDto:
<?php
use AdachSoft\AiToolCall\SPI\Collection\ConfigMap;
use AdachSoft\AiToolCall\SPI\Collection\KeyValueMap;
use AdachSoft\AiToolCall\SPI\Dto\ToolCallRequestDto;
use AdachSoft\ProjectMapTool\Factory\ProjectMapToolFactory;
$factory = new ProjectMapToolFactory();
$tool = $factory->create(new ConfigMap([
'project_base_path' => '/absolute/path/to/project',
]));
// Direct invocation, e.g. reading the project map summary:
$request = new ToolCallRequestDto(
toolName: 'project_map',
parameters: new KeyValueMap(['operation' => 'get_summary']),
);
$result = $tool->callTool($request);
$payload = $result->result->toArray();
See the usage guide for the recommended agent workflow, and examples for integration and direct-invocation samples.
composer require adachsoft/project-map-tool
Integration
Create a configured tool through ProjectMapToolFactory and register it with your AI tool runtime:
<?php
use AdachSoft\AiToolCall\SPI\Collection\ConfigMap;
use AdachSoft\ProjectMapTool\Factory\ProjectMapToolFactory;
$factory = new ProjectMapToolFactory();
$tool = $factory->create(new ConfigMap([
'project_base_path' => '/absolute/path/to/project',
// Defaults:
// 'maps_relative_directory' => 'docs/project-map',
// 'max_description_length' => 400,
// 'allowed_operations' => null, // null allows all operations
]));
Required configuration:
| Key | Type | Description |
|---|---|---|
project_base_path | string | Absolute path to the project root. |
Optional configuration:
| Key | Type | Default | Description |
|---|---|---|---|
maps_relative_directory | string | docs/project-map | Project-relative directory that stores map files. |
allowed_operations | list | null | null (all) | Allowlist of enabled operations. |
max_description_length | int | 400 | Maximum node description length. |
allowed_path_patterns | list | null | null | Path patterns allowed by the security policy. |
forbidden_path_patterns | list | null | null | Path patterns forbidden by the security policy. |
allowed_extensions | list | null | null | File extensions allowed by the security policy. |
forbidden_extensions | list | null | null | File extensions forbidden by the security policy. |
The returned tool implements the AdachSoft\AiToolCall\SPI\ToolInterface contract, so you can register it with any runtime that consumes that SPI:
$toolDefinition = $tool::getDefinition(); // static tool definition for the runtime
Documentation
- Usage guide — recommended agent workflow for working with project maps.
- Examples — integration and direct-invocation examples.
License
MIT