> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jelou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Referencia completa del CLI de Jelou Functions: todos los comandos, flags y variables de entorno.

## Instalación

```bash theme={null}
npm install -g @jelou/cli
```

Verifica:

```bash theme={null}
jelou --version
```

## Autenticación

### `jelou login`

Autenticarse con un token de acceso personal (PAT) o API key de Jelou.

```bash theme={null}
jelou login
# ? Paste your access token: ****
# ? Profile name: default
# ✓ Saved as profile "default"
```

| Flag               | Descripción                        |
| ------------------ | ---------------------------------- |
| `--token <token>`  | Token para uso no interactivo (CI) |
| `--profile <name>` | Nombre del perfil a guardar        |

```bash theme={null}
# CI/CD
jelou login --token jfn_pat_abc123 --profile ci
```

### `jelou logout`

Elimina credenciales almacenadas.

```bash theme={null}
jelou logout              # elimina el perfil activo
jelou logout --all        # elimina todos los perfiles
jelou logout --profile ci # elimina un perfil específico
```

### `jelou whoami`

Muestra la identidad actual.

```bash theme={null}
jelou whoami
# ▸ Type     Personal Access Token
# ▸ Name     alex@jelou.ai
# ▸ Scopes   functions:read, functions:write
# ▸ API      https://app.jelou.ai
# ▸ Profile  default (from credentials file)
```

### `jelou auth list`

Lista todos los perfiles guardados.

```bash theme={null}
jelou auth list
# ▸ Profile    Identity         Type    Active
# ▸ default    alex@jelou.ai    PAT     ✓
# ▸ staging    ci@jelou.ai      PAT
```

### `jelou auth switch [name]`

Cambia el perfil activo.

```bash theme={null}
jelou auth switch staging
```

### `jelou auth remove <name>`

Elimina un perfil.

```bash theme={null}
jelou auth remove staging -y
```

## Proyectos

### `jelou functions init`

Inicializa un proyecto de Jelou Functions.

```bash theme={null}
jelou functions init
# ? What is your function name? mi-funcion
# ? Add a description? Consulta de clientes
# ? Link to existing function or create new? Create new
# ✓ Created mi-funcion
```

| Flag                    | Descripción                         |
| ----------------------- | ----------------------------------- |
| `--slug <slug>`         | Nombre de la función                |
| `--description <desc>`  | Descripción                         |
| `--mode <create\|link>` | Crear nueva o enlazar existente     |
| `--force`               | Sobrescribir `jelou.json` existente |

Genera: `index.ts`, `jelou.json`, `deno.json`, `.env`, `.gitignore`.

### `jelou functions dev`

Inicia el servidor de desarrollo local con hot reload.

```bash theme={null}
jelou functions dev
# ▸ Function     mi-funcion
# ▸ Entrypoint   index.ts
# ▸ Port         3000
# ▸ Mode         define
# ▸ Routes       http://localhost:3000
# ▸ Health       http://localhost:3000/__health
# ▸ MCP          http://localhost:3000/mcp
```

| Flag                 | Descripción                       |
| -------------------- | --------------------------------- |
| `--port <number>`    | Puerto (default: 3000)            |
| `--env <path>`       | Ruta al archivo `.env`            |
| `--no-watch`         | Desactivar hot reload             |
| `--local-sdk <path>` | Usar un SDK local para desarrollo |

<Tip>
  El servidor detecta automáticamente si tu función usa `define()` o `app()` y muestra las rutas correspondientes.
</Tip>

## Despliegue

### `jelou functions deploy`

Despliega a producción.

```bash theme={null}
jelou functions deploy
# ▸ Files: index.ts (1.2 KB), jelou.json (98 B), deno.json (65 B)
# ? Deploy mi-funcion? (Y/n) y
# ✓ Deployed
# ▸ URL: https://mi-funcion.fn.jelou.ai
```

| Flag           | Descripción                          |
| -------------- | ------------------------------------ |
| `--no-confirm` | Omitir confirmación (para CI)        |
| `--follow`     | Streaming de logs después del deploy |

El primer deploy genera automáticamente un runtime token.

### `jelou functions rollback [slug] [id]`

Revierte a un despliegue anterior.

```bash theme={null}
# Interactivo — muestra menú de despliegues recientes
jelou functions rollback

# Directo
jelou functions rollback mi-funcion dep_abc12345
```

### `jelou functions deployments list [slug]`

Lista el historial de despliegues.

```bash theme={null}
jelou functions deployments list mi-funcion
# ▸ ID             Status   Source   Files  Deployed By    Age
# ▸ dep_abc123..   active   cli      3      alex@jelou.ai  2h ago
# ▸ dep_def456..   active   cli      3      ci@jelou.ai    1d ago
```

### `jelou functions deployments info <slug> <id>`

Muestra detalles de un despliegue específico.

```bash theme={null}
jelou functions deployments info mi-funcion dep_abc123
```

### `jelou functions deployments download <slug> <id>`

Descarga el artifact de un despliegue.

```bash theme={null}
jelou functions deployments download mi-funcion dep_abc123 -o artifact.tar.gz
```

## Funciones

### `jelou functions list`

Lista todas las funciones.

```bash theme={null}
jelou functions list
# ▸ Slug               Status   URL                                    Updated
# ▸ consultar-cliente   active   https://consultar-cliente.fn.jelou.ai  4/7/2026
# ▸ webhook-pagos       active   https://webhook-pagos.fn.jelou.ai      4/5/2026
```

### `jelou functions info <slug>`

Muestra detalles de una función.

```bash theme={null}
jelou functions info consultar-cliente
# ▸ Name          consultar-cliente
# ▸ Slug          consultar-cliente
# ▸ Status        active
# ▸ URL           https://consultar-cliente.fn.jelou.ai
# ▸ Deployment    dep_abc12345
```

### `jelou functions create`

Crea una función remota (sin código local).

```bash theme={null}
jelou functions create --slug mi-api --name "Mi API"
```

### `jelou functions delete <slug>`

Elimina una función. Requiere confirmación.

```bash theme={null}
jelou functions delete mi-funcion
# ? Delete function "mi-funcion"? This cannot be undone. (y/N)
```

Usa `-y` para omitir confirmación en CI.

## Secrets

### `jelou secrets list <slug>`

```bash theme={null}
jelou secrets list mi-funcion
# ▸ Key              Updated
# ▸ CRM_API_KEY      2 hours ago
# ▸ JELOU_API_KEY    3 days ago
```

### `jelou secrets set <slug>`

```bash theme={null}
# Inline
jelou secrets set mi-funcion CRM_API_KEY=sk_test_123 DB_URL=postgres://...

# Desde archivo
jelou secrets set mi-funcion --from-env .env.production

# Interactivo
jelou secrets set mi-funcion
```

### `jelou secrets delete <slug> <key>`

```bash theme={null}
jelou secrets delete mi-funcion CRM_API_KEY
```

## Tokens

### `jelou tokens list [slug]`

```bash theme={null}
jelou tokens list mi-funcion
# ▸ Name       Prefix          Last Used              Created
# ▸ default    jfn_rt_abc1..   4/7/2026, 10:30 AM     4/1/2026
# ▸ ci-deploy  jfn_rt_def4..   never                  4/5/2026
```

### `jelou tokens create [slug]`

```bash theme={null}
jelou tokens create mi-funcion --name ci-deploy
# ✓ Created token "ci-deploy"
# ▸ Token    jfn_rt_def456...
# ⚠ Save this token now — it will not be shown again.
```

### `jelou tokens revoke <slug> <token-id>`

```bash theme={null}
jelou tokens revoke mi-funcion token-uuid-123 -y
# ✓ Token revoked
```

## Logs

### `jelou functions logs [slug]`

```bash theme={null}
jelou functions logs mi-funcion              # streaming en vivo (default)
jelou functions logs mi-funcion --history    # logs históricos
jelou functions logs mi-funcion -f           # alias de streaming
```

## Cron

### `jelou functions cron list [slug]`

```bash theme={null}
jelou functions cron list mi-funcion
# ▸ Tool       Expression   Timezone             Last Triggered
# ▸ default    0 9 * * *    America/Guayaquil    2 hours ago
```

### `jelou functions cron logs [slug]`

```bash theme={null}
jelou functions cron logs mi-funcion
jelou functions cron logs mi-funcion --state ERROR
jelou functions cron logs mi-funcion --cursor <cursor>
```

## Flujo

### `jelou skill install`

Instala el flujo de Jelou Functions en herramientas de IA.

```bash theme={null}
jelou skill install           # local (proyecto actual)
jelou skill install --global  # global (todos los proyectos)
jelou skill install --api     # variante enfocada en API
```

## Flags globales

| Flag               | Descripción                     |
| ------------------ | ------------------------------- |
| `--json`           | Output JSON a stdout            |
| `--no-input`       | Desactivar prompts interactivos |
| `--profile <name>` | Usar un perfil específico       |

## Variables de entorno

| Variable         | Descripción                                                 |
| ---------------- | ----------------------------------------------------------- |
| `JELOU_TOKEN`    | Token de autenticación (sin necesidad de `jelou login`)     |
| `JELOU_NO_INPUT` | `1` para modo no interactivo                                |
| `CI`             | `true` para modo no interactivo (detectado automáticamente) |
| `JELOU_PROFILE`  | Perfil por defecto                                          |

<Tip>
  En pipelines de CI, usa `JELOU_TOKEN` como variable de entorno y `--json` para output parseable:

  ```bash theme={null}
  export JELOU_TOKEN=${{ secrets.JELOU_TOKEN }}
  jelou functions deploy --no-confirm --json | jq -r '.data.url'
  ```
</Tip>
