@optima-chat/bi-cli
Optima BI CLI - E-commerce business intelligence tool designed for LLM agents.
Features
- LLM-Friendly: Detailed help messages with JSON schemas and examples
- JSON Output: All commands output JSON by default for programmatic parsing
- Pretty Tables: Use
--pretty flag for human-readable table format
- Unified Auth: Shared authentication with
commerce-cli and optima-agent
Installation
npm install -g @optima-chat/bi-cli
Quick Start
bi-cli auth login
bi-cli sales get --days 7
bi-cli product best-sellers --limit 10
bi-cli trends revenue --days 30
bi-cli analytics compare --days 7
Authentication
Login
bi-cli auth login
bi-cli auth login --env stage
bi-cli auth login --env development
Check Status
bi-cli auth whoami
bi-cli auth status
bi-cli auth logout
Environment Configuration
| production | auth.optima.onl | bi-api.optima.onl |
| stage | auth.stage.optima.onl | bi-api.stage.optima.onl |
| development | auth.optima.chat | bi-api.optima.chat |
Token Priority
BI_CLI_TOKEN environment variable
OPTIMA_TOKEN environment variable
~/.optima/token.json file
Commands
Sales Analytics
bi-cli sales get
bi-cli sales get --days 30
bi-cli sales get --days 7 --pretty
Returns:
{
"summary": {
"total_revenue": 10000,
"total_orders": 100,
"avg_order_value": 100,
"unique_customers": 80
},
"daily": [{ "date": "2024-01-01", "total_revenue": 1500, "order_count": 15 }]
}
Product Analytics
bi-cli product best-sellers
bi-cli product best-sellers --limit 5
bi-cli product best-sellers --sort quantity
bi-cli product abc-analysis
bi-cli product price-analysis
bi-cli product performance --days 30 --limit 20
Trend Analytics
bi-cli trends revenue
bi-cli trends revenue --granularity hourly
bi-cli trends revenue --granularity weekly
bi-cli trends heatmap
bi-cli trends seasonality
bi-cli trends forecast
bi-cli trends forecast --days 14
Advanced Analytics
bi-cli analytics compare
bi-cli analytics compare --days 7
bi-cli analytics compare --compare-to previous_year
bi-cli analytics growth
bi-cli analytics growth --period weekly
bi-cli analytics growth --period monthly
bi-cli analytics cohort
bi-cli analytics funnel --days 30
Traffic Analytics
bi-cli traffic overview
bi-cli traffic overview --days 7
bi-cli traffic overview --product <uuid>
bi-cli traffic sources --limit 10
bi-cli traffic funnel
bi-cli traffic search
bi-cli traffic search --zero-results
bi-cli traffic pages --limit 20
Output Formats
JSON (Default)
All commands output JSON by default, ideal for LLM agents and programmatic use:
bi-cli sales get | jq .
bi-cli product best-sellers --limit 5 | your-ai-tool
Pretty Tables
Use --pretty flag for human-readable output:
bi-cli sales get --pretty
bi-cli product best-sellers --pretty
Environment Variables
export BI_CLI_TOKEN="your-access-token"
export BI_CLI_BACKEND_URL="https://custom-api.example.com"
export BI_CLI_AUTH_URL="https://custom-auth.example.com"
export BI_CLI_ENV="stage"
For LLM Agents
Each command includes detailed help with:
- Function description
- JSON return structure
- Usage examples
- Parameter descriptions with valid values
bi-cli sales get --help
bi-cli product abc-analysis --help
bi-cli analytics cohort --help
License
MIT