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
- Tree view of directory structure with file statistics (lines, characters, tokens)
- 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- you can specify
glob_processordecider_processto run on files, like if you want to convert a notebook to a markdown file
- you can specify
Installation
Install from PyPI:
pip install lmcat
or, install with support for counting tokens:
pip install lmcat[tokenizers]
Usage
Basic usage - concatenate current directory:
# Only show directory tree
python -m lmcat --tree-only
# Write output to file
python -m lmcat --output summary.md
# Print current configuration
python -m lmcat --print-cfg
The output will include a directory tree and the contents of each non-ignored file.
Command Line Options
-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 is best configured via a tool.lmcat section in pyproject.toml:
[tool.lmcat]
# Tree formatting
tree_divider = "│ " # Vertical lines in tree
tree_indent = " " # Indentation
tree_file_divider = "├── " # File/directory entries
content_divider = "``````" # File content delimiters
# Processing pipeline
tokenizer = "gpt2" # or "whitespace-split"
tree_only = false # Only show tree structure
on_multiple_processors = "except" # Behavior when multiple processors match
# File handling
ignore_patterns = ["*.tmp", "*.log"] # Additional patterns to ignore
ignore_patterns_files = [".gitignore", ".lmignore"]
# processors
[tool.lmcat.glob_process]
"[mM]akefile" = "makefile_recipes"
"*.ipynb" = "ipynb_to_md"
Development
Setup
- Clone the repository:
git clone https://github.com/mivanit/lmcat
cd lmcat
- Set up the development environment:
make setup
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
Roadmap
- more processors and deciders, like:
- only first
nlines if file is too large - first few lines of a csv file
- json schema of a big json/toml/yaml file
- metadata extraction from images
- only first
- 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
Metadata
Release files for lmcat 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lmcat-0.2.0.tar.gz | 304.9 kB | Without provenance | Details for lmcat-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lmcat-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for lmcat-0.2.0-py3-none-any.whl |
Total release size: 331.1 kB
Release files / lmcat-0.2.0.tar.gz
| Download URL | lmcat-0.2.0.tar.gz |
|---|---|
| Size | 304.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f83aaece9554620a04c59dfc8e9af0a022f59bc07a64d1ad4d8640bb3dca6599
|
|
BLAKE2b-256 checksum How to use checksums |
8c899b1460d9a0cabb41d525d19a4d8f7f17a4354e365b7876d991f0e7fa90f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / lmcat-0.2.0-py3-none-any.whl
| Download URL | lmcat-0.2.0-py3-none-any.whl |
|---|---|
| Size | 26.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
776bd5ca877cc2e1bab63fb5c1d5249989b257e9991d2e579e4aac182cf80b57
|
|
BLAKE2b-256 checksum How to use checksums |
8bbc376fed86f94fa0f59e31d1a7f11eab1b4873a236199b4d1c598c1bcb50a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for lmcat 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.