Metadata-Version: 2.4
Name: logfire-setup
Version: 0.1.0
Summary: Interactive CLI to set up Pydantic Logfire with optional dependencies
Project-URL: Homepage, https://github.com/dsfaccini/logfire-setup
Project-URL: Source, https://github.com/dsfaccini/logfire-setup
Author-email: David Sanchez <64162682+dsfaccini@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: httpx>=0.28.1
Requires-Dist: questionary>=2.1.1
Requires-Dist: rich>=14.2.0
Requires-Dist: tomli>=2.3.0
Description-Content-Type: text/markdown

# logfire-setup

Interactive CLI to set up [Pydantic Logfire](https://logfire.pydantic.dev/) with optional dependencies.

## What is this?

`logfire-setup` is a CLI tool that helps you quickly add Logfire to your Python project with an interactive setup process similar to `create-next-app`. It:

- **Interactive selection** with arrow keys and checkboxes for an intuitive user experience
- **Checks authentication** - Validates your Logfire credentials automatically
- **Project selection** - Fetches your projects and runs `logfire projects use` to configure your project
- **Auto-detects** your existing dependencies (FastAPI, Django, SQLAlchemy, etc.)
- **Pre-selects** matching Logfire integrations
- **Installs** Logfire with your chosen extras using `uv`
- **Validates environment** - Checks for LOGFIRE_TOKEN and MCP configuration
- **Generates** best practices documentation for your `AGENTS.md` or `CLAUDE.md`

## Installation & Usage

Run directly with `uvx` (no installation needed):

```bash
uvx logfire-setup
```

Or install globally:

```bash
uv tool install logfire-setup
logfire-setup
```

## Features

### 1. Authentication & Project Setup

Automatically checks if you're authenticated with Logfire by validating `~/.logfire/default.toml`. If authenticated, fetches your projects, lets you select one, and runs `logfire projects use` to create `.logfire/logfire_credentials.json` in your project.

### 2. Automatic Dependency Detection

The CLI scans your `pyproject.toml` or `requirements.txt` to detect existing packages and pre-selects relevant Logfire integrations.

### 3. Interactive Integration Selection

Choose from two organized sections using arrow keys and spacebar:

**Recommended Integrations:**
- HTTPX, FastAPI, Pydantic AI, SQLAlchemy

**Other Integrations** (alphabetically sorted):
- Web Frameworks: Django, Flask, Starlette, ASGI, WSGI
- HTTP Clients: Requests, aiohttp
- Databases: PostgreSQL (asyncpg/psycopg/psycopg2), MySQL, SQLite3, Redis, MongoDB
- Task Queues: Celery
- Cloud: AWS Lambda
- LLM & AI: Google GenAI, LiteLLM
- Monitoring: System Metrics

Detected integrations are pre-selected with checkmarks.

### 4. One-Command Installation

Automatically runs:

```bash
uv add logfire[fastapi,sqlalchemy,redis]
```

### 5. Environment Validation

After installation, checks for:
- `LOGFIRE_TOKEN` environment variable or `.env` file
- MCP (Model Context Protocol) configuration for IDE integrations (Cursor, Claude Desktop, etc.)

Provides helpful links to create tokens and example configurations if missing.

### 6. AI Assistant Instructions

Generates custom Logfire best practices for `AGENTS.md` or `CLAUDE.md`:

- Core patterns (spans, structured logging, exception handling)
- Integration-specific setup based on your selections
- MCP usage instructions (if configured)
- Security and performance tips
- Direct links to documentation

The instructions are tailored to your selected integrations and displayed inline for review before adding.

## Requirements

- Python 3.9+
- [uv](https://docs.astral.sh/uv/) package manager

## Development

Clone the repository:

```bash
git clone https://github.com/pydantic/logfire-setup.git
cd logfire-setup
```

Install dependencies:

```bash
uv sync
```

Run locally:

```bash
uv run logfire-setup
```

Test with uvx:

```bash
uvx --from . logfire-setup
```

## License

MIT - see [LICENSE](LICENSE) for details.

## Links

- [Pydantic Logfire Documentation](https://logfire.pydantic.dev/)
- [Logfire GitHub Repository](https://github.com/pydantic/logfire)
- [uv Documentation](https://docs.astral.sh/uv/)
