Generate file tree and file contents for coding assistance with LLMs.
Project description
Context Generator
Table of Contents
- Introduction
- Features
- Installation
- Usage
- Configuration
- Examples
- Integration with VSCode
- Contributing
- License
- Contact
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
-
Basic File Tree Generation:
generate-context generate .
-
Excluding Specific Files and Directories:
generate-context generate ./src --exclude-files .env --exclude-paths .git
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19f8f231a99c2ca050915adb5c9489de847b169b27f0031f2c28d35485b61574
|
|
| MD5 |
8c8592c7a5d4a3b6433176130459842a
|
|
| BLAKE2b-256 |
00c581413131e4ec3f9e104e9cd469961149f009d09f17627d62c7ce9b4e6cc3
|
File details
Details for the file context_generator-0.1.1-py3-none-any.whl.
File metadata
- Download URL: context_generator-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3728c15aa49c5bc5cfc5d7a5e37e2a717370ec5ea48d8ba9af4885fd7904b6e8
|
|
| MD5 |
48e493b3e0f93152611928684d6d9734
|
|
| BLAKE2b-256 |
1ae37e142f486c29d291496c80f01d5639caa9f9557de1ba5c64d2ff5d6b20bc
|