Metadata-Version: 2.4
Name: flatten-repo
Version: 0.2.0
Summary: Export a repository into LLM-friendly Markdown or JSONL.
Project-URL: Homepage, https://github.com/Guillaume-Lombardo/chathelpers
Project-URL: Repository, https://github.com/Guillaume-Lombardo/chathelpers
Project-URL: Issues, https://github.com/Guillaume-Lombardo/chathelpers/issues
License: MIT License
        
        Copyright (c) 2026 Guillaume Lombardo
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: cli,jsonl,llm,markdown,rag,repo
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Text Processing :: Markup
Requires-Python: >=3.13
Requires-Dist: pydantic
Requires-Dist: pydantic-settings
Requires-Dist: pyyaml
Requires-Dist: structlog
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: detect-secrets; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest-mock; extra == 'dev'
Requires-Dist: pytest-sugar; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Requires-Dist: ty; extra == 'dev'
Description-Content-Type: text/markdown

# Flatten Repo

Export a repository into LLM-friendly Markdown (`.md`) or chunked JSONL (`.jsonl`).

## What It Does

`flatten-repo` scans a project, applies include/exclude filters, and generates:

- `md`: a human-readable project export (tree + per-file blocks)
- `jsonl`: chunked records for ingestion pipelines (RAG, indexing, search)

It prefers `git ls-files` to respect Git tracking, with filesystem fallback when needed.

## Installation

From PyPI:

```bash
pip install flatten-repo
```

From source (editable):

```bash
pip install -e ".[dev]"
```

## CLI Usage

```bash
flatten-repo --help
flatten-repo --version
```

### Common examples

Export source-focused markdown:

```bash
flatten-repo --repo . --output repo_export.md
```

Export full repository to JSONL:

```bash
flatten-repo --repo . --all --format jsonl --output corpus.jsonl
```

Include tests and add custom filters:

```bash
flatten-repo \
  --repo . \
  --output out.md \
  --include-tests \
  --include-glob "src/**/*.py" \
  --exclude-glob "**/*.png"
```

Export Python files without docstrings:

```bash
flatten-repo --repo . --output out.md --strip-docstrings
```

## Project Layout

```text
src/flatten_repo/
  cli.py                  # CLI argument parsing and orchestration
  settings.py             # Runtime settings model
  logging.py              # Structlog setup
  config.py               # Shared enums/constants/models
  file_manipulation.py    # Filesystem/git/filter/content processing
  output_construction.py  # Markdown/JSONL rendering and chunking

tests/
  unit/
  integration/
  end2end/
```

## Development & Quality

Run checks from the local virtualenv:

```bash
./.venv/bin/ruff check .
./.venv/bin/ruff format --check .
./.venv/bin/ty check src/ tests/
./.venv/bin/pytest
./.venv/bin/pytest -m integration
./.venv/bin/pytest -m end2end
```

Pre-commit hooks are configured in `.pre-commit-config.yaml`.

## Scope & Filtering Notes

- Default scope: `src/` + key files (`pyproject.toml`, requirements, pre-commit config, etc.).
- `--src-only`: strict `src/` scope (excludes key files).
- `--tests-only`: restricts export to `tests/` (+ key files unless `--no-key-first`).
- `--max-bytes`: files larger than this threshold are truncated to head/tail excerpts.
- `--drop`: supports presets `api, ci, data, docker, docs, documentation, front, README, tests`.
- `--strip-docstrings`: removes Python module/class/function docstrings from exported content.

## Markdown Output Notes

- The file tree is rendered under a `## Structure` section.
- File section titles contain only the relative path (no size/SHA by default).

## Quality Gates

- Coverage gate is configured in `pyproject.toml` (`fail_under = 30`).
- Unit tests remain the default pytest selection via marker configuration.

## Publish To PyPI

Release checklist:

```bash
# 1) Update version in pyproject.toml + src/flatten_repo/__init__.py
./.venv/bin/ruff check .
./.venv/bin/pytest

# 2) Build artifacts
./.venv/bin/python -m build

# 3) Validate metadata and long description
./.venv/bin/python -m twine check dist/*
```

Dry-run on TestPyPI first:

```bash
./.venv/bin/python -m twine upload --repository testpypi dist/*
python -m pip install --index-url https://test.pypi.org/simple/ flatten-repo
```

Publish production release:

```bash
./.venv/bin/python -m twine upload dist/*
```

See `RELEASING.md` for full release process and options (API token or Trusted Publishing via GitHub Actions).

## License

MIT (see `LICENSE`).
