Skip to main content

Easily copy all relevant source files in a repository to clipboard

Project description

repogather

repogather is a command-line tool that copies all relevant files (with their relative paths) in a repository to the clipboard. It is intended to be used in LLM code understanding or code generation workflows. It uses gpt-4o-mini (configurable) to decide file relevance, but can also be used without an LLM to return all files, with non-AI filters (such as excluding tests or config files).

Features

  • Filters and analyzes code files in a repository
  • Excludes test and configuration files by default (with options to include them)
  • Estimates token count and API usage cost before processing
  • Uses OpenAI's GPT models to evaluate file relevance
  • Supports various methods of providing the OpenAI API key
  • Copies relevant files and their contents to the clipboard
  • Can return all files without LLM analysis

Installation

Install repogather using pip:

pip install repogather

Setup

Set up your OpenAI API key using one of the following methods:

  • As an environment variable: export OPENAI_API_KEY=your_api_key_here
  • In a .env file in your current working directory:
    OPENAI_API_KEY=your_api_key_here
    
  • Provide it as a command-line argument when running the tool (see Usage section)

Usage

After installation, you can run repogather from the command line:

repogather [QUERY] [OPTIONS]

Options

  • --include-test: Include test files in the analysis
  • --include-config: Include configuration files in the analysis
  • --relevance-threshold THRESHOLD: Set the relevance threshold (0-100, default: 50)
  • --model MODEL: Specify the OpenAI model to use (default: gpt-4o-mini-2024-07-18)
  • --openai-key KEY: Provide the OpenAI API key directly
  • --all: Return all files without using LLM analysis

Examples

  1. Analyze files with a query:

    repogather "Find files related to user authentication" --include-config --relevance-threshold 70 --model gpt-4o-2024-08-06
    

    This command will:

  2. Search for files related to user authentication

  3. Include configuration files in the search

  4. Only return files with a relevance score of 70 or higher

  5. Use the GPT-4o model from August 2024 for analysis

  6. Return all files without LLM analysis:

    repogather --all --include-test --include-config
    

    This command will:

  7. Gather all code files in the repository

  8. Include test and config files in the output (if present, inferred from file extension)

  9. Copy all gathered files to the clipboard without using LLM analysis

How It Works

repogather performs the following steps:

  1. Scans the current directory and its subdirectories for code files
  2. Filters out test and configuration files (unless included via options)
  3. If --all option is used, returns all filtered files
  4. Otherwise: a. Counts the tokens in the filtered files and estimates the API usage cost b. Asks for user confirmation before proceeding c. Sends the file contents and the query to the specified OpenAI model d. Processes the model's response to rank files by relevance e. Filters the files by the specified relevance threshold
  5. Copies the relevant file paths and contents to the clipboard

Note

repogather requires an active OpenAI API key when using LLM analysis. It will prompt you to confirm the expected cost of the query (in input tokens) before proceeding. When using the --all option, no API key is required.

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

repogather-0.0.2.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

repogather-0.0.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file repogather-0.0.2.tar.gz.

File metadata

  • Download URL: repogather-0.0.2.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.5

File hashes

Hashes for repogather-0.0.2.tar.gz
Algorithm Hash digest
SHA256 449dfeca24863b0f72d13473b70df3083e873b27e075103912d384baa8864abd
MD5 2adf3998a6979e9e7f15162fad4842e2
BLAKE2b-256 eb51e15e955cf7b83e96f8d27ed98f924c43bfee51ef6dc9d91af1b17668ae35

See more details on using hashes here.

File details

Details for the file repogather-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: repogather-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.5

File hashes

Hashes for repogather-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0504cfcec0cdaf4911ba2b4f27b625f30d11753074a8562c6b95acb95fe8c73d
MD5 79190b528c314fec2fb9acc3f0e088fc
BLAKE2b-256 15b96d9c2fabc2e828d7294038b2e1f644480bd5e84784fc10ce169310013154

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