gogpt is a command-line tool written in Go that enables you to export the structure and content of a Git repository into a text format. This format is tailored for consumption by AI language models, making it ideal for tasks like automated code reviews, documentation generation, or code analysis. The tool offers a range of customization options to include or exclude specific file types, respect .gitignore rules, and handle large files appropriately.
- Selective File Inclusion: Use system flags to specify which programming languages' files should be included in the export.
- .gitignore Compliance: Optionally ignore files listed in the project's
.gitignorefiles. - Large File Management: Exclude large files from the output, providing warnings with details about the excluded files.
- Automatic Language Detection: When no specific languages are provided, automatically detect the programming languages used in the repository.
- Human-Readable Logs: Utilize
Zerologto provide styled, human-readable logging, with default behavior tailored for both terminal and non-terminal outputs.
To build the gogpt CLI tool, navigate to the root of the project and run:
go build -o gogpt ./cmd/gogptThis will generate an executable named gogpt in the root directory.
You can download the pre-built binary for Linux (amd64) using curl and make it executable with the following commands:
sudo curl -L https://github.com/daemonp/gogpt/releases/download/v1/gogpt_linux_amd64 -o /usr/local/bin/gogpt
sudo chmod 755 /usr/local/bin/gogptTo verify the installation, run:
gogpt --versionAfter installing gogpt, you can run the tool with various options:
gogpt [options]-f: Specify the output file path (default: stdout).-i: Ignore files listed in.gitignore.-l: Comma-separated list of languages to include (e.g.,go,js,md).--max-tokens: Maximum number of tokens per file (default: 1000).-v: Enable verbose logging.
-
Basic Usage
gogpt -l go,js -f output.txt
gogpt -l go,js | wl-copy -
Ignore Files in .gitignore:
gogpt -l go,js -i
-
Automatic Language Detection:
gogpt
By default, logs are output in a human-readable format to stderr. If the output is being piped, logs are adjusted for non-terminal environments.