Skip to main content

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.

Demo

✨ Features

  • ✅ Terminal-based file viewer with syntax highlighting
  • ✅ Line-by-line navigation and selection
  • ✅ Integration with local LLMs via Ollama
  • ✅ On-demand code explanation using selected lines and full-file context
  • ✅ Works fully offline
  • ✅ Customizable LLM model and port via CLI

🚀 Usage

1. Basic Command

code-xray /path/to/your/file.py

This opens an interactive terminal interface to browse and explain code.

2. With Custom Model and Port

code-xray /path/to/your/file.py --model mistral --port 11434
  • --model or -m: LLM model name (e.g. mistral, llama3, codellama)
  • --port or -p: Port where Ollama is running (default is 11434)

🧭 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
q Quit viewer or popup
Esc Close explanation popup

🛠 Requirements

  • Python 3.10+
  • Ollama running locally with desired model pulled

Example to pull a model:

ollama pull mistral

Then ensure it's running:

ollama serve

🧩 Installation

git clone https://github.com/yourusername/code-xray.git
cd code-xray
pip install -e .

Make sure code-xray is available in your PATH or create an alias.


🤖 Example Output

Demo Screenshot


📄 License

MIT License © 2024 Aayush Rajesh Jadhav


🙌 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

code_xray-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

code_xray-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file code_xray-0.1.0.tar.gz.

File metadata

  • Download URL: code_xray-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for code_xray-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c01b9140a401b3930780d06ec17db24f1648d8fef462eeee872cc7117b9035a9
MD5 2369c554875813259fd0d989add0f5a3
BLAKE2b-256 713e3b61881a18f71e4e339e137becd26162333fd60f10d6ca2047f7618f07dc

See more details on using hashes here.

File details

Details for the file code_xray-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: code_xray-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for code_xray-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c293640b6c2b8e419bc519268338857295d1a1555cf89f7cb5bcd7064d364e6
MD5 e2fab75bb766c51ff357d5509708da49
BLAKE2b-256 cb9979eee5da02667a42c7099000f2e3affdf4c6a22687eeef11116184e390e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page