Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

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 (like README.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>"
  },
  ...
]
  1. First message: The tree view of the directory.
  2. 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.

Release files for dir2chat 0.1.0a0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dir2chat 0.1.0a0
File Size Uploaded
dir2chat-0.1.0a0.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dir2chat 0.1.0a0
File Interpreter ABI Platform
dir2chat-0.1.0a0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 8.3 kB

Release files / dir2chat-0.1.0a0.tar.gz

Download URL dir2chat-0.1.0a0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fba5abeb0cbb2d326a3c0eca08fc3c683ccf1c5f41c79d7fc18c39fc75de70cc
BLAKE2b-256 checksum
How to use checksums
841d13e3fa2233e0a6f73d9ea4f6550771ced8b15f727e8c61ee9ef04821dbaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / dir2chat-0.1.0a0-py2.py3-none-any.whl

Download URL dir2chat-0.1.0a0-py2.py3-none-any.whl
Size 4.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2180e699d9274a391a35c6af610b47c888ce148c271df8246d6ad2b951ab32e1
BLAKE2b-256 checksum
How to use checksums
fc457fe4f68601af2b957e267c7677217f93e12b309c014f66d24970eb42a2f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

0.1.0a0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page