定制 freelygive/ai-diff 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

freelygive/ai-diff

最新稳定版本:1.0.0-beta2

Composer 安装命令:

composer require freelygive/ai-diff

包简介

A package to support AI generated code diffs, inspired by Aider's edit formats.

README 文档

README

A PHP library for parsing and applying AI friendly diffs. Inspired by Aider edit formats.

Features

  • Parse and validate a diff
  • Apply a parsed diff to original content

Supported diffs

Installation

composer require freelyive/ai-diff

Usage

use FreelyGive\AiDiff\Format\Udiff;

$diff = (new Udiff())->parse($diff_from_ai);

// Handle new files.
if ($diff->from === NULL) {
  add_file(
    filename: $diff->to, 
    contents: $diff->chunks[0]->getAfter(),
  );
}
// Handle removed files.
elseif ($diff->to === NULL) {
  remove_file(
    filename: $diff->from,
  );
}
// Handle updating files.
else {
  update_file(
    filename: $diff->from,
    new_filename: $diff->to,
    content: $diff->applyTo($original_content),
  );
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2025-06-13