datashaman/laravel-agent-tools 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

datashaman/laravel-agent-tools

Composer 安装命令:

composer require datashaman/laravel-agent-tools

包简介

Claude Code-equivalent tools for laravel/ai agents. Filesystem, shell, task management, and tool discovery.

README 文档

README

Claude Code-equivalent tools for laravel/ai agents. Filesystem, shell, task management, and tool discovery.

Requirements

  • PHP 8.3+
  • Laravel 12+ or 13+
  • laravel/ai ^0.3

Installation

composer require datashaman/laravel-agent-tools

The service provider is auto-discovered. To publish the config:

php artisan vendor:publish --tag=laravel-agent-config

For the database task store, publish and run the migration:

php artisan vendor:publish --tag=laravel-agent-migrations
php artisan migrate

Tools

Filesystem

Tool Description
ReadFile Read file contents with line numbers, offset/limit, binary detection
WriteFile Create or overwrite files with automatic parent directory creation
EditFile Exact string replacement with uniqueness validation and fuzzy-match error suggestions
GlobFiles Find files by glob pattern, sorted by modification time
GrepFiles Search file contents with regex, multiple output modes, context lines, filtering

Execution

Tool Description
RunCommand Execute shell commands with sync, async, or queued modes. Supports timeout, idle timeout, and command allow/deny lists

Task Management

Tool Description
TaskCreate Create a new task
TaskGet Retrieve task details by ID
TaskList List tasks with optional status filtering
TaskOutput Get output from a background task
TaskStop Kill a running background task
TaskUpdate Update task properties or delete a task
TodoWrite Batch-manage the full task list (sugar over individual task tools)

Meta

Tool Description
ToolSearch Discover and load deferred tools from a ToolRegistry

Usage

All tools implement Laravel\Ai\Contracts\Tool and work with any laravel/ai agent:

use DataShaman\LaravelAgent\Tools\Filesystem\ReadFile;
use DataShaman\LaravelAgent\Tools\Filesystem\WriteFile;
use DataShaman\LaravelAgent\Tools\Filesystem\EditFile;
use DataShaman\LaravelAgent\Tools\Filesystem\GlobFiles;
use DataShaman\LaravelAgent\Tools\Filesystem\GrepFiles;
use DataShaman\LaravelAgent\Tools\Execution\RunCommand;
use Laravel\Ai\Contracts\Agent;
use Laravel\Ai\Contracts\HasTools;
use Laravel\Ai\Promptable;

class CodeAssistant implements Agent, HasTools
{
    use Promptable;

    public function __construct(
        private string $projectPath,
    ) {}

    public function instructions(): string
    {
        return 'You are a code assistant with full filesystem and shell access.';
    }

    public function tools(): iterable
    {
        return [
            new ReadFile(basePath: $this->projectPath),
            new WriteFile(basePath: $this->projectPath),
            new EditFile(basePath: $this->projectPath),
            new GlobFiles(basePath: $this->projectPath),
            new GrepFiles(basePath: $this->projectPath),
            new RunCommand(
                basePath: $this->projectPath,
                timeout: 30,
                allow: ['git *', 'composer *', 'php *'],
                deny: ['rm -rf *', 'sudo *'],
            ),
        ];
    }
}

Task Management

use DataShaman\LaravelAgent\Support\InMemoryTaskStore;
use DataShaman\LaravelAgent\Tools\Tasks\TaskCreate;
use DataShaman\LaravelAgent\Tools\Tasks\TaskList;
use DataShaman\LaravelAgent\Tools\Tasks\TaskUpdate;

$store = new InMemoryTaskStore;

$tools = [
    new TaskCreate($store),
    new TaskList($store),
    new TaskUpdate($store),
    // ... other tools
];

Tool Discovery

Start with a minimal tool set and let the agent discover more at runtime:

use DataShaman\LaravelAgent\Support\ToolRegistry;
use DataShaman\LaravelAgent\Tools\Meta\ToolSearch;

$registry = new ToolRegistry([
    new ReadFile(basePath: $path),
    new WriteFile(basePath: $path),
    new EditFile(basePath: $path),
    new GlobFiles(basePath: $path),
    new GrepFiles(basePath: $path),
    new RunCommand(basePath: $path),
]);

// Agent starts with just ReadFile, GlobFiles, and ToolSearch
$tools = [
    new ReadFile(basePath: $path),
    new GlobFiles(basePath: $path),
    new ToolSearch($registry),
];

Background Commands

use DataShaman\LaravelAgent\Support\InMemoryTaskStore;
use DataShaman\LaravelAgent\Support\ProcessManager;
use DataShaman\LaravelAgent\Tools\Execution\RunCommand;

$store = new InMemoryTaskStore;
$processManager = new ProcessManager($store);

// Async: background process via Laravel Process::start()
$tool = new RunCommand(
    basePath: $path,
    executor: 'async',
    taskStore: $store,
    processManager: $processManager,
);

// Queued: dispatched as a Laravel job
$tool = new RunCommand(
    basePath: $path,
    executor: 'queued',
    taskStore: $store,
);

Configuration

All tools are configured via constructor parameters. No global config required.

The config/laravel-agent.php file provides defaults for the service provider bindings:

Key Default Description
task_store memory Task store driver: memory, cache, database
executor async RunCommand background executor: sync, async, queued
cache.store null Cache store for CacheTaskStore
cache.prefix laravel-agent:tasks: Cache key prefix
cache.ttl 3600 Cache TTL in seconds
database.connection null Database connection for DatabaseTaskStore
database.table agent_tasks Table name for DatabaseTaskStore

Sandboxing

All filesystem and execution tools accept a basePath parameter that restricts operations to that directory. Paths outside basePath are rejected.

RunCommand additionally supports allow and deny glob patterns for command filtering. Deny takes precedence over allow.

Custom Descriptions

Every tool ships with Claude Code-quality descriptions that guide LLM behavior. Override them per-instance:

new EditFile(
    basePath: $path,
    description: 'Edit files. No restrictions.',
)

Testing

composer test

Or directly:

vendor/bin/phpunit

License

MIT

datashaman/laravel-agent-tools 适用场景与选型建议

datashaman/laravel-agent-tools 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「tools」 「laravel」 「Agent」 「ai」 「claude」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 datashaman/laravel-agent-tools 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 datashaman/laravel-agent-tools 我们能提供哪些服务?
定制开发 / 二次开发

基于 datashaman/laravel-agent-tools 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 31
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-25