Metadata-Version: 2.4
Name: aegro
Version: 0.2.0
Summary: CLI for Aegro agricultural management API
Project-URL: Homepage, https://github.com/aegro/tool-aegro-cli
Project-URL: Repository, https://github.com/aegro/tool-aegro-cli.git
Project-URL: Issues, https://github.com/aegro/tool-aegro-cli/issues
Project-URL: Changelog, https://github.com/aegro/tool-aegro-cli/releases
Author-email: Aegro Engineering <pedro@aegro.com.br>
License-Expression: MIT
License-File: LICENSE
Keywords: agriculture,api-client,cli,farm-management,typer
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic-settings>=2.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: structlog>=24.0.0
Requires-Dist: typer[all]>=0.12.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest-httpx>=0.34.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.8.0; extra == 'dev'
Description-Content-Type: text/markdown

# Aegro CLI

Command-line interface for the [Aegro](https://aegro.com.br) agricultural management API.

[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
[![PyPI](https://img.shields.io/pypi/v/aegro.svg)](https://pypi.org/project/aegro/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

---

## Install

```bash
# pipx (recommended)
pipx install aegro

# uv
uv tool install aegro

# Homebrew (macOS)
brew tap aegro/tap
brew install aegro
```

For development:

```bash
git clone https://github.com/aegro/tool-aegro-cli.git
cd tool-aegro-cli
uv sync
uv run aegro --help
```

---

## Quick Start

```bash
# 1. Authenticate
aegro auth login --farm-name "Fazenda Sul" --api-key "aegro_abc123..."

# 2. Select a farm
aegro farms list
aegro farms select "Fazenda Sul"

# 3. Start working
aegro crops list --start-date 2025-01-01 --end-date 2025-12-31
aegro financial installments --status PENDING
aegro stock items --output table
```

---

## Commands

| Group | Commands | Domain |
|-------|----------|--------|
| `auth` | login, status, logout | Authentication |
| `farms` | list, select, info | Farm management |
| `crops` | get, list, prorate, harvest-discounts, prorates, glebes | Harvest management |
| `activities` | get, list, plan, realizations, get-plan, get-realization, create-plan | Activity planning |
| `financial` | bill, installment, installments, create/update/delete-installment, realize | Accounts payable/receivable |
| `stock` | item, location, items, locations, logs, log, transfer, entry, removal | Inventory |
| `elements` | get, list, create-defensive/fertilizer/item/seed/service, set-categories | Inputs/supplies |
| `assets` | get, list, create-machine/vehicle/garner/immobilized/pivot/weather-station | Equipment |
| `fuel-supplies` | get, list, create, update | Fuel management |
| `maintenances` | get, list, create, update | Maintenance records |
| `harvest-logs` | get, create | Harvest records |
| `bank-accounts` | get, list, create | Bank accounts |
| `companies` | get, list, create | Suppliers/vendors |
| `fin-categories` | get, list, create, subcategories | Chart of accounts |
| `catalogs` | list, element-keys, elements | Catalog lookups |
| `tags` | get, list, create | Tags/labels |
| `weather` | get, create | Weather data |
| `purchase-orders` | get, list, create | Purchase orders |
| `glebes` | get, list | Farm fields |
| `crop-glebes` | get, list | Crop fields |

---

## Output Formats

All commands support three output formats:

```bash
aegro crops list --output json    # JSON (default, for LLMs/scripts)
aegro crops list --output table   # Rich table for humans
aegro crops list --output csv     # CSV export
```

---

## Usage Examples

### Human workflow

```bash
# Morning overview
aegro farms select "Fazenda Norte"
aegro crops list --output table
aegro financial installments --status PENDING --due-date-start 2025-03-01 --output table
aegro stock items --output table

# Register a fuel supply
aegro fuel-supplies create --asset-key K --date 2025-03-13 --quantity 150 --unit L --cost 900

# Check harvest
aegro harvest-logs get <key>
```

### LLM/Agent workflow

```bash
# Agents use JSON output (default) for structured data
aegro crops list --start-date 2025-01-01 --end-date 2025-12-31
aegro activities list --crop-key <key>
aegro stock items
aegro financial installments --status PENDING
```

---

## AI Skills

The project includes guided workflows for AI assistants in `.claude/skills/`:

### Domain skills (personas)

| Skill | Purpose |
|-------|---------|
| `aegro-agronomo` | Agronomic domain — crops, fields, activities, harvests, weather, inputs |
| `aegro-estoquista` | Stock domain — items, locations, movements, catalogs, elements |
| `aegro-financeiro` | Financial domain — bills, installments, categories, bank accounts, companies |
| `aegro-operacional` | Operational domain — farms, auth, tags, cross-domain orchestration |
| `aegro-patrimonial` | Asset domain — machines, vehicles, fuel supplies, maintenances |

### Workflow skills

| Skill | Purpose |
|-------|---------|
| `aegro-visao-geral` | Farm overview dashboard |
| `aegro-fechamento-safra` | Crop season closing checklist |
| `aegro-lancamento-financeiro` | Financial entry guide |
| `aegro-reconciliacao-estoque` | Stock reconciliation |
| `aegro-monitoramento-pragas` | Pest monitoring |
| `aegro-analise-rentabilidade` | Profitability analysis |
| `aegro-cadastro-patrimonio` | Asset registration |

---

## Configuration

### Authentication

Credential resolution priority:

1. `AEGRO_FARMS` env var (JSON) — for CI/CD and scripts
2. `AEGRO_FARMS_FILE` env var (path) — for Docker/K8s secrets
3. `~/.config/aegro/credentials.json` — interactive setup via `aegro auth login`

```bash
# Option 1: Environment variable
export AEGRO_FARMS='{"Fazenda Norte": "aegro_key1", "Fazenda Sul": "aegro_key2"}'

# Option 2: Interactive login (saves to ~/.config/aegro/credentials.json)
aegro auth login --farm-name "Fazenda Norte" --api-key "aegro_key1"
```

### Environment Variables

| Variable | Default | Purpose |
|----------|---------|---------|
| `AEGRO_API_BASE_URL` | `https://app.aegro.com.br` | Aegro API base URL |
| `AEGRO_FARMS` | — | JSON map of farm name → API key |
| `AEGRO_FARMS_FILE` | — | Path to JSON credentials file |

---

## Development

```bash
# Install dependencies
uv sync

# Run tests
uv run pytest -v

# Lint
uv run ruff check aegro/ tests/

# Format
uv run ruff format aegro/ tests/
```

---

## Links

- [Aegro](https://aegro.com.br) — Agricultural management platform
- [Typer](https://typer.tiangolo.com/) — CLI framework
- [PyPI: aegro](https://pypi.org/project/aegro/) — Package page

---

## License

[MIT](LICENSE)
