"""Templates for the `strura init` command."""

MAIN_PY = '''\
from contextlib import asynccontextmanager
from collections.abc import AsyncIterator

from fastapi import FastAPI


@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
    # Startup
    yield
    # Shutdown


app = FastAPI(lifespan=lifespan)


@app.get("/health")
async def health_check() -> dict[str, str]:
    return {"status": "ok"}
'''

ENV_PY = '''\
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    """Application settings loaded from environment variables."""

    APP_NAME: str = "my-api"
    DEBUG: bool = False
    DATABASE_URL: str = "sqlite+aiosqlite:///./dev.db"

    model_config = {"env_file": ".env", "env_file_encoding": "utf-8"}


settings = Settings()
'''

INIT_DB_PY = '''\
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine

from app.settings.env import settings

engine = create_async_engine(settings.DATABASE_URL, echo=settings.DEBUG)
async_session = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)


async def get_db() -> AsyncSession:  # type: ignore[misc]
    async with async_session() as session:
        yield session
'''

CONFTEST_PY = '''\
import pytest


@pytest.fixture
def app():
    """Create application fixture."""
    from app.main import app
    return app
'''

# --- Agent Rules ---

MERMAID_ENUM_REPRESENTATION_MD = '''\
# Mermaid Enum Representation

## Rule

When representing enums in Mermaid ER diagrams, use the following format:

```mermaid
erDiagram
    ENTITY {
        string status "ENUM: active, inactive, pending"
    }
```

- Always prefix the comment with `ENUM:` followed by comma-separated values.
- Use `string` as the type for enum fields in the diagram.
- Keep enum values lowercase and separated by commas.
'''

MODEL_DOC_GENERATOR_MD = '''\
# Model Documentation Generator

## Rule

When generating documentation for a model, follow this process:

1. Read the SQLAlchemy model file.
2. Extract all columns, their types, constraints, and relationships.
3. Generate a markdown file following the `MODEL_DOCUMENTATION_STANDARD`.
4. Place the documentation in `docs/models/<model_name>.md` within the context.
'''

MODEL_DOCUMENTATION_STANDARD_MD = '''\
# Model Documentation Standard

## Format

Each model documentation file must follow this structure:

```markdown
# <ModelName>

## Description
Brief description of what this model represents.

## Fields

| Field | Type | Nullable | Default | Description |
|-------|------|----------|---------|-------------|
| id | UUID | No | auto | Primary key |

## Relationships
- **relationship_name**: Description of the relationship.

## Indexes
- `ix_table_field`: Index on `field` column.

## Constraints
- `uq_table_field`: Unique constraint on `field`.
```
'''
