Skip to main content

Generate file tree and file contents for coding assistance with LLMs.

Project description

Context Generator

PyPI Python Versions License

Table of Contents

Introduction

Context Generator is a Python CLI tool designed to generate a comprehensive file tree and collect file contents from your project. This tool is used to give a comprehensive context of your project to an LLM for improved responses.

for an example of the output please look in the img dir

Features

  • File Tree Generation: Visual representation of your project's directory structure.
  • Content Collection: Aggregates contents of selected files for easy reference.
  • Exclusion Options: Customize which files or directories to exclude from the context.
  • Hidden Files Handling: Option to include or exclude hidden files and directories.
  • Configuration Management: Easily configure default settings through a JSON file.
  • VSCode Integration: Seamlessly integrate with Visual Studio Code via a dedicated extension (planned).
  • Cross-Platform Support: Works on Windows, macOS, and Linux.

Installation

Prerequisites

  • Python 3.7+: Ensure you have Python installed. You can download it from python.org.

Install via PyPI

pip install context-generator

Usage

Generating Context

To generate a file tree and collect contents:

generate-context generate <directory> --output <output_file>

Options:

  • directory: The root directory to scan. Defaults to the current working directory.
  • --output: Specify the output file for the generated context.
  • --exclude-files: List filenames to exclude from the context.
  • --exclude-paths: List directory paths to exclude from the context.
  • --include-hidden: Include hidden files and directories in the output.

Example

Generate a context file for your project:

generate-context generate . --output context.txt --exclude-files .env --exclude-paths .git

Calibrating Configuration

To edit the default configuration file:

generate-context calibrate

This opens the configuration file located at ~/.generate_context_config.json in your default editor. Adjust the settings as needed.

Configuration

The configuration file is stored at ~/.generate_context_config.json. Below is an example configuration:

{
  "exclude_files": [".env", "package-lock.json", "LICENSE"],
  "exclude_paths": [".git", "__pycache__"],
  "output_file": "file_context.txt",
  "exclude_hidden": true
}

Fields:

  • exclude_files: Files to exclude from the context generation.
  • exclude_paths: Directories to exclude.
  • output_file: Default output file name.
  • exclude_hidden: Whether to exclude hidden files and directories.

Examples

  1. Basic File Tree Generation:

    generate-context generate .
    
  2. Excluding Specific Files and Directories:

    generate-context generate ./src --exclude-files .env --exclude-paths .git
    
  3. Including Hidden Files:

    generate-context generate ./ --include-hidden
    

Integration with VSCode

  • Planned integration with Visual Studio Code to provide an extension for generating context directly from the editor.

Contributing

We welcome contributions! Feel free to submit issues and pull requests on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For questions or support, reach out to Alastair Grant at aldo.e.george@gmail.com.

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

context_generator-0.1.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

context_generator-0.1.1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: context_generator-0.1.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for context_generator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 19f8f231a99c2ca050915adb5c9489de847b169b27f0031f2c28d35485b61574
MD5 8c8592c7a5d4a3b6433176130459842a
BLAKE2b-256 00c581413131e4ec3f9e104e9cd469961149f009d09f17627d62c7ce9b4e6cc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for context_generator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3728c15aa49c5bc5cfc5d7a5e37e2a717370ec5ea48d8ba9af4885fd7904b6e8
MD5 48e493b3e0f93152611928684d6d9734
BLAKE2b-256 1ae37e142f486c29d291496c80f01d5639caa9f9557de1ba5c64d2ff5d6b20bc

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