Generate an OpenAI Chat Completions-compatible JSON from all UTF-8 plaintext files in a directory.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
dir2chat
Generate an OpenAI Chat Completions-compatible JSON from all UTF-8 plaintext files in a directory.
Use Cases
This tool is designed to help with a variety of tasks involving directory contents and large-language models, such as:
-
Codebase Summarization for LLMs
Preparing a repository as an input for Chat Completions-compatible models, making it easy to "upload" a codebase as a conversational context. -
Automated Project Documentation
Quickly gather all plaintext documentation files (likeREADME.md,docs/, etc.) and their contents for further summarization, analysis, or indexing.
Installation
pip install dir2chat
Usage
python -m dir2chat <directory> [options]
Options:
-o,--output: Output JSON file (default:-for stdout).--max-file-size: Max size for files in bytes (default:65536, or 64 KB).
Example:
python -m dir2chat path/to/my/project -o chat.json --max-file-size 32768
Output
The output is a JSON array of messages suitable for OpenAI Chat models, in the structure:
[
{
"role": "user",
"content": "- README.md\n- src/\n - main.py\n - utils.py"
},
{
"role": "user",
"content": "README.md"
},
{
"role": "user",
"content": "<contents of README.md>"
},
...
]
- First message: The tree view of the directory.
- Subsequent pairs: For each included file, a message with the file's relative path, then another with its content.
Only UTF-8-encoded, plaintext files below the size limit are included. Skipped files are reported to stderr.
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the MIT License.
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 dir2chat-0.1.0a0.tar.gz.
File metadata
- Download URL: dir2chat-0.1.0a0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fba5abeb0cbb2d326a3c0eca08fc3c683ccf1c5f41c79d7fc18c39fc75de70cc
|
|
| MD5 |
0126a8519a0224ff8862dd512fc8dc13
|
|
| BLAKE2b-256 |
841d13e3fa2233e0a6f73d9ea4f6550771ced8b15f727e8c61ee9ef04821dbaa
|
File details
Details for the file dir2chat-0.1.0a0-py2.py3-none-any.whl.
File metadata
- Download URL: dir2chat-0.1.0a0-py2.py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2180e699d9274a391a35c6af610b47c888ce148c271df8246d6ad2b951ab32e1
|
|
| MD5 |
226d64789d9d6089b480ee9a341dd9d9
|
|
| BLAKE2b-256 |
fc457fe4f68601af2b957e267c7677217f93e12b309c014f66d24970eb42a2f4
|