axm-edit 0.0.1.dev0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. axm_edit-0.2.0/.gitignore +48 -0
  2. axm_edit-0.2.0/CONTRIBUTING.md +36 -0
  3. axm_edit-0.2.0/LICENSE +201 -0
  4. axm_edit-0.2.0/PKG-INFO +208 -0
  5. axm_edit-0.2.0/README.md +184 -0
  6. axm_edit-0.2.0/docs/explanation/architecture.md +66 -0
  7. axm_edit-0.2.0/docs/howto/index.md +71 -0
  8. axm_edit-0.2.0/docs/howto/mcp.md +57 -0
  9. axm_edit-0.2.0/docs/index.md +51 -0
  10. axm_edit-0.2.0/docs/reference/cli.md +23 -0
  11. axm_edit-0.2.0/docs/tutorials/getting-started.md +99 -0
  12. axm_edit-0.2.0/mkdocs.yml +85 -0
  13. axm_edit-0.2.0/pyproject.toml +366 -0
  14. axm_edit-0.2.0/src/axm_edit/__init__.py +8 -0
  15. axm_edit-0.2.0/src/axm_edit/_version.py +24 -0
  16. axm_edit-0.2.0/src/axm_edit/core/__init__.py +9 -0
  17. axm_edit-0.2.0/src/axm_edit/core/checkpoint.py +211 -0
  18. axm_edit-0.2.0/src/axm_edit/core/engine.py +781 -0
  19. axm_edit-0.2.0/src/axm_edit/models/__init__.py +1 -0
  20. axm_edit-0.2.0/src/axm_edit/models/operations.py +164 -0
  21. axm_edit-0.2.0/src/axm_edit/services/__init__.py +1 -0
  22. axm_edit-0.2.0/src/axm_edit/services/lint.py +27 -0
  23. axm_edit-0.2.0/src/axm_edit/services/lint_diff.py +119 -0
  24. axm_edit-0.2.0/src/axm_edit/tools/__init__.py +1 -0
  25. axm_edit-0.2.0/src/axm_edit/tools/batch_edit.py +429 -0
  26. axm_edit-0.2.0/src/axm_edit/tools/batch_rollback.py +112 -0
  27. axm_edit-0.2.0/src/axm_edit/tools/edit_file.py +162 -0
  28. axm_edit-0.2.0/src/axm_edit/tools/list_dir.py +220 -0
  29. axm_edit-0.2.0/src/axm_edit/tools/read_file.py +204 -0
  30. axm_edit-0.2.0/src/axm_edit/tools/run_command.py +232 -0
  31. axm_edit-0.2.0/src/axm_edit/tools/search_files.py +255 -0
  32. axm_edit-0.2.0/src/axm_edit/tools/write_file.py +91 -0
  33. axm_edit-0.2.0/src/axm_edit/utils/__init__.py +35 -0
  34. axm_edit-0.2.0/tests/__init__.py +1 -0
  35. axm_edit-0.2.0/tests/conftest.py +72 -0
  36. axm_edit-0.2.0/tests/e2e/__init__.py +0 -0
  37. axm_edit-0.2.0/tests/integration/__init__.py +0 -0
  38. axm_edit-0.2.0/tests/integration/_helpers.py +19 -0
  39. axm_edit-0.2.0/tests/integration/test_batch_apply__batch_rollback_tool.py +52 -0
  40. axm_edit-0.2.0/tests/integration/test_batch_apply__create_op.py +179 -0
  41. axm_edit-0.2.0/tests/integration/test_batch_apply__delete_op.py +31 -0
  42. axm_edit-0.2.0/tests/integration/test_batch_apply__edit.py +108 -0
  43. axm_edit-0.2.0/tests/integration/test_batch_apply__operation.py +63 -0
  44. axm_edit-0.2.0/tests/integration/test_batch_apply__replace_op.py +880 -0
  45. axm_edit-0.2.0/tests/integration/test_batch_edit_tool.py +864 -0
  46. axm_edit-0.2.0/tests/integration/test_checkpoint_mod__create_checkpoint.py +40 -0
  47. axm_edit-0.2.0/tests/integration/test_create_checkpoint__create_op.py +83 -0
  48. axm_edit-0.2.0/tests/integration/test_create_checkpoint__delete_op.py +30 -0
  49. axm_edit-0.2.0/tests/integration/test_create_checkpoint__replace_op.py +99 -0
  50. axm_edit-0.2.0/tests/integration/test_edit__replace_op.py +124 -0
  51. axm_edit-0.2.0/tests/integration/test_edit_file_tool.py +83 -0
  52. axm_edit-0.2.0/tests/integration/test_is_binary.py +46 -0
  53. axm_edit-0.2.0/tests/integration/test_list_dir_tool.py +175 -0
  54. axm_edit-0.2.0/tests/integration/test_read_file_tool.py +171 -0
  55. axm_edit-0.2.0/tests/integration/test_run_command_tool.py +124 -0
  56. axm_edit-0.2.0/tests/integration/test_search_files_tool.py +199 -0
  57. axm_edit-0.2.0/tests/integration/test_write_file_tool.py +63 -0
  58. axm_edit-0.2.0/tests/unit/__init__.py +0 -0
  59. axm_edit-0.2.0/tests/unit/models/__init__.py +0 -0
  60. axm_edit-0.2.0/tests/unit/models/test_operations.py +114 -0
  61. axm_edit-0.2.0/tests/unit/services/__init__.py +0 -0
  62. axm_edit-0.2.0/tests/unit/services/test_lint.py +32 -0
  63. axm_edit-0.2.0/tests/unit/services/test_lint_diff.py +146 -0
  64. axm_edit-0.2.0/tests/unit/tools/__init__.py +0 -0
  65. axm_edit-0.2.0/tests/unit/tools/test_batch_edit.py +100 -0
  66. axm_edit-0.2.0/tests/unit/tools/test_batch_rollback.py +53 -0
  67. axm_edit-0.2.0/tests/unit/tools/test_edit_file.py +55 -0
  68. axm_edit-0.2.0/tests/unit/tools/test_list_dir.py +20 -0
  69. axm_edit-0.2.0/tests/unit/tools/test_read_file.py +19 -0
  70. axm_edit-0.2.0/tests/unit/tools/test_run_command.py +69 -0
  71. axm_edit-0.2.0/tests/unit/tools/test_search_files.py +43 -0
  72. axm_edit-0.2.0/tests/unit/tools/test_write_file.py +38 -0
  73. axm_edit-0.0.1.dev0/PKG-INFO +0 -14
  74. axm_edit-0.0.1.dev0/README.md +0 -3
  75. axm_edit-0.0.1.dev0/pyproject.toml +0 -16
  76. axm_edit-0.0.1.dev0/src/axm_edit/__init__.py +0 -1
  77. {axm_edit-0.0.1.dev0 → axm_edit-0.2.0}/src/axm_edit/py.typed +0 -0
@@ -0,0 +1,48 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ # Generated version file
7
+ _version.py
8
+ .Python
9
+ build/
10
+ dist/
11
+ *.egg-info/
12
+ *.egg
13
+
14
+ # Virtual environments
15
+ .venv/
16
+ .uv/
17
+ venv/
18
+ ENV/
19
+
20
+ # Testing & Coverage
21
+ .pytest_cache/
22
+ .coverage
23
+ coverage.xml
24
+ coverage.json
25
+ htmlcov/
26
+ coverage_html/
27
+ .tox/
28
+
29
+ # Type checking & Linting
30
+ .mypy_cache/
31
+ .ruff_cache/
32
+
33
+ # IDE
34
+ .idea/
35
+ .vscode/
36
+ *.swp
37
+ *.swo
38
+
39
+ # Environment
40
+ .env
41
+ .envrc
42
+
43
+ # Documentation
44
+ site/
45
+
46
+ # OS
47
+ .DS_Store
48
+ Thumbs.db
@@ -0,0 +1,36 @@
1
+ # Contributing to axm-edit
2
+
3
+ ## Development Setup
4
+
5
+ ```bash
6
+ git clone https://github.com/axm-protocols/axm-edit.git
7
+ cd axm-edit
8
+ uv sync --all-groups
9
+ ```
10
+
11
+ ## Commands
12
+
13
+ | Command | Description |
14
+ |---------|-------------|
15
+ | `make check` | Lint + type-check + tests |
16
+ | `make lint` | Ruff + MyPy |
17
+ | `make format` | Auto-format with Ruff |
18
+ | `make docs-serve` | Local docs preview |
19
+
20
+ ## Commit Conventions
21
+
22
+ This project uses [Conventional Commits](https://www.conventionalcommits.org/):
23
+
24
+ - `feat:` — new feature
25
+ - `fix:` — bug fix
26
+ - `docs:` — documentation only
27
+ - `chore:` — maintenance (deps, CI, config)
28
+ - `test:` — adding or updating tests
29
+ - `refactor:` — code change that neither fixes a bug nor adds a feature
30
+
31
+ ## Pull Request Checklist
32
+
33
+ 1. Write tests first (TDD)
34
+ 2. Run `make check` — all tests pass, no lint errors
35
+ 3. Keep commits atomic and conventional
36
+ 4. Update docs if user-facing
axm_edit-0.2.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 John Doe
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.4
2
+ Name: axm-edit
3
+ Version: 0.2.0
4
+ Summary: AXM Edit — Atomic batch file editing for AI agents.
5
+ Project-URL: Homepage, https://forge.axm-protocols.io
6
+ Project-URL: Documentation, https://forge.axm-protocols.io
7
+ Project-URL: Repository, https://github.com/axm-protocols/axm-forge
8
+ Project-URL: Issues, https://github.com/axm-protocols/axm-forge/issues
9
+ Author-email: Gabriel Jarry <gabriel@axm-protocols.io>
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: agent,batch-edit,file-editing,mcp,refactoring
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.12
21
+ Requires-Dist: axm
22
+ Requires-Dist: pydantic>=2.0.0
23
+ Description-Content-Type: text/markdown
24
+
25
+ # axm-edit
26
+
27
+ **Atomic batch file editing for AI agents.**
28
+
29
+ <p align="center">
30
+ <a href="https://forge.axm-protocols.io/audit/"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/axm-protocols/axm-forge/gh-pages/badges/axm-edit/axm-audit.json" alt="axm-audit"></a>
31
+ <a href="https://forge.axm-protocols.io/init/"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/axm-protocols/axm-forge/gh-pages/badges/axm-edit/axm-init.json" alt="axm-init"></a>
32
+ <a href="https://github.com/axm-protocols/axm-forge/actions/workflows/axm-quality.yml"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/axm-protocols/axm-forge/gh-pages/badges/axm-edit/coverage.json" alt="Coverage"></a>
33
+ <img src="https://img.shields.io/badge/python-3.12%2B-blue" alt="Python 3.12+">
34
+ </p>
35
+
36
+ ---
37
+
38
+ ## Overview
39
+
40
+ IDE agents edit files one-at-a-time. A refactor touching 30 files = 30 tool calls.
41
+ The agent spends 70% of its budget on mechanics.
42
+
43
+ **`axm-edit` replaces all of that with 1 call.**
44
+
45
+ ## Features
46
+
47
+ - 🔧 **`batch_edit`** — Replace, create, and delete files in a single atomic operation
48
+ - 📖 **`read_file`** — Read file content with optional line-range support
49
+ - 🔍 **`search_files`** — Grep-like search across project files (literal or regex)
50
+ - 📂 **`list_dir`** — List files and directories with metadata (recursive, depth-limited)
51
+ - ✏️ **`write_file`** — Write or overwrite file content
52
+ - ▶️ **`run_command`** — Execute shell commands with timeout and output truncation
53
+ - ⏪ **`batch_rollback`** — Restore the exact paths a batch touched from a targeted snapshot
54
+ - 🛡️ **Atomic** — All-or-nothing: validation runs before any file is touched
55
+ - 📐 **Bottom-to-top** — Line edits applied in reverse order to avoid line-shift problems
56
+ - 🔒 **Safe** — Path traversal blocked, `old` content validated, targeted path snapshot before writes
57
+
58
+ ## Installation
59
+
60
+ ```bash
61
+ uv add axm-edit
62
+ ```
63
+
64
+ Or as a workspace dependency in `pyproject.toml`:
65
+
66
+ ```toml
67
+ [project]
68
+ dependencies = ["axm-edit"]
69
+
70
+ [tool.uv.sources]
71
+ axm-edit = { workspace = true }
72
+ ```
73
+
74
+ ## Quick Start
75
+
76
+ ```python
77
+ from axm_edit.core.engine import batch_apply
78
+ from axm_edit.models.operations import Edit, ReplaceOp, CreateOp
79
+ from pathlib import Path
80
+
81
+ result = batch_apply(
82
+ root=Path("/my/project"),
83
+ operations=[
84
+ ReplaceOp(file="src/core.py", edits=[
85
+ Edit(line=5, old="class OldName:", new="class NewName:"),
86
+ ]),
87
+ CreateOp(file="src/new.py", content='"""New module."""\n'),
88
+ ],
89
+ )
90
+ print(result.summary) # {"modified": 1, "created": 1, "deleted": 0}
91
+ ```
92
+
93
+ ## MCP Tools
94
+
95
+ ### `batch_edit`
96
+
97
+ Atomic batch file operations.
98
+
99
+ | Param | Type | Default | Description |
100
+ |---|---|---|---|
101
+ | `path` | `str` | `"."` | Project root directory |
102
+ | `operations` | `list[Op]` | — | List of replace/create/delete operations |
103
+ | `lint` | `bool` | `True` | Run `ruff --fix` on changed Python files after apply |
104
+ | `lint_diff` | `bool` | `True` | Surface per-file `lint_diffs` hunks of post-lint mutations |
105
+ | `lint_diff_max_ratio` | `float` | `0.5` | Fallback to `file_reread_recommended` when `len(diff) > ratio * len(post)` |
106
+
107
+ When `lint_diff=True` and ruff/harness_fix mutates any Python file, `ToolResult.data["lint_diffs"]` lists one entry per file: `{"file", "rules": [ruff codes], "diff": "@L<n>\n-old\n+new..."}`. On large rewrites the entry drops `diff` and carries `"diff_skipped": "file_reread_recommended"`.
108
+
109
+ **3 operation types:**
110
+
111
+ #### `replace` — modify lines in an existing file
112
+
113
+ ```json
114
+ {
115
+ "op": "replace",
116
+ "file": "src/foo.py",
117
+ "edits": [
118
+ {"line": 3, "old": "import bar", "new": "import baz"},
119
+ {"line": 17, "old": "x = bar()", "new": "x = baz()"}
120
+ ]
121
+ }
122
+ ```
123
+
124
+ All line numbers reference the **original** file. The engine sorts edits bottom-to-top.
125
+
126
+ #### `create` — create a new file
127
+
128
+ ```json
129
+ {"op": "create", "file": "src/new.py", "content": "\"\"\"New module.\"\"\"\n"}
130
+ ```
131
+
132
+ Fails if file exists (unless `"overwrite": true`).
133
+
134
+ #### `delete` — remove a file
135
+
136
+ ```json
137
+ {"op": "delete", "file": "src/old.py"}
138
+ ```
139
+
140
+ ### `read_file`
141
+
142
+ Read file content with optional line-range support.
143
+
144
+ | Param | Type | Description |
145
+ |---|---|---|
146
+ | `path` | `str` | Project root directory |
147
+ | `file` | `str` | Relative path to the file |
148
+ | `start_line` | `int?` | Optional 1-indexed start line (inclusive) |
149
+ | `end_line` | `int?` | Optional 1-indexed end line (inclusive) |
150
+
151
+ ### `search_files`
152
+
153
+ Grep-like search across project files.
154
+
155
+ | Param | Type | Description |
156
+ |---|---|---|
157
+ | `path` | `str` | Project root directory |
158
+ | `pattern` | `str` | Search string or regex (required) |
159
+ | `is_regex` | `bool?` | Treat pattern as regex (default `false`) |
160
+ | `include` | `list[str]?` | Glob patterns to filter files (e.g. `["*.py"]`) |
161
+
162
+ ### `list_dir`
163
+
164
+ List files and directories with metadata.
165
+
166
+ | Param | Type | Description |
167
+ |---|---|---|
168
+ | `path` | `str` | Root directory to list (default `"."`) |
169
+ | `max_depth` | `int?` | Recursion depth — 1 for immediate children only (default `1`) |
170
+
171
+ ### `run_command`
172
+
173
+ Execute shell commands with timeout and output truncation.
174
+
175
+ | Param | Type | Description |
176
+ |---|---|---|
177
+ | `path` | `str` | Project root directory |
178
+ | `command` | `str` | Shell command string (required) |
179
+ | `cwd` | `str?` | Working directory, relative to root |
180
+ | `timeout` | `int?` | Timeout in seconds (default 30) |
181
+
182
+ ### `batch_rollback`
183
+
184
+ Restore the exact paths a batch touched from its snapshot.
185
+
186
+ | Param | Type | Description |
187
+ |---|---|---|
188
+ | `path` | `str` | Project root directory |
189
+ | `checkpoint` | `str` | Snapshot payload from the `batch_edit` response |
190
+
191
+ ## Development
192
+
193
+ This package is part of the **axm-forge** workspace.
194
+
195
+ ```bash
196
+ git clone https://github.com/axm-protocols/axm-forge.git
197
+ cd axm-forge
198
+ uv sync --all-groups
199
+
200
+ # Run tests for this package
201
+ uv run pytest --package axm-edit
202
+ ```
203
+
204
+ 📖 **[Full documentation](https://forge.axm-protocols.io/edit/)**
205
+
206
+ ## License
207
+
208
+ Apache-2.0 — © 2026 Gabriel Jarry
@@ -0,0 +1,184 @@
1
+ # axm-edit
2
+
3
+ **Atomic batch file editing for AI agents.**
4
+
5
+ <p align="center">
6
+ <a href="https://forge.axm-protocols.io/audit/"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/axm-protocols/axm-forge/gh-pages/badges/axm-edit/axm-audit.json" alt="axm-audit"></a>
7
+ <a href="https://forge.axm-protocols.io/init/"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/axm-protocols/axm-forge/gh-pages/badges/axm-edit/axm-init.json" alt="axm-init"></a>
8
+ <a href="https://github.com/axm-protocols/axm-forge/actions/workflows/axm-quality.yml"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/axm-protocols/axm-forge/gh-pages/badges/axm-edit/coverage.json" alt="Coverage"></a>
9
+ <img src="https://img.shields.io/badge/python-3.12%2B-blue" alt="Python 3.12+">
10
+ </p>
11
+
12
+ ---
13
+
14
+ ## Overview
15
+
16
+ IDE agents edit files one-at-a-time. A refactor touching 30 files = 30 tool calls.
17
+ The agent spends 70% of its budget on mechanics.
18
+
19
+ **`axm-edit` replaces all of that with 1 call.**
20
+
21
+ ## Features
22
+
23
+ - 🔧 **`batch_edit`** — Replace, create, and delete files in a single atomic operation
24
+ - 📖 **`read_file`** — Read file content with optional line-range support
25
+ - 🔍 **`search_files`** — Grep-like search across project files (literal or regex)
26
+ - 📂 **`list_dir`** — List files and directories with metadata (recursive, depth-limited)
27
+ - ✏️ **`write_file`** — Write or overwrite file content
28
+ - ▶️ **`run_command`** — Execute shell commands with timeout and output truncation
29
+ - ⏪ **`batch_rollback`** — Restore the exact paths a batch touched from a targeted snapshot
30
+ - 🛡️ **Atomic** — All-or-nothing: validation runs before any file is touched
31
+ - 📐 **Bottom-to-top** — Line edits applied in reverse order to avoid line-shift problems
32
+ - 🔒 **Safe** — Path traversal blocked, `old` content validated, targeted path snapshot before writes
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ uv add axm-edit
38
+ ```
39
+
40
+ Or as a workspace dependency in `pyproject.toml`:
41
+
42
+ ```toml
43
+ [project]
44
+ dependencies = ["axm-edit"]
45
+
46
+ [tool.uv.sources]
47
+ axm-edit = { workspace = true }
48
+ ```
49
+
50
+ ## Quick Start
51
+
52
+ ```python
53
+ from axm_edit.core.engine import batch_apply
54
+ from axm_edit.models.operations import Edit, ReplaceOp, CreateOp
55
+ from pathlib import Path
56
+
57
+ result = batch_apply(
58
+ root=Path("/my/project"),
59
+ operations=[
60
+ ReplaceOp(file="src/core.py", edits=[
61
+ Edit(line=5, old="class OldName:", new="class NewName:"),
62
+ ]),
63
+ CreateOp(file="src/new.py", content='"""New module."""\n'),
64
+ ],
65
+ )
66
+ print(result.summary) # {"modified": 1, "created": 1, "deleted": 0}
67
+ ```
68
+
69
+ ## MCP Tools
70
+
71
+ ### `batch_edit`
72
+
73
+ Atomic batch file operations.
74
+
75
+ | Param | Type | Default | Description |
76
+ |---|---|---|---|
77
+ | `path` | `str` | `"."` | Project root directory |
78
+ | `operations` | `list[Op]` | — | List of replace/create/delete operations |
79
+ | `lint` | `bool` | `True` | Run `ruff --fix` on changed Python files after apply |
80
+ | `lint_diff` | `bool` | `True` | Surface per-file `lint_diffs` hunks of post-lint mutations |
81
+ | `lint_diff_max_ratio` | `float` | `0.5` | Fallback to `file_reread_recommended` when `len(diff) > ratio * len(post)` |
82
+
83
+ When `lint_diff=True` and ruff/harness_fix mutates any Python file, `ToolResult.data["lint_diffs"]` lists one entry per file: `{"file", "rules": [ruff codes], "diff": "@L<n>\n-old\n+new..."}`. On large rewrites the entry drops `diff` and carries `"diff_skipped": "file_reread_recommended"`.
84
+
85
+ **3 operation types:**
86
+
87
+ #### `replace` — modify lines in an existing file
88
+
89
+ ```json
90
+ {
91
+ "op": "replace",
92
+ "file": "src/foo.py",
93
+ "edits": [
94
+ {"line": 3, "old": "import bar", "new": "import baz"},
95
+ {"line": 17, "old": "x = bar()", "new": "x = baz()"}
96
+ ]
97
+ }
98
+ ```
99
+
100
+ All line numbers reference the **original** file. The engine sorts edits bottom-to-top.
101
+
102
+ #### `create` — create a new file
103
+
104
+ ```json
105
+ {"op": "create", "file": "src/new.py", "content": "\"\"\"New module.\"\"\"\n"}
106
+ ```
107
+
108
+ Fails if file exists (unless `"overwrite": true`).
109
+
110
+ #### `delete` — remove a file
111
+
112
+ ```json
113
+ {"op": "delete", "file": "src/old.py"}
114
+ ```
115
+
116
+ ### `read_file`
117
+
118
+ Read file content with optional line-range support.
119
+
120
+ | Param | Type | Description |
121
+ |---|---|---|
122
+ | `path` | `str` | Project root directory |
123
+ | `file` | `str` | Relative path to the file |
124
+ | `start_line` | `int?` | Optional 1-indexed start line (inclusive) |
125
+ | `end_line` | `int?` | Optional 1-indexed end line (inclusive) |
126
+
127
+ ### `search_files`
128
+
129
+ Grep-like search across project files.
130
+
131
+ | Param | Type | Description |
132
+ |---|---|---|
133
+ | `path` | `str` | Project root directory |
134
+ | `pattern` | `str` | Search string or regex (required) |
135
+ | `is_regex` | `bool?` | Treat pattern as regex (default `false`) |
136
+ | `include` | `list[str]?` | Glob patterns to filter files (e.g. `["*.py"]`) |
137
+
138
+ ### `list_dir`
139
+
140
+ List files and directories with metadata.
141
+
142
+ | Param | Type | Description |
143
+ |---|---|---|
144
+ | `path` | `str` | Root directory to list (default `"."`) |
145
+ | `max_depth` | `int?` | Recursion depth — 1 for immediate children only (default `1`) |
146
+
147
+ ### `run_command`
148
+
149
+ Execute shell commands with timeout and output truncation.
150
+
151
+ | Param | Type | Description |
152
+ |---|---|---|
153
+ | `path` | `str` | Project root directory |
154
+ | `command` | `str` | Shell command string (required) |
155
+ | `cwd` | `str?` | Working directory, relative to root |
156
+ | `timeout` | `int?` | Timeout in seconds (default 30) |
157
+
158
+ ### `batch_rollback`
159
+
160
+ Restore the exact paths a batch touched from its snapshot.
161
+
162
+ | Param | Type | Description |
163
+ |---|---|---|
164
+ | `path` | `str` | Project root directory |
165
+ | `checkpoint` | `str` | Snapshot payload from the `batch_edit` response |
166
+
167
+ ## Development
168
+
169
+ This package is part of the **axm-forge** workspace.
170
+
171
+ ```bash
172
+ git clone https://github.com/axm-protocols/axm-forge.git
173
+ cd axm-forge
174
+ uv sync --all-groups
175
+
176
+ # Run tests for this package
177
+ uv run pytest --package axm-edit
178
+ ```
179
+
180
+ 📖 **[Full documentation](https://forge.axm-protocols.io/edit/)**
181
+
182
+ ## License
183
+
184
+ Apache-2.0 — © 2026 Gabriel Jarry