adachsoft / code-graph-tool
AI tool adapter for adachsoft/ai-tool-call SPI providing source code architecture graph extraction based on adachsoft/code-graph-contract.
Requires
- php: ^8.3
- adachsoft/ai-tool-call: ^2.1.0
- adachsoft/code-graph-contract: ^0.1.0
- adachsoft/sandbox-contracts: ^0.1.0
Requires (Dev)
- adachsoft/php-code-style: ^0.7.1
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^12.0 || ^13.0
- rector/rector: ^2.8
- symplify/phpstan-rules: ^14.9
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-04 09:04:34 UTC
README
adachsoft/code-graph-tool is an AI tool adapter for adachsoft/ai-tool-call. It exposes source-code architecture graph extraction through the adachsoft/code-graph-contract interfaces.
Requirements
- PHP 8.3 or later.
- A host-provided implementation of
AdachSoft\CodeGraphContract\Contract\GraphExtractorInterface.
Installation
composer require adachsoft/code-graph-tool
Integration
Provide a graph extractor implementation and create the tool with the project root as its sandbox base path:
use AdachSoft\AiToolCall\SPI\Collection\ConfigMap;
use AdachSoft\CodeGraphContract\Contract\GraphExtractorInterface;
use AdachSoft\CodeGraphTool\Factory\CodeGraphToolFactory;
/** @var GraphExtractorInterface $graphExtractor Provided by the host application. */
$factory = new CodeGraphToolFactory($graphExtractor);
$tool = $factory->create(new ConfigMap([
'base_path' => '/path/to/project',
]));
// Register $tool with the host application's ai-tool-call runtime.
See the basic usage example for a complete tool-call request.
Tool parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
path | string | Yes | — | Relative path to a file or directory inside the configured sandbox. |
format | string | No | mermaid-modules | One of mermaid-modules, mermaid-classes, or json. |
exclude_vendor | boolean | No | true | Exclude external vendor dependencies from graph edges. |
target_module | string | No | — | Optional module filter for diagram exports. |
The tool returns a result map containing format, nodes_count, edges_count, output, and output_truncated.
Path isolation and errors
The configured base_path is the sandbox root. Request paths are resolved within that root; a path that escapes the sandbox raises SandboxEscapeException. Invalid parameters raise CodeGraphToolValidationException, while graph extraction or export failures raise CodeGraphToolExecutionException.
License
This package is licensed under the MIT License. See LICENSE.