# CredVault Intelligence Engine (CIE) CLI

Command-line interface for the CredVault Intelligence Engine - AI/ML platform for researchers, developers, and enterprises.

## Installation

```bash
npm install -g credvault-cie
```

## Quick Start

```bash
# Login to your account
cie login

# Upload a dataset
cie data upload customers.csv

# Train a model
cie train ds_abc123

# Make predictions
cie predict md_xyz789 --data '{"age": 25, "income": 50000}'
```

## Commands

### Authentication

```bash
# Login with email/password
cie login

# Login to specific tenant
cie login --tenant tenant_abc123

# Check current session
cie whoami

# Configure defaults
cie configure

# Logout
cie logout
```

### Data Management

```bash
# Upload dataset
cie data upload dataset.csv

# List all datasets
cie data list

# List datasets (JSON output)
cie data list --output json

# Delete dataset
cie data delete ds_abc123

# Delete without confirmation
cie data delete ds_abc123 --force
```

### Model Training

```bash
# Train model on dataset
cie train ds_abc123

# Train with custom name
cie train ds_abc123 --name "Customer Prediction Model"

# Train specific model type
cie train ds_abc123 --type classification

# List all models
cie models list

# Get model details
cie models info md_xyz789

# Export trained model
cie models export md_xyz789
cie models export md_xyz789 --output ./my-model.zip
```

### Predictions

```bash
# Single prediction
cie predict md_xyz789 --data '{"age": 25, "income": 50000}'

# Batch prediction from file
cie predict md_xyz789 --file input.json

# Stream live predictions
cie stream md_xyz789
```

### Deployment

```bash
# Deploy model to production
cie deploy md_xyz789 --env production

# Deploy to staging
cie deploy md_xyz789 --env staging

# List all jobs
cie jobs list

# Check job status
cie job status job_abc123
```

### IoT/Robotics Integration

```bash
# Connect robot/device
cie robot connect robot_001

# Monitor robot data
cie robot monitor robot_001

# Sync workspace
cie sync
```

### Utilities

```bash
# View logs
cie logs

# View last 100 logs
cie logs --lines 100

# Test API connectivity
cie test

# Check CLI version
cie version

# Update CLI
cie update
```

## Global Options

```bash
# Verbose output (detailed logging)
cie data list --verbose

# Quiet mode (minimal output, useful for scripts)
cie data upload file.csv --quiet

# JSON output (machine-readable)
cie models list --output json
```

## Configuration

Configuration is stored in `~/.cie/config.json`

```json
{
  "apiUrl": "https://api.credvault.com",
  "defaultRegion": "us-east-1",
  "defaultEnvironment": "production",
  "defaultCluster": "cluster_abc123"
}
```

## Authentication

Credentials are securely stored in `~/.cie/credentials`

Session tokens expire after 7 days. Run `cie login` to refresh.

## Exit Codes

- `0` - Success
- `1` - General error
- `2` - Authentication error
- `3` - Not found error
- `4` - Validation error

## Examples

### Complete Workflow

```bash
# 1. Login
cie login
# Email: researcher@university.edu
# Password: ********
# Login successful

# 2. Upload training data
cie data upload research-data.csv
# Dataset uploaded: ds_abc123
# Records: 50000

# 3. Start training
cie train ds_abc123 --name "Research Model"
# Training started: job_xyz789
# Model ID: md_123456

# 4. Monitor progress
cie job status job_xyz789
# Status: running
# Progress: 67%

# 5. Make predictions
cie predict md_123456 --data '{"feature1": 10, "feature2": 20}'
# Prediction: {"result": "positive", "confidence": 0.94}

# 6. Deploy to production
cie deploy md_123456 --env production
# Model deployed
# API Endpoint: https://api.credvault.com/v1/models/md_123456/predict
```

### Automation Scripts

```bash
#!/bin/bash
# Automated training pipeline

# Upload new data
DATASET_ID=$(cie data upload new-data.csv --quiet)

# Train model
JOB_ID=$(cie train $DATASET_ID --quiet | grep -o 'job_[a-z0-9]*')

# Wait for completion
while [ "$(cie job status $JOB_ID --output json | jq -r '.status')" != "completed" ]; do
  sleep 30
done

# Deploy
cie deploy $(cie job status $JOB_ID --output json | jq -r '.modelId') --env production
```

