Only in /var/lib/copr-rpmbuild/results/ripgrep-edit/upstream-unpacked/Source0/ripgrep-edit-0.3.19: .distro diff -U2 -r /var/lib/copr-rpmbuild/results/ripgrep-edit/upstream-unpacked/Source0/ripgrep-edit-0.3.19/README.md /var/lib/copr-rpmbuild/results/ripgrep-edit/srpm-unpacked/ripgrep-edit-0.3.19.tar.gz-extract/ripgrep-edit-0.3.19/README.md --- /var/lib/copr-rpmbuild/results/ripgrep-edit/upstream-unpacked/Source0/ripgrep-edit-0.3.19/README.md 2026-10-07 17:05:25.000000000 +0000 +++ /var/lib/copr-rpmbuild/results/ripgrep-edit/srpm-unpacked/ripgrep-edit-0.3.19.tar.gz-extract/ripgrep-edit-0.3.19/README.md 2026-10-23 22:28:36.000000000 +0000 @@ -8,6 +8,8 @@ - 📄 Present matches in a clean, linear, easy-to-read format - ✏️ Edit all matched code snippets in a single temporary file -- 💾 Apply changes back to original files -- 🛠️ Works with any editor via shell command +- 💾 Apply changes back to the original files +- 🛠️ Work with any editor via a shell command + +If the temporary file is not saved by the editor, no changes are applied. ## Demo @@ -29,5 +31,7 @@ ### Fedora Copr + A Fedora Copr package is available: + ```bash sudo dnf copr enable vittyvk/ripgrep-edit @@ -40,24 +44,24 @@ - `-e, --regexp `: Regex pattern to search for -- `-E, --editor `: Editor command (e.g., `vim`, `emacs`) -- `-C, --context `: Number of context lines -- `-A, --after-context `: Lines of context to show after each match -- `-B, --before-context `: Lines of context to show before each match -- `--require-all-files`: Require all files in ripgrep output to be present in the edited file -- `--context-separator `: Separator string between snippets -- `--filename-prefix `: Prefix for filename lines +- `-E, --editor `: Editor command (e.g., `vim`, `emacsclient`) +- `-C, --context `: Number of context lines (default: 5, minimum: 1) +- `-A, --after-context `: Lines of context to show after each match (the larger of `-A` and `-C` is used) +- `-B, --before-context `: Lines of context to show before each match (the larger of `-B` and `-C` is used) +- `--require-all-files`: Require all files in the ripgrep output to be present in the edited file (by default, files removed from the edited file are left unchanged) +- `--context-separator `: Separator string between snippets (default: `-- DO NOT DELETE THIS SEPARATOR`) +- `--filename-prefix `: Prefix for filename lines (default: `-- `) - `-S, --smart-case`: Enable smart case search - `-i, --ignore-case`: Ignore case distinctions -- `-w, --word-regexp`: Force pattern to match only whole words +- `-w, --word-regexp`: Force the pattern to match only whole words - `-U, --multiline`: Enable multiline matching - `--multiline-dotall`: Enable dotall mode for multiline matching -- `--sort `: Sort results by path, modified, accessed, or created time -- `--sortr `: Sort results in reverse order by path, modified, accessed, or created time -- `--follow`: Follow symlinks -- `-j, --threads `: Number of threads to use -- `--dump-on-error`: Dump processed tempfile to stderr on error -- `--output-size-limit `: Limit total ripgrep output size (e.g., 1024, 1k, 1m, 1g). If the limit is exceeded, the tool exits with code 3. -- `--gbnf`: Generate dynamic GBNF grammar file -- `--gbnf-control-lines`: Max number of GBNF control lines added as extra context +- `--sort `: Sort results by `path`, `modified`, `accessed`, or `created` time +- `--sortr `: Sort results in reverse order by `path`, `modified`, `accessed`, or `created` time (cannot be combined with `--sort`) +- `-L, --follow`: Follow symlinks +- `-j, --threads `: Number of threads to use (default: 0, automatic) +- `--dump-on-error`: Dump the processed temporary file to stderr on error +- `--output-size-limit `: Limit the total ripgrep output size (e.g., `1024`, `1k`, `1m`, `1g`). If the limit is exceeded, the tool exits with code 3. +- `--gbnf`: Generate a dynamic GBNF grammar file +- `-G, --gbnf-control-lines `: Maximum number of GBNF control lines added as extra context (default: 10) ## Examples @@ -66,13 +70,13 @@ rg-edit [OPTIONS] --regexp --editor [PATHS...] rg-edit -e "function\s*\(" -E vim src/ -rg-edit -e "function\s*\(" -E "emacsclient" -C 8 src/ +rg-edit -e "function\s*\(" -E emacsclient -C 8 src/ rg-edit -E vim -C10 -U -e '(?s)^<<<<<<<+ .*?^\|\|\|\|\|\|\|+ .*?^>>>>>>>+ ' # resolve git conflicts rg-edit -E emacsclient -C10 -U -e '(?s)^<<<<<<<+ .*?^\|\|\|\|\|\|\|+ .*?^>>>>>>>+ ' -rg-edit -e '.*' -E vim src/ --output-size-limit 1m # fail if output larger than 1 megabyte (exits with code 3) +rg-edit -e '.*' -E vim src/ --output-size-limit 1m # fail if the output exceeds 1 megabyte (exits with code 3) ``` ## Why It Was Built -Large codebases challenge LLMs due to context limits. Traditional vibe coding tools require reading snippets of multiple large files through the LLM agentic workflow. +Large codebases challenge LLMs due to context limits. Traditional vibe coding tools require the LLM agentic workflow to read snippets of multiple large files. `ripgrep-edit` solves this by: @@ -80,7 +84,7 @@ - 📌 **Preserving context** around each match - 🧠 **Enabling precise edits** via LLMs or editors -- 🔄 **Reapplying changes to original files** +- 💾 **Reapplying changes** to the original files -`ripgrep-edit` lets the programmer define the exact context needed, presenting it in a structured, linear format optimized for the LLM's key-value input. The resulting gain in efficiency enables real-time visibility into what the LLM is generating — allowing to interrupt, refine input, adjust directives, and eliminate unnecessary context, computation, and cost. +`ripgrep-edit` lets the programmer define the exact context needed, presenting it in a structured, linear format optimized for the LLM's key-value input. The resulting gain in efficiency provides real-time visibility into what the LLM is generating, making it possible to interrupt, refine the input, adjust directives, and eliminate unnecessary context, computation, and cost. The goal is to optimize the LLM's most demanding task — writing code — by minimizing perplexity and maximizing efficiency. @@ -102,7 +106,12 @@ ``` +Every file kept in the edited output must retain all of its snippets and separators; otherwise the changes are rejected. + ## rg-edit.el -- Provides `rg-edit`, `rg-edit-buffer`, `rg-edit-git`, `rg-edit-git-conflicts` functions +- Provides the `rg-edit`, `rg-edit-buffer`, `rg-edit-git` and `rg-edit-git-conflicts` commands +- Requires a running Emacs server (`M-x server-start`), since `emacsclient` is used as the editor +- Enabling `global-auto-revert-mode` is recommended so modified files are reloaded automatically +- Automatically passes `--gbnf` when a configured gptel backend supports the `gbnf` or `ebnf` capability - Keybindings: - `rg-edit-git` **C-c r** @@ -110,6 +119,12 @@ - `rg-edit-buffer` **C-- C-c r** - `rg-edit-git-conflicts` **C-u C-c r** - - `rg-edit--commit` **C-c C-c** (in rg-edit buffer) - - `rg-edit--abort` **C-c C-k** (in rg-edit buffer) + - `rg-edit--commit` **C-c C-c** (in the rg-edit buffer) + - `rg-edit--abort` **C-c C-k** (in the rg-edit buffer) + - `rg-edit--terminate` **C-c C-k** (in the `*rg-edit*` buffer, terminates any outstanding session) +- Customization variables: + - `rg-edit-executable`: path to the `rg-edit` executable + - `rg-edit-auto-mark-whole-buffer`: mark the whole buffer when entering `rg-edit-mode` + - `rg-edit-prefill-extra-args`: default extra arguments (default: `-U --multiline-dotall --smart-case`) + - `rg-edit-gptel-system-message`: gptel directive used in rg-edit buffers ```elisp @@ -122,7 +137,7 @@ ``` -## GBNF EBNF Grammar Support +## GBNF/EBNF Grammar Support -ripgrep-edit integrates with [GBNF](https://github.com/ggml-org/llama.cpp/blob/master/grammars/README.md) to constrain LLM outputs when using llama.cpp or vllm. When the `--gbnf` flag is used, a `*.gbnf` grammar file is generated in the same directory as the temporary rg-edit buffer. The `rg-edit.el` plugin automatically detects this file and injects its contents into the JSON request as the `grammar` field when the gptel backend supports the `gbnf` or `ebnf` capability. +ripgrep-edit integrates with [GBNF](https://github.com/ggml-org/llama.cpp/blob/master/grammars/README.md) to constrain LLM outputs when using llama.cpp or vLLM. When the `--gbnf` flag is used, a `.gbnf` grammar file is generated next to the temporary `.rg-edit` file. The `rg-edit.el` plugin automatically detects this file and injects its contents into the JSON request: as the `grammar` field when the gptel model supports the `gbnf` capability, or as `structured_outputs.grammar` when it supports the `ebnf` capability. ```elisp @@ -146,7 +161,7 @@ ``` -The GBNF grammar enforces deterministic structure around the metadata markers of the rg-edit format. The LLM retains the ability to drop irrelevant files or reorder the file sequence, but the filename and its prefix are enforced to have no typos. Once inside the snippets, the GBNF grammar emits the "before context" control line (if available) and then grants the LLM free reign to modify snippet content until the LLM emits the "after context" control line or the separator. At that point, the GBNF grammar regains control, emits the separator (if not already emitted), and advances to the next snippet. +The GBNF grammar enforces a deterministic structure around the metadata markers of the rg-edit format. The LLM retains the ability to drop irrelevant files or reorder the file sequence, but the filename and its prefix are enforced verbatim, preventing typos. Inside each snippet, the grammar emits the "before context" control line (if available) and then grants the LLM free rein to modify the snippet content until it emits the "after context" control line or the separator. At that point, the grammar regains control, emits the separator (if not already emitted), and advances to the next snippet. -When the grammar is enabled during inference, a notification appears in the `*rg-edit*` buffer. +When the grammar is enabled, a notification appears in the `*rg-edit*` buffer. > ![ripgrep-edit `"max_line_1 with GBNF"` commit](https://gitlab.com/aarcange/ripgrep-edit-assets/-/raw/main/demo-max_line_1-GBNF.webm) @@ -155,10 +170,9 @@ ## Why Not wgrep? -- Emacs' [`wgrep`](https://github.com/mhayashi1120/Emacs-wgrep) offers similar functionality but relies on interactive edits, such as `C-c C-d` to delete a line, which are incompatible with the full rewrites required in LLM-driven workflows. +- Emacs' [`wgrep`](https://github.com/mhayashi1120/Emacs-wgrep) offers similar functionality but relies on interactive edits, such as `C-c C-d` to delete a line, which are incompatible with the full rewrites required by LLM-driven workflows. -- Unlike wgrep, `ripgrep-edit` is editor-agnostic and LLM-agnostic: any editor can be used, making it ideal for diverse environments, or simply to avoid opening multiple files with vim. +- Unlike wgrep, `ripgrep-edit` is editor-agnostic and LLM-agnostic: any editor can be used, making it ideal for diverse environments, or simply to avoid opening multiple files in vim. ## License -[![License: GPL-3.0-or-later](https://img.shields.io/badge/License-GPL--3.0--or--later-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html) -[![License: AGPL-3.0-or-later](https://img.shields.io/badge/License-AGPL--3.0--or--later-blue.svg)](https://www.gnu.org/licenses/agpl-3.0.html) +[![License: GPL-3.0-or-later](https://img.shields.io/badge/License-GPL--3.0--or--later-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html) ![OR](https://img.shields.io/badge/OR-lightgrey.svg) [![License: AGPL-3.0-or-later](https://img.shields.io/badge/License-AGPL--3.0--or--later-blue.svg)](https://www.gnu.org/licenses/agpl-3.0.html)