Skip to main content

Autonomous codebase understanding agent — clone a repo, get an architecture report.

Project description

CodeNarrator

Autonomous codebase understanding agent.

Give it a Git URL and it produces an interactive HTML dependency graph plus a natural-language architecture summary of the codebase. Everything runs locally via Ollama — no API keys, no cloud calls.

Prerequisites

  • Python 3.10+
  • Ollama installed and running
  • A model pulled: ollama pull qwen2.5-coder:7b

Installation

Not on PyPI yet. Install from a local clone:

git clone https://github.com/sharwariakre/CodeNarrator
cd CodeNarrator
pip install -e .

Usage

from codenarrator import analyze

result = analyze("https://github.com/user/repo")

result.show()                  # opens the HTML report in your browser
result.to_html("report.html")  # save the HTML to a file
result.to_json("graph.json")   # export the dependency graph as JSON

Deeper exploration (30 steps instead of the default 20):

result = analyze("https://github.com/user/repo", depth="deep")

Private repositories:

result = analyze(
    "https://github.com/user/private-repo",
    api_key="your-github-token",
)

Result object

Property / Method Description
result.show() Open the HTML report in your browser
result.to_html(path) Save the HTML report to a file
result.to_json(path) Export dependency graph as JSON
result.dependency_graph List of internal edges
result.explored_files Files the agent explored
result.architecture_summary AI-generated architecture summary

Configuration

Environment variables:

Variable Purpose Default
CODENARRATOR_DATA_DIR Where clones, cache, and reports go ~/codenarrator/
OLLAMA_HOST Ollama server URL http://localhost:11434
OLLAMA_MODEL Model to use qwen2.5-coder:7b

Output

Reports and clones live under ~/codenarrator/ by default:

~/codenarrator/
├── repos/      ← cloned repositories
├── cache/      ← analysis cache (keyed by repo + git HEAD)
└── reports/    ← generated HTML reports

Supported languages

Language Full dependency graph Import extraction
Python
TypeScript
JavaScript
Java
Go
Rust
C / C++

How it works

Two layers:

Deterministic layer — file scanning, import extraction, internal-edge resolution, dependency graph computation. Pure Python, no LLM involved. Always produces a complete graph from static analysis alone.

Agentic layer — a local LLM (Qwen2.5-Coder 7B by default) explores the codebase via five tool calls:

  • read_file — inspect a source file
  • follow_import — jump to a file imported by something already read
  • search_for_pattern — regex search across the repo
  • mark_architecture_insight — record a finding
  • stop_analysis — finish the run

The model produces a natural-language architecture summary alongside the deterministic graph. If the LLM times out or returns junk, the report still renders from the deterministic layer.

Local development

git clone https://github.com/sharwariakre/CodeNarrator
cd CodeNarrator
pip install -e .

# Start Ollama (separate terminal)
ollama serve
ollama pull qwen2.5-coder:7b

Optional web UI (FastAPI backend + React frontend):

# Terminal 1
cd backend && uvicorn app.main:app --reload

# Terminal 2
cd frontend && npm install && npm run dev

Run the test suite:

cd backend && python -m pytest tests/

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

codenarrator_ai-0.1.0.tar.gz (42.5 kB view details)

Uploaded Source

Built Distribution

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

codenarrator_ai-0.1.0-py3-none-any.whl (46.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codenarrator_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 42.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for codenarrator_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 38ff6995cd4ae2833563d040c72f199662a480b1c9d0c4bf2c9e79927fe41b06
MD5 9e63587f58a5c840f940a9aed697ab6a
BLAKE2b-256 2f0009110f3467556b53efa89b01ace354d8160ae924d1c7b44b2256ea20adfa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for codenarrator_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d888a7824a590892dc585759808e2e171d6aee6c9cd662b20b6a2c7d3d45830
MD5 45cc9a1ab9d0e3089ad3108760753bb9
BLAKE2b-256 f6b313aa4097e7203ca2f6fe4a76a06819b5824e786b897bc8df3b6320277f0c

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