AI-powered code intelligence tool for analyzing and documenting codebases
Project description
Autodoc - AI-Powered Code Intelligence
Autodoc is an AI-powered code intelligence tool that analyzes Python and TypeScript codebases, enabling semantic search using OpenAI embeddings. It parses code using AST (Abstract Syntax Tree) analysis to extract functions, classes, and their relationships, then generates embeddings for intelligent code search.
Features
- ๐ Semantic Code Search - Search your codebase using natural language queries
- ๐ Python & TypeScript Support - Full AST analysis for both languages
- ๐ Comprehensive Analysis - Extract and analyze functions, classes, and their relationships
- ๐ค AI-Powered - Optional OpenAI embeddings for enhanced search capabilities
- ๐ง LLM Code Enrichment - Generate detailed descriptions using OpenAI, Anthropic/Claude, or Ollama
- ๐ Rich Documentation - Generate detailed codebase documentation in Markdown or JSON
- ๐ Fast & Efficient - Caches analysis results for quick repeated searches
- ๐ API Server - REST API for integration with other tools
- ๐ Graph Database - Neo4j integration for relationship visualization
- ๐ฆ Easy Integration - Use as CLI tool or Python library
- ๐จ Beautiful Output - Rich terminal UI with syntax highlighting
Quick Start
# Install from private registry (for team members)
pip install --index-url https://us-central1-python.pkg.dev/the-agent-factory/autodoc-repo/simple/ autodoc
# Or install for development (requires uv)
git clone https://github.com/your-org/autodoc.git
cd autodoc
make setup
source .venv/bin/activate
Basic Usage
Command Line
# Quick workflow
autodoc analyze ./src # Analyze your codebase
autodoc generate # Create AUTODOC.md documentation
autodoc vector # Generate embeddings for search
autodoc search "auth logic" # Search with natural language
# LLM Enrichment (NEW!)
autodoc init # Create .autodoc.yml config
autodoc enrich --limit 50 # Enrich code with AI descriptions
autodoc generate # Now includes enriched content!
# Additional commands
autodoc check # Check setup and configuration
autodoc graph --visualize # Build graph database with visualizations
autodoc serve # Start REST API server
Python API
from autodoc import SimpleAutodoc
import asyncio
async def main():
# Initialize autodoc
autodoc = SimpleAutodoc()
# Analyze a directory
summary = await autodoc.analyze_directory("./src")
print(f"Found {summary['total_entities']} code entities")
# Search with natural language
results = await autodoc.search("validation logic", limit=5)
for result in results:
print(f"{result['entity']['name']} - {result['similarity']:.2f}")
asyncio.run(main())
Configuration
OpenAI Integration (Optional)
For enhanced semantic search capabilities, set up OpenAI:
# Create .env file
echo "OPENAI_API_KEY=sk-your-key-here" > .env
Autodoc works without OpenAI API key using simple text matching, but embeddings provide much better search results.
Development
Prerequisites
First, install uv - the fast Python package manager:
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or via Homebrew
brew install uv
Setup Development Environment
# Clone repository
git clone https://github.com/your-org/autodoc.git
cd autodoc
# Setup environment with uv
make setup
# Activate virtual environment
source .venv/bin/activate
# Run tests
make test
# Format code
make format
# Build package
make build
Available Make Commands
make help # Show all available commands
make setup # Setup development environment with uv
make setup-graph # Setup with graph dependencies
make analyze # Analyze current directory
make search QUERY="your search" # Search code
make test # Run all tests
make test-core # Run core tests only
make test-graph # Run graph tests only
make lint # Check code quality
make format # Format code
make build # Build package
make publish # Publish to GCP Artifact Registry
# Graph commands (require graph dependencies)
make build-graph # Build code relationship graph
make visualize-graph # Create graph visualizations
make query-graph # Query graph insights
# Quick workflows
make dev # Quick development setup
make dev-graph # Development setup with graph features
Publishing & Deployment
Autodoc uses GCP Artifact Registry for private package hosting:
# One-time setup
make setup-gcp
make configure-auth
# Create a release
make release # Interactive version bump
make publish # Publish to registry
# Or use automated deployment
./scripts/deploy.sh patch # or minor/major
See DEPLOYMENT.md for detailed deployment instructions.
Architecture
Core Components
- SimpleASTAnalyzer - Parses Python files using AST to extract code entities
- OpenAIEmbedder - Handles embedding generation for semantic search
- SimpleAutodoc - Main orchestrator combining analysis and search
- CLI Interface - Rich command-line interface built with Click
Data Flow
- Analysis Phase: Python files โ AST parsing โ CodeEntity objects โ Optional embeddings โ Cache
- Search Phase: Query โ Embedding (if available) โ Similarity computation โ Ranked results
Advanced Features
Generate Comprehensive Documentation
# Generate markdown documentation
autodoc generate-summary --format markdown --output codebase-docs.md
# Generate JSON for programmatic use
autodoc generate-summary --format json --output codebase-data.json
Code Graph Analysis (Optional)
With additional dependencies, you can build and query a code relationship graph:
# Setup with graph dependencies
make setup-graph
source .venv/bin/activate
# Build graph (requires Neo4j running)
autodoc build-graph --clear
# Create visualizations
autodoc visualize-graph --all
# Query insights
autodoc query-graph --all
# Or use make commands
make build-graph
make visualize-graph
make query-graph
Graph Dependencies
The graph features require additional packages:
neo4j- Graph database drivermatplotlib- Static graph visualizationnetworkx- Graph analysisplotly- Interactive visualizationspyvis- Interactive network graphs
Install them with: make setup-graph or uv sync --extra graph
Example Output
Search Results
Search Results for 'authentication'
โโโโโโโโโโโโณโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโณโโโโโโโโโโโโโ
โ Type โ Name โ File โ Line โ Similarity โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ function โ authenticate โ auth/handler.py โ 45 โ 0.92 โ
โ class โ AuthManager โ auth/manager.py โ 12 โ 0.87 โ
โ function โ check_token โ auth/tokens.py โ 78 โ 0.83 โ
โโโโโโโโโโโโดโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโโโโโ
Analysis Summary
Analysis Summary:
files_analyzed: 42
total_entities: 237
functions: 189
classes: 48
has_embeddings: True
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
make test) - Format code (
make format) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Issues: GitHub Issues
- Documentation: CLAUDE.md for AI assistant guidance
- Installation Help: INSTALL.md for detailed setup instructions
Project details
Release history Release notifications | RSS feed
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 ai_code_autodoc-0.7.0.tar.gz.
File metadata
- Download URL: ai_code_autodoc-0.7.0.tar.gz
- Upload date:
- Size: 457.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1aa4751ec1f070527e470866958080d73484419acdeafc62f15199494d9f806f
|
|
| MD5 |
e40bc80ffe80e3f486377361c52abc4f
|
|
| BLAKE2b-256 |
e9d02684535bed4942803fc0d5a7182881f65c5a427d5133aa0acc9f5f2d1035
|
Provenance
The following attestation bundles were made for ai_code_autodoc-0.7.0.tar.gz:
Publisher:
pypi-publish.yml on Emberfield/autodoc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_code_autodoc-0.7.0.tar.gz -
Subject digest:
1aa4751ec1f070527e470866958080d73484419acdeafc62f15199494d9f806f - Sigstore transparency entry: 775772297
- Sigstore integration time:
-
Permalink:
Emberfield/autodoc@d1ad1f8679303f5e0cff14e1d8574152ec7c6e6f -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Emberfield
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@d1ad1f8679303f5e0cff14e1d8574152ec7c6e6f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ai_code_autodoc-0.7.0-py3-none-any.whl.
File metadata
- Download URL: ai_code_autodoc-0.7.0-py3-none-any.whl
- Upload date:
- Size: 125.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d12bc2f72d2143647463b9e6681cc9170cc0928378f21f4d1b824d7a0e4dd13
|
|
| MD5 |
ba869bb7a114fac212272ab47c08cd05
|
|
| BLAKE2b-256 |
f250c708c5fcd1badfae023aaaa4f244f0f1f6bc09ef94313ee4e7f31533b99e
|
Provenance
The following attestation bundles were made for ai_code_autodoc-0.7.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on Emberfield/autodoc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_code_autodoc-0.7.0-py3-none-any.whl -
Subject digest:
1d12bc2f72d2143647463b9e6681cc9170cc0928378f21f4d1b824d7a0e4dd13 - Sigstore transparency entry: 775772301
- Sigstore integration time:
-
Permalink:
Emberfield/autodoc@d1ad1f8679303f5e0cff14e1d8574152ec7c6e6f -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Emberfield
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@d1ad1f8679303f5e0cff14e1d8574152ec7c6e6f -
Trigger Event:
workflow_dispatch
-
Statement type: