# Opik TS - Interactive Setup Tool

> A guided CLI tool for quickly integrating Opik SDK into your Node.js/TypeScript projects with automatic configuration and setup.

The Opik TS is an interactive command-line tool that streamlines the process of adding Opik observability to your Node.js and TypeScript applications. It automatically detects your project setup, installs dependencies, and configures tracing for your LLM integrations.

## Features

* **🔍 Smart Detection**: Automatically detects your project setup (package manager, TypeScript configuration, existing integrations)
* **📦 Package Management**: Supports npm, yarn, pnpm, and bun
* **⚙️ Environment Configuration**: Creates or updates `.env` files with proper Opik configuration

## Getting Started

### Basic Usage

Run the CLI in your project directory:

```bash
npx opik-ts configure
```

The CLI will guide you through:

1. **Project Detection**: Identifies your package manager and project structure
2. **Dependency Installation**: Installs Opik SDK and integration packages
3. **Environment Setup**: Configures API keys and environment variables
4. **Code Generation**: Sets up Opik client in your root project folder
5. **Formatting**: Optionally applies Prettier formatting

### Requirements

* **Node.js**: Version 18 or higher
* **Package Manager**: npm, yarn, pnpm, or bun
* **Supported Project Types**:
  * Node.js applications
  * TypeScript projects
  * Express/Fastify APIs

## CLI Options

The CLI supports several command-line options for customization:

| Option            | Type    | Default           | Description                                                    | Environment Variable    |
| ----------------- | ------- | ----------------- | -------------------------------------------------------------- | ----------------------- |
| `--help`          | boolean | -                 | Display help information                                       | -                       |
| `--version`       | boolean | -                 | Show version number                                            | -                       |
| `--debug`         | boolean | `false`           | Enable verbose logging for troubleshooting                     | `OPIK_TS_DEBUG`         |
| `--default`       | boolean | `true`            | Use default options for all prompts (non-interactive)          | `OPIK_TS_DEFAULT`       |
| `--force-install` | boolean | `false`           | Force package installation even if peer dependency checks fail | `OPIK_TS_FORCE_INSTALL` |
| `--install-dir`   | string  | current directory | Specify custom installation directory                          | `OPIK_TS_INSTALL_DIR`   |
| `--use-local`     | boolean | `false`           | Skip deployment selection and configure for local development  | `OPIK_TS_USE_LOCAL`     |

### Examples

**Verbose debugging mode:**

```bash
npx opik-ts configure --debug
```

**Non-interactive mode with defaults:**

```bash
npx opik-ts configure --default
```

**Install in a specific directory:**

```bash
npx opik-ts configure --install-dir=./my-app
```

**Force installation (skip peer dependency checks):**

```bash
npx opik-ts configure --force-install
```

**Local development setup:**

```bash
npx opik-ts configure --use-local
```

This will skip the deployment selection step and automatically configure your environment for local development (localhost:5173).

## Environment Configuration

The CLI automatically creates or updates your `.env` file with the necessary configuration:

```bash