Skip to main content

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

pip install codenarrator-ai

Usage

from codenarrator import analyze

result = analyze(
    "https://github.com/user/repo",  # replace with any public GitHub URL
    depth="deep"
)

print("Report path:", result.report_path)
print("Explored files:", len(result.explored_files))
print("Internal edges:", len(result.dependency_graph))

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.

Roadmap

  • Pluggable LLM backends (OpenAI, Anthropic, any OpenAI-compatible API)
  • CLI: codenarrator analyze <url>
  • Full dependency graph support for Java, Go, Rust, C/C++
  • Incremental analysis — only re-explore files changed since last run

Local development

For contributors only. End users should use pip install codenarrator-ai above.

git clone https://github.com/sharwariakre/CodeNarrator
cd CodeNarrator
pip install -e .  # for local development

# 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/

Metadata

Release files for codenarrator-ai 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codenarrator-ai 0.1.4
File Size Uploaded
codenarrator_ai-0.1.4.tar.gz 43.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codenarrator-ai 0.1.4
File Interpreter ABI Platform
codenarrator_ai-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 90.0 kB

Release files / codenarrator_ai-0.1.4.tar.gz

Download URL codenarrator_ai-0.1.4.tar.gz
Size 43.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b5fac14a8d558171b30d5ab110d6203bba104fed48f67c78e292e2d2f4c6423d
BLAKE2b-256 checksum
How to use checksums
ff3851df17410eb47049255a8180fdc026d25c6bf171a69d3415ae7819ee86e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / codenarrator_ai-0.1.4-py3-none-any.whl

Download URL codenarrator_ai-0.1.4-py3-none-any.whl
Size 47.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22fa4216016b901b27500e6646a9f7a1b31b322ab29c22b3f554b237e2aeb123
BLAKE2b-256 checksum
How to use checksums
3b280912421fb58aeaf9515ff2bc374a664cb2cc3e08421ad4f68622711bce60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page