fabricatio-diff
Intelligent diff-based editing for LLM-driven text transformations. Combines fuzzy line matching, hashline-anchored edits, and LLM-generated search-and-replace operations into a single package.
Installation
This package is part of the fabricatio monorepo and can be installed as an optional dependency:
pip install fabricatio[diff]
# or
uv pip install fabricatio[diff]
For a full installation:
pip install fabricatio[full]
# or
uv pip install fabricatio[full]
Overview
fabricatio-diff provides two complementary layers for text editing:
- Rust-accelerated primitive operations — hashline anchoring, fuzzy line matching, unified diffs, and similarity measurement, exposed via PyO3 bindings.
- Python orchestration — a
Diffmodel andDiffEditcapability that use LLMs to generate search/replace operations from natural language requirements and apply them with configurable precision.
Key Components
Diff model
Represents a text transformation as a search / replace pair with optional line-range anchoring.
from fabricatio_diff.models.diff import Diff
# Pattern-matching diff
d = Diff(search="old text", replace="new text")
result = d.apply(source_text, match_precision=0.9)
# Anchor-based line-range diff (stable against content shifts)
d = Diff.from_anchors(start_anchor="10:a1b2", end_anchor="15:c3d4", replace="new lines")
# Line-number-based range diff
d = Diff.from_line_range(start=10, end=15, replace="new lines")
# Reverse a diff
rev = d.reverse()
# Format content with LINE:HASH anchors for LLM prompt context
hashed = d.format_with_hashes(source_text)
DiffEdit capability
Mixin class that delegates diff generation to an LLM via prompt templates. Parses the LLM response for <<<<SEARCH / <<<<REPLACE blocks and constructs a validated Diff.
from fabricatio_diff.capabilities.diff_edit import DiffEdit
class MyAgent(DiffEdit, SomeOtherCapability):
pass
agent = MyAgent()
result = await agent.diff_edit(source_text, "rename variable x to count")
Rust Primitives (imported from fabricatio_diff.rust)
| Function | Description |
|---|---|
rate(a, b) |
Normalized Damerau-Levenshtein similarity (0.0–1.0) |
match_lines(haystack, needle, precision=0.9) |
Find a fuzzy-matching block of lines |
show_diff(a, b) |
Generate a unified diff between two strings |
compute_hash(line) |
xxHash-based per-line hash |
format_hashes(content, start_line=1) |
Annotate each line with LINE:HASH |
parse_hashline_anchor(anchor) |
Parse "42:ab12" into (line, hash) |
apply_set_line(content, anchor, new_text) |
Replace one line by anchor |
apply_insert_after(content, anchor, text) |
Insert after an anchored line |
apply_replace(content, old, new, all=False) |
Simple text substitution |
apply_replace_lines(content, start, end, text) |
Replace a range between two anchors |
Configuration
All options below are read through the fabricatio configuration chain (see the
Configuration Guide). Set them under the
[ext.diff] table in fabricatio.toml, equivalently under
[tool.fabricatio.ext.diff] in pyproject.toml, or via
FABRICATIO_EXT__DIFF__<FIELD_UPPER> environment variables.
[ext.diff]
match_precision = 1.0
diff_template = "built-in/diff"
hashline_diff_template = "built-in/hashline_diff"
hashline_judge_template = "built-in/hashline_judge"
hashline_diff_max_iterations = 5
| Option | Type | Default | Description |
|---|---|---|---|
match_precision |
float |
1.0 |
Precision threshold for matching. |
diff_template |
str |
"built-in/diff" |
Template string for diff output. |
hashline_diff_template |
str |
"built-in/hashline_diff" |
Template for the LLM-driven hashline edit loop (self-correcting). |
hashline_judge_template |
str |
"built-in/hashline_judge" |
Template for the YES/NO satisfaction judge inside the hashline edit loop. |
hashline_diff_max_iterations |
int |
5 |
Maximum LLM iterations for the hashline edit loop before giving up. |
Access at runtime: from fabricatio_diff.config import diff_config.
Dependencies
fabricatio-core— core interfaces, configuration system, and prompt template manager- Rust crates:
strsim(similarity),similar(unified diffs),rho-hashline(line hashing),rayon(parallel search)
License
MIT — see LICENSE
Metadata
Release files for fabricatio-diff 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 23.5 MB
Release files / fabricatio_diff-0.4.1-cp314-cp314-win_amd64.whl
| Download URL | fabricatio_diff-0.4.1-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f4714c93f0bbb2eeb4126091ad45f3de5f47ab6e632fd6b34dd1b3f1f448788f
|
|
BLAKE2b-256 checksum How to use checksums |
46bfd674b20cbe36c2591c828476702487025dd4c728718377026b83f1d488ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_diff-0.4.1-cp314-cp314-manylinux_2_34_x86_64.whl
| Download URL | fabricatio_diff-0.4.1-cp314-cp314-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.14 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
7a444e867176604ad5f8c45e90cafc708888fa884f5d7449af9278f1914a7608
|
|
BLAKE2b-256 checksum How to use checksums |
dcce48933e5c2e4319817f09b2db5cc215f2a2fb8e7a28865ac4f6181ee3dfdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_diff-0.4.1-cp314-cp314-manylinux_2_34_aarch64.whl
| Download URL | fabricatio_diff-0.4.1-cp314-cp314-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.14 Linux glibc 2.34+ ARM64 |
|
SHA-256 checksum How to use checksums |
6ec3c08d1f6d5a2e77a318d7ef1cd9eb53969fd72aac1e847fb737087ec8423c
|
|
BLAKE2b-256 checksum How to use checksums |
85b31ab4b773e0af3c0fda054141859ab96debaa44088bef10519dd58451aa3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_diff-0.4.1-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | fabricatio_diff-0.4.1-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c6c8db5478d532c755a3c53f8e0fd8184ef58180c4b2b112182d58a6040c63a7
|
|
BLAKE2b-256 checksum How to use checksums |
2b4e89080377535647b935029b13c32f3d8682d833157e087f74e14d2a57512c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_diff-0.4.1-cp313-cp313-win_amd64.whl
| Download URL | fabricatio_diff-0.4.1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f048db49ca87f06ae1393a3f5deda90eb3698fc03bab674f9103e7c1cdacc40c
|
|
BLAKE2b-256 checksum How to use checksums |
6a69603cc9f09d26fe325ece1fb926b8315256c6adbf09d9df091d293cedb641
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_diff-0.4.1-cp313-cp313-manylinux_2_34_x86_64.whl
| Download URL | fabricatio_diff-0.4.1-cp313-cp313-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.13 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
596eaa58d348a9408bee98fa64aefe14b64bc396c61ed808b0621f0209561f7a
|
|
BLAKE2b-256 checksum How to use checksums |
e4d63b283cacdfedd9e3e75f3a0b7686a1b9a6fb12c2a4e6a7b1816b43a4b746
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_diff-0.4.1-cp313-cp313-manylinux_2_34_aarch64.whl
| Download URL | fabricatio_diff-0.4.1-cp313-cp313-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.13 Linux glibc 2.34+ ARM64 |
|
SHA-256 checksum How to use checksums |
6c4fa45624f25d8ffdeaabfeab498002d2d01ebba88f705c67cadfd0124054b3
|
|
BLAKE2b-256 checksum How to use checksums |
f0b41ed47631bb1bed7bcc6d5c5ce69ee86c7f54044f6aac850db4c3c806a9b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_diff-0.4.1-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | fabricatio_diff-0.4.1-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e50827abc8d75c7c9b64aacef5c9e2baabf47a90c0c28d9148d1ba65d0af3c1e
|
|
BLAKE2b-256 checksum How to use checksums |
05810a950807a76dc0d901363a4980650e17b35c12d7284f809527bc58968135
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_diff-0.4.1-cp312-cp312-win_amd64.whl
| Download URL | fabricatio_diff-0.4.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
362a491d7601394d587e04cd4d95e451f7e8df14a5f32ba941ffbf63107b996f
|
|
BLAKE2b-256 checksum How to use checksums |
98937aad56d83567af15e312f5a2248266a39160121da97c5666febedde3f6f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_diff-0.4.1-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | fabricatio_diff-0.4.1-cp312-cp312-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
1f4a1dfdaf95349d660f84ea6e830403698564640064e3cf7c1b5e556f718fff
|
|
BLAKE2b-256 checksum How to use checksums |
e5e986f74d0463287b2e238065cb11d39aed0dbc3e3c91eea9aa3f8203615a79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_diff-0.4.1-cp312-cp312-manylinux_2_34_aarch64.whl
| Download URL | fabricatio_diff-0.4.1-cp312-cp312-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.12 Linux glibc 2.34+ ARM64 |
|
SHA-256 checksum How to use checksums |
87d96f00fab7323a61609e12d6da3e744c3c16fdff62249d93756f1af3c76f1f
|
|
BLAKE2b-256 checksum How to use checksums |
05166e02968a0512e062cb417a236954e13136c95bce2a9ba3d4e83fa2656692
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_diff-0.4.1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | fabricatio_diff-0.4.1-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
75096a3a0837903c421f0abafb003c3c443dbcfe36fc97e2d01689cf2b2cb197
|
|
BLAKE2b-256 checksum How to use checksums |
0d86351e41671dc5c73415679e850dc5ea7b7bba008d2fc10832e2814c348777
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for fabricatio-diff 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.