Skip to main content

GPT directory structure and file contents prompt generator

Project description

GPT Automation

This Python-based project provides a way to automatically generate a project structure, including all directories and files, while ignoring certain unwanted files or directories as specified in a blacklist, whitelist, .gptignore, or .gptincludeonly file.

Installation

Pipx Installation

We recommend installing GPT Automation through pipx, a package manager for running applications written in Python. If you haven't installed pipx, first install it by running:

python3 -m pip install --user pipx
python3 -m pipx ensurepath

Next, install the GPT Automation package with:

pipx install gpt-automation

Manual Installation

To manually install the project, run the following command from the project's root directory:

python setup.py install

This will install the project as a package, making the main module accessible from the command line.

Initialization

To initialize the .gpt directory with sample blacklist, whitelist, and .gptignore files, run:

autogpt init [profile names]

This creates a .gpt directory (or profile-specific directories under .gpt/other_profiles/ if profile names are specified) if it doesn't already exist, copying sample_config/black_list.txt, sample_config/white_list.txt, and a sample .gptignore file into this directory.

Prompt Generation

GPT Automation provides two types of prompts:

  • Full Prompt: Includes both the directory structure and the contents of all files. To generate a full prompt, use:
autogpt prompt --dir [profile names] --content [profile names]
  • Directory-Only Prompt: Only includes the directory structure. To generate a directory-only prompt, use:
autogpt prompt --dir [profile names]
  • Content-Only Prompt: Only includes the file contents. To generate a content-only prompt, use:
autogpt prompt --content [profile names]

In all cases, the generated prompt is automatically copied to the clipboard.

Options

  • --dir: Generates prompts only for directory structures for specified profiles.
  • --content: Generates prompts only for file contents for specified profiles.
  • The default profile used is "default" if no profiles are specified.

Blacklists, Whitelists, .gptignore, and .gptincludeonly

The blacklist file contains patterns of files and directories to ignore during prompt generation, whereas the whitelist file contains patterns of files and directories to include. The .gptignore file functions similarly to a blacklist, offering a more flexible and familiar way to specify files and directories to ignore. The .gptincludeonly file is a new addition that allows users to specify files and directories that should exclusively be included in the prompt, regardless of other rules. If a file matches patterns in both the include and exclude lists, it will be included in the prompt.

# Sample Blacklist (black_list.txt)
*/.gpt/*
*/.git/*
*.gitignore
*.gptignore
*/__pycache__/*
*/gen_scripts/old/*
*/resources/*
*tests*

# Sample Whitelist (white_list.txt)
*.groovy
*.java
*.py
*.ini
*.txt

# Sample `.gptignore`
# Ignore all markdown files
*.md

# Ignore specific directories
node_modules/
build/

# Sample `.gptincludeonly`
# Explicitly include only these files or directories
src/main/
*.yml

Optimization Features

Early Directory Exclusion

The tool implements early directory exclusion for optimal performance when dealing with large codebases. This means:

  • Directories matched by ignore patterns are completely skipped without scanning their contents
  • Particularly useful for directories like node_modules, venv, or .git that contain thousands of files
  • Significantly improves performance by avoiding unnecessary filesystem operations

Example .gptignore for efficient directory exclusion:

node_modules/
venv/
.git/

Output

The generated code, including the directory structure and file contents, will be copied to the clipboard in the following format:

Directory Structure:
./
    file_1.py
    file_2.py
    dir_1/
        file_1.py

File Contents:
==========file_1.py:
# Code for file_1.py

==========file_2.py:
# Code for file_2.py

==========dir_1/file_1.py:
# Code for dir_1/file_1.py

Profile-Based Configuration in .gptignore and .gptincludeonly

Profiles in .gptignore and .gptincludeonly files allow users to define different exclusion and inclusion rules for various project environments or scenarios. This section provides examples of how to structure these files with profile headers and without (global), along with comments to explain their usage.

Example with Profile Headers

# Global Rules (Applies to all profiles)
# Ignore all .git directories
.git/

# Profile: cli
# Rules specific to the "cli" profile
[cli]
# Ignore all markdown files
*.md

# Explicitly include only these files or directories
src/main/
*.yml

# Profile: ignore_walk
# Rules specific to the "ignore_walk" profile
[ignore_walk]
# Ignore specific directories
node_modules/
build/

# Profile: ignore_walk_tests
# Rules specific to the "ignore_walk_tests" profile
[ignore_walk_tests]
# Ignore test files with "ignore_walk" in their path
tests/*/ignore_walk*

# Profile: setup
# Rules specific to the "setup" profile
[setup]
# Ignore setup-related files
setup.py
setup.cfg
pyproject.toml

Example without Profile Headers (Global Rules Only)

# Global Rules (Applies to all profiles)
# Ignore all .git directories
.git/

# Ignore all markdown files
*.md

# Explicitly include only these files or directories
src/main/
*.yml

# Ignore specific directories
node_modules/
build/

# Ignore test files with "ignore_walk" in their path
tests/*/ignore_walk*

# Ignore setup-related files
setup.py
setup.cfg
pyproject.toml

Example Usage

Suppose you have defined the following profiles:

  • cli
  • ignore_walk
  • ignore_walk_tests
  • setup

You can then apply the rules defined within these profiles during project initialization and prompt generation by specifying the corresponding profile names. For example:

autogpt init cli ignore_walk
autogpt prompt --dir ignore_walk_tests --content setup

This will apply the rules defined in the specified profiles to the initialization and prompt generation processes, ensuring that the directory structure and file contents meet the requirements of each specific profile.

This README provides detailed instructions for installing and using the GPT Automation tool, including how to use the init, prompt commands with their respective options. It also explains the purpose of the blacklist, whitelist, and .gptignore files, and how the output will be formatted and copied to the clipboard.

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

gpt_automation-0.1.17.tar.gz (42.6 kB view details)

Uploaded Source

Built Distribution

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

gpt_automation-0.1.17-py3-none-any.whl (60.1 kB view details)

Uploaded Python 3

File details

Details for the file gpt_automation-0.1.17.tar.gz.

File metadata

  • Download URL: gpt_automation-0.1.17.tar.gz
  • Upload date:
  • Size: 42.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.0

File hashes

Hashes for gpt_automation-0.1.17.tar.gz
Algorithm Hash digest
SHA256 3203d007af20ef5ee89504c89d240f96f1d33d720a3cdd596ecbb76fc10f6ea0
MD5 79fa812aed0e6e412b5cf5ced6529c61
BLAKE2b-256 3fa6b222482df4ff671c55c3bc5386460ca88f2ba62ab6dc214c7c0278deed9b

See more details on using hashes here.

File details

Details for the file gpt_automation-0.1.17-py3-none-any.whl.

File metadata

File hashes

Hashes for gpt_automation-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 afdc395b49eeaf9b2908275a180fe31a3f48e670c2b8c21f67eaf04c751f13a5
MD5 3c931594d372e9afea00f2df172390b2
BLAKE2b-256 7e893f23fa964f788b5e2a4be808b58d71a05832813d2aee768ed6f25fc49792

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