Search by

adachsoft / code-graph-tool

Arkadiusz Adach

AI tool adapter for adachsoft/ai-tool-call SPI providing source code architecture graph extraction based on adachsoft/code-graph-contract.

Package info

gitlab.com/a.adach/code-graph-tool

Issues

pkg:composer/adachsoft/code-graph-tool

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-11-03 11:28 UTC

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

ParameterTypeRequiredDefaultDescription
pathstringYes—Relative path to a file or directory inside the configured sandbox.
formatstringNomermaid-modulesOne of mermaid-modules, mermaid-classes, or json.
exclude_vendorbooleanNotrueExclude external vendor dependencies from graph edges.
target_modulestringNo—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.