Skip to main content

A tool to generate a structured summary of a software repository, enhanced with AI.

Project description

๐Ÿ—บ๏ธ repo-map

repo-map is an advanced tool for generating comprehensive, AI-enhanced summaries of software repositories. It provides developers with valuable insights into project structures, file purposes, and potential considerations across various programming languages. Using efficient caching, repo-map only processes files that have changed since the last run, making it ideal for continuous use in evolving projects. This tool not only aids in understanding and documenting codebases but can also assist LLM agents in writing accurate and functional code within your existing project structure.

๐ŸŒŸ Features

  • ๐Ÿ“Š Generates detailed repository structure summaries
  • ๐Ÿง  AI-powered enhancements:
    • ๐Ÿ’ก Developer considerations for potential issues or unique aspects
    • ๐Ÿ—ฃ๏ธ Concise explanations of file purposes and functionality
    • ๐Ÿ” Insights into code structure and organization
  • ๐ŸŒ Analyzes code structure across multiple programming languages
  • ๐Ÿš€ Supports various file types including Python, Java, JavaScript, TypeScript, and more
  • ๐Ÿ’พ Caching mechanism using SQLite for efficient processing of unchanged files
  • ๐ŸŒณ Tree-like visualization of the repository structure
  • ๐Ÿ“ Markdown output for easy sharing and documentation
  • ๐Ÿ”’ Respects .gitignore files (including nested ones) within the target directory for file exclusion
  • ๐Ÿšฆ Implements rate limiting and exponential backoff for LLM API calls
  • โšก Asynchronous processing for improved performance

๐Ÿ› ๏ธ Installation

Install repo-map using pip:

pip install repo-map

Additionally, the repo_map.py file is designed to be a standalone script that can be easily integrated into any existing project repository.

๐Ÿš€ Usage

To generate a repository map, run the following command:

repo-map <repository_path> [options]

Replace <repository_path> with the path to the repository you want to analyze.

Options:

  • -y, --yes: Automatically accept the disclaimer and proceed without prompting
  • --model MODEL: Specify the OpenRouter LLM model to use (default: anthropic/claude-3.5-sonnet)

Examples:

# Basic usage
repo-map /path/to/your/repo

# Use a specific model
repo-map /path/to/your/repo --model anthropic/claude-3-opus

# Auto-accept disclaimer
repo-map /path/to/your/repo -y

๐Ÿ Example: Snake Game Repository Map

Here's an example of a repo-map generated for an advanced Snake game implemented in Python:

/ (SSSnakeGame)
โ”œโ”€โ”€ main.py (Python)
โ”‚   โ”œโ”€โ”€ Description: Entry point for the Snake game, initializes game and runs the main loop.
โ”‚   โ”œโ”€โ”€ Developer Consideration: "Uses pygame for game development, which may require additional setup for cross-platform compatibility."
โ”‚   โ”œโ”€โ”€ Imports: [pygame, random, time]
โ”‚   โ”œโ”€โ”€ Functions: [main, game_loop, draw_snake, draw_food]
โ”œโ”€โ”€ config.py (Python)
โ”‚   โ”œโ”€โ”€ Description: Centralizes game configuration parameters.
โ”‚   โ”œโ”€โ”€ Developer Consideration: "Hard-coded values may need adjustment for different screen sizes or game difficulties."
โ”œโ”€โ”€ assets/
โ”‚   โ”œโ”€โ”€ images/
โ”‚   โ”‚   โ”œโ”€โ”€ snake_head.png (Image)
โ”‚   โ”‚   โ”œโ”€โ”€ food.png (Image)
โ”‚   โ”œโ”€โ”€ sounds/
โ”‚   โ”‚   โ”œโ”€โ”€ eat.wav (Audio)
โ”‚   โ”‚   โ”œโ”€โ”€ game_over.mp3 (Audio)
โ”œโ”€โ”€ requirements.txt (Text)
โ”‚   โ”œโ”€โ”€ Description: Lists all Python package dependencies for the project.
โ”œโ”€โ”€ README.md (Markdown)
โ”‚   โ”œโ”€โ”€ Description: Provides project overview, setup instructions, and gameplay details.
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

This example demonstrates how repo-map provides a comprehensive overview of a Snake game project, including file descriptions, developer considerations, and key structural information.

๐Ÿ”ง Requirements

  • Python 3.7+
  • Dependencies:
    • requests
    • tqdm
    • aiohttp
    • pathspec
    • certifi

๐Ÿ” Configuration

Before using repo-map, you need to set up your OpenRouter API key. Set the following environment variable:

export OPENROUTER_API_KEY=your_api_key_here

Replace your_api_key_here with your actual OpenRouter API key.

๐Ÿงฉ How It Works

  1. ๐Ÿ“‚ Walks through the repository directory structure
  2. ๐Ÿ“ Analyzes file contents and extracts key information (imports, functions, classes)
  3. ๐Ÿค– Utilizes an LLM (via OpenRouter) to generate descriptions and developer considerations
  4. ๐Ÿ—ƒ๏ธ Caches results in SQLite for efficient processing of unchanged files
  5. ๐Ÿ“Š Generates a comprehensive tree-like structure of the repository
  6. ๐Ÿ’พ Saves the output as a Markdown file for easy viewing and sharing

๐Ÿ”‘ Key Components

  • summarize_repo(): Generates the initial repository summary
  • enhance_repo_with_llm(): Enhances the summary with AI-generated descriptions
  • get_structure(): Extracts classes, functions, and constants from files
  • print_tree(): Displays the repository structure in a tree format
  • save_tree_map(): Saves the repository map to a Markdown file

๐Ÿ“‹ Additional Notes

  • The tool supports a wide range of file types and programming languages. Check the SUPPORTED_LANGUAGES dictionary in the script for a full list.
  • A pre-enhanced repository summary is saved to .repo_map_structure.json as an intermediate step.
  • The tool uses a manual ignore list for generated files like .repo_map_structure.json and .repo-map-cache.db.
  • SSL verification is handled using the certifi library for secure API communications.

๐Ÿ›ก๏ธ License

This project is licensed under the Apache 2.0 License. See the LICENSE file in the root directory of this project for the full license text.

๐Ÿค Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

๐Ÿ“ž Support

If you encounter any problems or have any questions, please open an issue in the GitHub repository.

๐Ÿ“ฆ Version

Current version: 0.1.0

โš ๏ธ Disclaimer

By using this tool, you acknowledge that files will be sent to the OpenRouter LLM for processing. Ensure you have the necessary permissions and consider any sensitive information in your repository.

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

repo_map-0.1.1.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

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

repo_map-0.1.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file repo_map-0.1.1.tar.gz.

File metadata

  • Download URL: repo_map-0.1.1.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for repo_map-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3111d062cde7359e22a718c00028a4e439d4c8cc389fe2980bb0a32efff3dde7
MD5 406e4427b6bcfac97bc0f13bbb035c70
BLAKE2b-256 6253a422c0fe71200eb5c8aa028061add015568cd811f49b3f76e46bfdf7a393

See more details on using hashes here.

File details

Details for the file repo_map-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: repo_map-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for repo_map-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8065d9554f4531085f900a3b6781d2be6a0216bad437b93dd62f4e3e6ee1b0c
MD5 6a3b1ff86fc350882cc82a839889e84d
BLAKE2b-256 edbf8772656e6a02710d0d694cce88a3fcb7a37428382e4e02a7edeb367b0ba4

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