承接 coquibot/coqui-toolkit-code-edit 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

coquibot/coqui-toolkit-code-edit

Composer 安装命令:

composer require coquibot/coqui-toolkit-code-edit

包简介

Surgical file editing toolkit for Coqui — replace, insert, remove, indent, batch operations with undo history

README 文档

README

Surgical file editing toolkit for Coqui. Provides precise, token-efficient code editing operations with full undo history — replace, insert, remove, indent, batch operations, all sandboxed to the workspace.

Requirements

  • PHP 8.4+
  • Coqui (auto-discovered via Composer)

Installation

composer require coquibot/coqui-toolkit-code-edit

When installed alongside Coqui, the toolkit is auto-discovered via Composer's extra.php-agents.toolkits — no manual registration needed.

Tools Provided

replace_in_file

Replace text in a file using plain string or PCRE regex matching.

Parameter Type Required Description
path string Yes File path relative to workspace
search string Yes Text or regex pattern to search for
replace string Yes Replacement text (supports backreferences for regex)
is_regex bool No Treat search as PCRE regex (default: false)
flags string No PCRE modifier flags, e.g. "msi"

insert_before

Insert content before lines matching an anchor pattern.

Parameter Type Required Description
path string Yes File path relative to workspace
anchor string Yes Text or regex to match lines against
content string Yes Content to insert before each match
is_regex bool No Treat anchor as PCRE regex (default: false)
occurrences int No Matches to affect: 0=all, 1=first (default: 1)

insert_after

Insert content after lines matching an anchor pattern.

Parameter Type Required Description
path string Yes File path relative to workspace
anchor string Yes Text or regex to match lines against
content string Yes Content to insert after each match
is_regex bool No Treat anchor as PCRE regex (default: false)
occurrences int No Matches to affect: 0=all, 1=first (default: 1)

replace_block

Replace a block of content between start and end markers (inclusive).

Parameter Type Required Description
path string Yes File path relative to workspace
start_marker string Yes Text or regex marking block start
end_marker string Yes Text or regex marking block end
new_content string Yes Content to replace the block with
is_regex bool No Treat markers as PCRE regex (default: false)

remove_lines

Remove a range of lines from a file.

Parameter Type Required Description
path string Yes File path relative to workspace
from int Yes Start line (1-based, inclusive)
to int Yes End line (1-based, inclusive)

extract_lines

Extract a range of lines from a file (read-only, does not modify the file).

Parameter Type Required Description
path string Yes File path relative to workspace
from int Yes Start line (1-based, inclusive)
to int Yes End line (1-based, inclusive)

batch_replace

Run search/replace across multiple files matching a glob pattern.

Parameter Type Required Description
glob string Yes Glob pattern (e.g. "src/**/*.php")
search string Yes Text or regex pattern
replace string Yes Replacement text
is_regex bool No Treat search as PCRE regex (default: false)
flags string No PCRE modifier flags

append_to_file

Append text to the end of a file. Creates the file if it doesn't exist.

Parameter Type Required Description
path string Yes File path relative to workspace
content string Yes Content to append

write_lines

Overwrite a specific range of lines with new content.

Parameter Type Required Description
path string Yes File path relative to workspace
from int Yes Start line (1-based, inclusive)
to int Yes End line (1-based, inclusive)
content string Yes New content (can be more or fewer lines)

indent_lines

Indent or outdent a range of lines.

Parameter Type Required Description
path string Yes File path relative to workspace
from int Yes Start line (1-based, inclusive)
to int Yes End line (1-based, inclusive)
direction enum Yes indent or outdent
size int No Spaces per level (default: 4)
use_tabs bool No Use tabs instead of spaces (default: false)

undo_edit

Undo previous code-edit operations by restoring original file content.

Parameter Type Required Description
edit_id int No Undo a specific edit by ID
file string No File path to undo edits for (with count)
count int No Number of recent edits to undo (default: 1)
list_only bool No List recent edits without undoing (default: false)
prune_days int No Remove backups older than N days

Architecture

src/
├── CodeEditToolkit.php          # Main toolkit — registers all tools
├── Exception/
│   └── CodeEditException.php    # Domain exceptions
├── Storage/
│   └── EditHistory.php          # SQLite edit log + file backups
├── Support/
│   ├── FileOperations.php       # Atomic reads/writes, EOL detection
│   └── PathResolver.php         # Workspace sandbox enforcement
└── Tool/
    ├── AppendToFileTool.php
    ├── BatchReplaceTool.php
    ├── ExtractLinesTool.php
    ├── IndentTool.php
    ├── InsertAfterTool.php
    ├── InsertBeforeTool.php
    ├── RemoveLinesTool.php
    ├── ReplaceBlockTool.php
    ├── ReplaceInFileTool.php
    ├── UndoEditTool.php
    └── WriteLinesTool.php

Key Design Decisions

Decision Rationale
Separate tool classes Each tool has distinct parameter shapes; keeps schemas clean for LLM consumption
Atomic writes (temp + rename) Prevents partial writes from corrupting files on crash
SQLite edit history Lightweight undo with per-edit granularity; auto-prune keeps storage bounded
Path sandboxing via PathResolver All paths validated against workspace root; blocks directory traversal
EOL detection + preservation Maintains CRLF/LF consistency when editing Windows or Unix files
Read-only extract_lines No history overhead for inspection — only mutating ops record history

Notes

  • All paths are relative to the workspace root and sandboxed — directory traversal is blocked.
  • Regex uses PCRE with ~ as delimiter (no need to escape / in patterns).
  • Writes are atomic via temp file + rename to prevent corruption.
  • Edit history is stored in .workspace/code-edit/history.db with file backups in .workspace/code-edit/backups/.
  • Use undo_edit(prune_days: 7) periodically to clean up old backups.

Development

composer install
composer test        # Run Pest tests
composer analyse     # Run PHPStan (level 8)

License

MIT

coquibot/coqui-toolkit-code-edit 适用场景与选型建议

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

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

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

围绕 coquibot/coqui-toolkit-code-edit 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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