PHPackages                             coquibot/coqui-toolkit-code-edit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. coquibot/coqui-toolkit-code-edit

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

coquibot/coqui-toolkit-code-edit
================================

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

v0.1.0(1mo ago)01↓100%MITPHPPHP ^8.4CI passing

Since Mar 17Pushed 1mo agoCompare

[ Source](https://github.com/carmelosantana/coqui-toolkit-code-edit)[ Packagist](https://packagist.org/packages/coquibot/coqui-toolkit-code-edit)[ RSS](/packages/coquibot-coqui-toolkit-code-edit/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Coqui Code Edit Toolkit
=======================

[](#coqui-code-edit-toolkit)

Surgical file editing toolkit for [Coqui](https://github.com/AgentCoqui/coqui). Provides precise, token-efficient code editing operations with full undo history — replace, insert, remove, indent, batch operations, all sandboxed to the workspace.

Requirements
------------

[](#requirements)

- PHP 8.4+
- [Coqui](https://github.com/AgentCoqui/coqui) (auto-discovered via Composer)

Installation
------------

[](#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
--------------

[](#tools-provided)

### `replace_in_file`

[](#replace_in_file)

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

ParameterTypeRequiredDescription`path`stringYesFile path relative to workspace`search`stringYesText or regex pattern to search for`replace`stringYesReplacement text (supports backreferences for regex)`is_regex`boolNoTreat search as PCRE regex (default: false)`flags`stringNoPCRE modifier flags, e.g. "msi"### `insert_before`

[](#insert_before)

Insert content before lines matching an anchor pattern.

ParameterTypeRequiredDescription`path`stringYesFile path relative to workspace`anchor`stringYesText or regex to match lines against`content`stringYesContent to insert before each match`is_regex`boolNoTreat anchor as PCRE regex (default: false)`occurrences`intNoMatches to affect: 0=all, 1=first (default: 1)### `insert_after`

[](#insert_after)

Insert content after lines matching an anchor pattern.

ParameterTypeRequiredDescription`path`stringYesFile path relative to workspace`anchor`stringYesText or regex to match lines against`content`stringYesContent to insert after each match`is_regex`boolNoTreat anchor as PCRE regex (default: false)`occurrences`intNoMatches to affect: 0=all, 1=first (default: 1)### `replace_block`

[](#replace_block)

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

ParameterTypeRequiredDescription`path`stringYesFile path relative to workspace`start_marker`stringYesText or regex marking block start`end_marker`stringYesText or regex marking block end`new_content`stringYesContent to replace the block with`is_regex`boolNoTreat markers as PCRE regex (default: false)### `remove_lines`

[](#remove_lines)

Remove a range of lines from a file.

ParameterTypeRequiredDescription`path`stringYesFile path relative to workspace`from`intYesStart line (1-based, inclusive)`to`intYesEnd line (1-based, inclusive)### `extract_lines`

[](#extract_lines)

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

ParameterTypeRequiredDescription`path`stringYesFile path relative to workspace`from`intYesStart line (1-based, inclusive)`to`intYesEnd line (1-based, inclusive)### `batch_replace`

[](#batch_replace)

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

ParameterTypeRequiredDescription`glob`stringYesGlob pattern (e.g. "src/\*\*/\*.php")`search`stringYesText or regex pattern`replace`stringYesReplacement text`is_regex`boolNoTreat search as PCRE regex (default: false)`flags`stringNoPCRE modifier flags### `append_to_file`

[](#append_to_file)

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

ParameterTypeRequiredDescription`path`stringYesFile path relative to workspace`content`stringYesContent to append### `write_lines`

[](#write_lines)

Overwrite a specific range of lines with new content.

ParameterTypeRequiredDescription`path`stringYesFile path relative to workspace`from`intYesStart line (1-based, inclusive)`to`intYesEnd line (1-based, inclusive)`content`stringYesNew content (can be more or fewer lines)### `indent_lines`

[](#indent_lines)

Indent or outdent a range of lines.

ParameterTypeRequiredDescription`path`stringYesFile path relative to workspace`from`intYesStart line (1-based, inclusive)`to`intYesEnd line (1-based, inclusive)`direction`enumYes`indent` or `outdent``size`intNoSpaces per level (default: 4)`use_tabs`boolNoUse tabs instead of spaces (default: false)### `undo_edit`

[](#undo_edit)

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

ParameterTypeRequiredDescription`edit_id`intNoUndo a specific edit by ID`file`stringNoFile path to undo edits for (with count)`count`intNoNumber of recent edits to undo (default: 1)`list_only`boolNoList recent edits without undoing (default: false)`prune_days`intNoRemove backups older than N daysArchitecture
------------

[](#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
--------------------

[](#key-design-decisions)

DecisionRationaleSeparate tool classesEach tool has distinct parameter shapes; keeps schemas clean for LLM consumptionAtomic writes (temp + rename)Prevents partial writes from corrupting files on crashSQLite edit historyLightweight undo with per-edit granularity; auto-prune keeps storage boundedPath sandboxing via PathResolverAll paths validated against workspace root; blocks directory traversalEOL detection + preservationMaintains CRLF/LF consistency when editing Windows or Unix filesRead-only extract\_linesNo history overhead for inspection — only mutating ops record historyNotes
-----

[](#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
-----------

[](#development)

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

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 84% of packages

Maintenance96

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

52d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/597820?v=4)[Carmelo Santana](/maintainers/carmelosantana)[@carmelosantana](https://github.com/carmelosantana)

---

Top Contributors

[![carmelosantana](https://avatars.githubusercontent.com/u/597820?v=4)](https://github.com/carmelosantana "carmelosantana (1 commits)")

---

Tags

refactoringtoolkitphp-agentscoquisearch-replacecode-editfile-editing

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/coquibot-coqui-toolkit-code-edit/health.svg)

```
[![Health](https://phpackages.com/badges/coquibot-coqui-toolkit-code-edit/health.svg)](https://phpackages.com/packages/coquibot-coqui-toolkit-code-edit)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
