nnly055

PHP Agent — AI skill for Claude Code

AI community

纯 PHP 实现的 coding agent:LLM 流式对话 + 工具调用循环 + 插件化持久化/权限/审计 + 本地 SSE 服务(对标 opencode / Claude Code 核心机制).

How to install PHP Agent

This entry records only its repository, not the path inside it, so there is no exact command to give. Open nnly055/php-agent and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What PHP Agent does

纯 PHP 实现的 coding agent:LLM 流式对话 + 工具调用循环 + 插件化持久化/权限/审计 + 本地 SSE 服务(对标 opencode / Claude Code 核心机制).

Alternatives in AI

  • Graphify — AI coding assistant skill (Claude Code, Codex, OpenCode, OpenClaw, Factory Droid, Trae) 20.9k ★
  • Desktop Cc Gui — Multi-engine AI coding desktop client (Tauri) 4.4k ★
  • PaiAgent — 🔥轻量级的AI工作流编排系统,类似dify、n8n,全程使用Vibe Coding,AI工具为Qoder+CLI 698 ★

README

PHP Agent

[![CI](https://github.com/nnly055/php-agent/actions/workflows/ci.yml/badge.svg)](https://github.com/nnly055/php-agent/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

用纯 PHP 实现的 coding agent(对标 opencode / Claude Code 的核心机制): **LLM 流式对话 + 工具调用循环 + 插件化持久化 + 本地 SSE 服务**。

  • 终端交互:php bin/agent,流式输出、彩色工具调用展示
  • 本地服务:php bin/server,内置 Web 聊天页,为将来接入 Tauri/Electron 桌面壳提供 HTTP+SSE 接口
  • 多 Provider:Anthropic 原生协议 + OpenAI 兼容协议(覆盖 GLM / DeepSeek / Kimi / Qwen / OpenAI)
  • 零框架:核心代码仅依赖 curl(Fiber 流式)与 ReactPHP(本地服务)

环境要求

  • PHP ≥ 8.1(需 curl、json、mbstring 扩展)
  • Composer

快速开始

cd php-agent

# 1. 安装依赖
composer install

# 2. 配置 provider(参考 .env.example,任选一个 preset)
cp .env.example .env
# 编辑 .env:AGENT_API_KEY + AGENT_BASE_URL + AGENT_MODEL

# 3a. 离线体验(不需要 API key,走内置演示脚本)
php bin/agent --fake

# 3b. 真实对话
php bin/agent

# 3c. 本地服务 + 网页聊天
php bin/server
# 打开 http://127.0.0.1:8091

支持的 Provider preset

Provider AGENT_PROVIDER AGENT_BASE_URL AGENT_MODEL 示例
智谱 GLM openai https://open.bigmodel.cn/api/paas/v4 glm-4.6
DeepSeek openai https://api.deepseek.com/v1 deepseek-chat
Kimi openai https://api.moonshot.cn/v1 kimi-k2-0905-preview
OpenAI openai https://api.openai.com/v1 gpt-4o
Anthropic anthropic https://api.anthropic.com claude-sonnet-4-5

CLI 命令

命令 说明
/help 帮助(列出全部命令,含插件注册的)
/tools 列出已注册工具
/plugins 已加载插件 + 当前会话存储 + provider
/sessions 列出最近会话
/resume [id] 恢复会话(无参数=最近一个)
/new 开启新会话
/reset 清空当前会话历史
/exit 退出(Ctrl+D 同效)

会话在每轮任务结束后自动保存;CLI 重进 `/resume` 续聊,server 重启不丢会话。

权限模式与审计

AGENT_PERMISSIONS=ask   # 默认:write_file/run_command 执行前 CLI 确认 [Y/n/a],
                        # a=本次会话总是允许;只读工具(read_file/list_dir/grep)自动放行;
                        # 非交互终端自动拒绝
AGENT_PERMISSIONS=off   # 全部放行
AGENT_