concatenating files for tossing them into a language model
Project description
lmcat
A Python tool for concatenating files and directory structures into a single document, perfect for sharing code with language models. It respects .gitignore and .lmignore patterns and provides configurable output formatting.
Features
- Creates a tree view of your directory structure
- Includes file contents with clear delimiters
- Respects
.gitignorepatterns (can be disabled) - Supports custom ignore patterns via
.lmignore - Configurable via
pyproject.toml,lmcat.toml, orlmcat.json - Python 3.11+ native, with fallback support for older versions
Installation
Install from PyPI:
pip install lmcat
Usage
Basic usage - concatenate current directory:
python -m lmcat
The output will include a directory tree and the contents of each non-ignored file.
Command Line Options
-g,--no-include-gitignore: Ignore.gitignorefiles (they are included by default)-t,--tree-only: Only print the directory tree, not file contents-o,--output: Specify an output file (defaults to stdout)-h,--help: Show help message
Configuration
lmcat can be configured using any of these files (in order of precedence):
pyproject.toml(under[tool.lmcat])lmcat.tomllmcat.json
Configuration options:
[tool.lmcat]
tree_divider = "│ " # Used for vertical lines in the tree
indent = " " # Used for indentation
file_divider = "├── " # Used for file/directory entries
content_divider = "``````" # Used to delimit file contents
include_gitignore = true # Whether to respect .gitignore files
tree_only = false # Whether to only show the tree
Ignore Patterns
lmcat supports two types of ignore files:
.gitignore- Standard Git ignore patterns (used by default).lmignore- Custom ignore patterns specific to lmcat
.lmignore follows the same pattern syntax as .gitignore. Patterns in .lmignore take precedence over .gitignore.
Example .lmignore:
# Ignore all .log files
*.log
# Ignore the build directory and its contents
build/
# Un-ignore a specific file (overrides previous patterns)
!important.log
Development
Setup
- Clone the repository:
git clone https://github.com/mivanit/lmcat
cd lmcat
- Set up the development environment:
make setup
This will:
- Create a virtual environment
- Install development dependencies
- Set up pre-commit hooks
Development Commands
The project uses make for common development tasks:
make dep: Install/update dependenciesmake format: Format code using ruff and pyclnmake test: Run testsmake typing: Run type checksmake check: Run all checks (format, test, typing)make clean: Clean temporary filesmake docs: Generate documentationmake build: Build the packagemake publish: Publish to PyPI (maintainers only)
Run make help to see all available commands.
Running Tests
make test
For verbose output:
VERBOSE=1 make test
For test coverage:
make cov
Roadmap
- better tests, I feel like gitignore/lmignore interaction is broken
- llm summarization and caching of those summaries in
.lmsummary/ - reasonable defaults for file extensions to ignore
- web interface
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
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 lmcat-0.0.1.tar.gz.
File metadata
- Download URL: lmcat-0.0.1.tar.gz
- Upload date:
- Size: 157.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba5624b82854b900eeb6522fb5b193160760655d54976917698656217c8c7a55
|
|
| MD5 |
4be35d17b16fdb5fe27beeea38be7dad
|
|
| BLAKE2b-256 |
e6ea8d9b8f051842b810895d9bba46001767992304d0baeb44ff139ab5ade80a
|
File details
Details for the file lmcat-0.0.1-py3-none-any.whl.
File metadata
- Download URL: lmcat-0.0.1-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e340638f9b2701a5a9fb6fb2f79a30a50a796afd07bf1842100758c07b706ead
|
|
| MD5 |
881849734b3c6961c9c40e1b8907dde2
|
|
| BLAKE2b-256 |
6c27860a4b62f8bd9ea5474e5b01c776c28cd4fa72de42840f76062c9bb6c47b
|