The bridge between your local codebase and LLMs.
Project description
xtrshow
xtrshow is a lightweight CLI suite designed to optimize the "Context Injection" and "Code Application" loop when working with AI coding assistants (ChatGPT, Claude, Gemini, etc.).
It consists of two tools:
xtrshow: A TUI to select, compress, and format code context for your LLM.xtrpatch: A surgical patching tool to apply LLM-generated changes back to your source code safely.
Installation
pip install xtrshow
The Workflow
1. Extract Context (xtrshow)
Stop manually copying and pasting files.
Run xtrshow in your directory. Navigate with arrow keys, select files with Space, and hit Enter (or use -o to save to a file).
# Open interactive TUI
xtrshow
# Or pipe directly to clipboard (Mac/Linux)
xtrshow | pbcopy
The output is formatted specifically for LLMs, including file paths and line numbers (enabled by default) to assist in referencing specific code blocks.
2. Prompt the LLM
Paste the output into your LLM. When asking for changes, include the following instruction to get a compatible patch:
"Provide changes using the Multi-File Search and Replace Block format."
3. Apply Changes (xtrpatch)
Save the LLM's response to a file (e.g., response.txt) and apply it:
xtrpatch response.txt
xtrpatch is whitespace-insensitive and uses fuzzy matching, making it significantly more robust than standard git apply when dealing with LLM hallucinations or formatting errors.
Features
Safety First (Atomic Backups)
xtrpatch never destroys code.
- Every time a file is patched, the original is backed up to
.xtrpatch/<file>.orig. - Backups are versioned (
file.py.orig,file.py.1.orig,file.py.2.orig). - The patch itself is archived alongside the backup.
Reverting
Made a mistake? You can unwind changes easily:
# Revert a specific file to its state before the last patch
xtrpatch --revert src/main.py
# Revert all files modified by a specific patch file
xtrpatch --revert response.txt
File Creation
If the LLM wants to create a new file, xtrpatch handles that too.
--- a/src/new_feature.py
<<<<
====
def hello():
print("New file created!")
>>>>
Patch Format Specification
xtrpatch uses a custom, hallucination-resistant format:
--- a/path/to/file.py
<<<< 50
def old_function():
return False
====
def old_function():
return True
>>>>
- Header:
--- a/path/to/file - Start:
<<<< LINE_HINTor<<<< START~END(e.g.,<<<< 50~55). The~indicates an approximate range/fuzzy hint. - Search Block: The existing code to find.
- Divider:
==== - Replace Block: The new code.
- Divider (Optional):
====(Use a second divider to provide Tail Context). - Tail Context (Optional): Code that must exist immediately after the block to verify location.
- End:
>>>>
Example with Tail Context
--- a/src/main.rs
<<<< 10~15
let x = 1;
let y = 2;
====
let x = 10;
let y = 20;
====
// This line must exist after the block for the patch to apply
println!("Calculating...");
>>>>
License
Apache 2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xtrshow-0.2.1.tar.gz.
File metadata
- Download URL: xtrshow-0.2.1.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2afe5e344b4f9ba4943947b279185d1070656530e4a78317532f4635c66f8f9b
|
|
| MD5 |
8335d256ecaeea98a2d739df471635ea
|
|
| BLAKE2b-256 |
96add3352a06d9b44240a938bb526bfffcc88ef8c6346c56e3ca8aba14ca353f
|
File details
Details for the file xtrshow-0.2.1-py3-none-any.whl.
File metadata
- Download URL: xtrshow-0.2.1-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64b7388a39f6b051b0da50533884c8e922d2080701cc72dc7e32569c12a2d2b1
|
|
| MD5 |
bb7a6bb4347af209a6c2a46580252d79
|
|
| BLAKE2b-256 |
3caf0095ec504fb4b86ed9e82d38ead58bb7f5f2751928658a2a0652f4d6444b
|