fmlpack is a tool to convert a file tree to/from a Filesystem Markup Language (FML) document. It creates a single text-based archive of a directory structure, suitable for passing file contexts to LLMs (Large Language Models).
- Pack: Archives files and directories into a single FML file.
- Unpack: Extracts files from an FML archive to the filesystem.
- Filtering: Supports
.gitignorerules via--gitignore, plus specific exclusions via.fmlpackignoreand--exclude. - Safety: Prevents path traversal attacks during extraction.
Install directly with pip to automatically handle dependencies:
pip install fmlpackfmlpack is a single-file Python script, but it requires the pathspec library.
- Install the dependency:
pip install pathspec. - Copy
src/fmlpack.pyto a location in your PATH. - Make it executable:
chmod +x fmlpack.py.
# Archive current directory to archive.fml
fmlpack -c . -f archive.fml
# Archive using .gitignore rules (excludes .git/ automatically)
fmlpack -c . --gitignore -f archive.fml
# Archive specific files and folders
fmlpack -c src/ tests/ -f source_code.fml
# Exclude specific patterns
fmlpack -c . --exclude "*.pyc" --exclude "__pycache__"# Extract to current directory
fmlpack -x -f archive.fml
# Extract to specific directory
fmlpack -x -f archive.fml -C /tmp/outputfmlpack -t -f archive.fmlThis project uses pytest for testing.
-
Install test dependencies:
pip install pytest pytest-cov pathspec
-
Run tests:
pytest
-
Run tests with coverage report:
pytest --cov=./src/ tests/test_fmlpack.py