Terminal-based code explainer powered by Ollama
Project description
🧠 code-xray
code-xray is a terminal-based code exploration and explanation tool powered by local LLMs (like Ollama).
Select lines of code interactively, send them for explanation, and get human-friendly insights – right in your terminal.
✨ Features
- ✅ Terminal-based file viewer with syntax highlighting
- ✅ Line-by-line navigation and selection
- ✅ Interactive directory tree when run without arguments
- ✅ Integration with local LLMs via Ollama
- ✅ On-demand code explanation using selected lines and full-file context
- ✅ Works fully offline
- ✅ Switch between file viewer and file tree (
bto go back) - ✅ Customizable LLM model and port via CLI
🚀 Usage
1. Launch without arguments
code-xray
This opens a directory tree starting from your current working directory.
You can navigate folders and open files for explanation. Press b inside a viewer to return to the file tree.
2. Launch with a file directly
code-xray /path/to/your/file.py
This opens an interactive terminal interface to browse and explain code.
3. Launch with custom model and port
code-xray /path/to/your/file.py --model mistral --port 11434
--modelor-m: LLM model name (e.g.mistral,llama3,codellama)--portor-p: Port where Ollama is running (default is11434)
🧭 Keybindings
| Key | Action |
|---|---|
h |
Move up one line |
l |
Move down one line |
Shift+h |
Expand selection up |
Shift+l |
Expand selection down |
e |
Explain selected code |
b |
Go back to file tree |
q |
Quit viewer or popup |
Esc |
Close explanation popup |
Enter |
Select file or enter folder |
../ |
Navigate up in the file tree |
🛠 Requirements
- Python 3.10+
- Ollama running locally with your preferred model
Example to pull a model:
ollama pull mistral
Then start the server:
ollama serve
🧩 Installation
pip install code-xray
Make sure
code-xrayis available in your PATH or create an alias.
🙌 Acknowledgements
- Textual for the beautiful terminal UI
- Ollama for local model hosting
- Rich for the syntax highlighting
🔗 Contributions
Pull requests welcome! Feel free to fork and build on top of this.
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 code_xray-2.0.0.tar.gz.
File metadata
- Download URL: code_xray-2.0.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f953158acc01f53db5dec20eb327871d2dc4815135f23095003b044926baab34
|
|
| MD5 |
2381932518ee1ee1965c5eb6dd99cb48
|
|
| BLAKE2b-256 |
e63931ae81b9955c39cf389281f5836ac453d9ba64fc2b94efdfc0dd2fbd2374
|
File details
Details for the file code_xray-2.0.0-py3-none-any.whl.
File metadata
- Download URL: code_xray-2.0.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7297c48d3a32a13337ff828205709a265559e2afae3dcafc313b5a9f6bad11a2
|
|
| MD5 |
c1f3b5a2344dcc5f458d3af46d8bc404
|
|
| BLAKE2b-256 |
c76435e343b4ba47282448403d69637e0daf52f018ed7de24bc8e28f4d6f3fc5
|