Copcon is a CLI tool that effortlessly copies your project's directory structure and file contents directly to the clipboard, ideal for working with AI chatbots.
Copcon (Copy Context) is a CLI tool designed to generate a comprehensive report of a project's directory structure and file contents. This report can be used to provide context to large language models (LLMs) like ChatGPT, facilitating more informed and accurate responses based on your codebase.
- Directory Tree Generation: Creates a visual representation of your project's directory structure.
- File Content Capture: Includes the contents of files, with options to handle binary files appropriately.
- Customizable Traversal Depth: Specify how deep the directory traversal should go.
- Exclusion Options: Exclude hidden files/directories and specify additional patterns to ignore.
- Clipboard Integration: Optionally copy the generated report directly to the clipboard.
- File Output: Save the report to a specified file instead of copying to the clipboard.
pip install copcon
After installation, use the copcon
command to generate a report of your project.
Generate a report and copy it to the clipboard:
copcon /path/to/your/project
--depth INTEGER
: Specify the depth of directory traversal (-1
for unlimited). Default is-1
.--exclude-hidden / --no-exclude-hidden
: Toggle exclusion of hidden files and directories. Default is--exclude-hidden
.--ignore-dirs TEXT
: Additional directories to ignore. Can be used multiple times.--ignore-files TEXT
: Additional files to ignore. Can be used multiple times.--copconignore PATH
: Path to a custom.copconignore
file.--output-file PATH
: Specify an output file path to save the report instead of copying to the clipboard.
copcon /path/to/your/project
copcon /path/to/your/project --depth 2 --ignore-dirs tests --ignore-files *.md
copcon /path/to/your/project --output-file report.txt
Copcon supports a .copconignore
file to specify patterns for files and directories to exclude from the report. This file should be placed in the root of your project directory.
The .copconignore
follows the gitignore syntax, allowing for flexible pattern matching.
# Ignore all log files
*.log
# Ignore the temp directory and all its contents
temp/
# Ignore all .tmp files in any directory
**/*.tmp
Copcon generates a report structured into two main sections:
- Directory Structure: A tree-like representation of your project's directories and files.
- File Contents: The contents of each file, with binary files indicated appropriately.
Directory Structure:
your_project_name
βββ folder1
β βββ file1.py
β βββ file2.py
βββ folder2
β βββ file3.py
βββ main.py
File Contents:
File: folder1/file1.py
----------------------------------------
[Content of file1.py]
----------------------------------------
File: folder1/file2.py
----------------------------------------
[Content of file2.py]
----------------------------------------
File: folder2/file3.py
----------------------------------------
[Content of file3.py]
----------------------------------------
File: main.py
----------------------------------------
[Content of main.py]
----------------------------------------
Copcon is compatible with the following operating systems:
- macOS
- Windows
- Linux (requires
xclip
or a similar package)
To enable clipboard functionality on Linux, install xclip
:
sudo apt install xclip
-
Ensure you have Python 3.11+ and uv installed.
-
Clone the repository:
git clone https://github.com/kasperjunge/copcon.git cd copcon
-
Install dependencies:
uv sync
-
Run tests:
uv run pytest
Contributions are welcome. Please follow these steps to contribute:
-
Fork the repository.
-
Create a new branch for your feature or bugfix:
git checkout -b feature/your-feature-name
-
Commit your changes with clear messages.
-
Push to your fork and submit a Pull Request.
- Adhere to PEP 8 coding standards.
- Include tests for new features or bug fixes.
- Update documentation as necessary.
This project is licensed under the MIT License.
All notable changes to this project are documented in the CHANGELOG.