Skip to main content

Terminal-based code explainer powered by Ollama

Project description

code-xray logo

🧠 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

pip install code-xray

Make sure code-xray is 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

code_xray-1.0.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-1.0.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: code_xray-1.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2230421d303b605b70d058412739e1661797f421f728a721e31d0c45a2534423
MD5 5b2ee065060375f7cb20355c6dcc4f17
BLAKE2b-256 cf9c75f7a028954e75e8c65407332ef11294483f309339a9b6f1b4cdac75f71b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: code_xray-1.0.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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e66cde974e86140eb0bba5b05c677fa814801335f5d8a055a1b2ad882fe50a46
MD5 0c89246ebc3df2c9c32e8ea512f769b0
BLAKE2b-256 2d4d42a9edff8a287e0fb87a847993974a014a9e12ce173377da83d6b2aa4a07

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