# Getting Started

A 5-minute walkthrough to get OpenLife CLI running on your machine.

## 1. Install globally

```bash
npm install -g @openlife/cli
openlife --version
```

You should see the current version (matching the npm tag).

## 2. Run the wizard

```bash
openlife init
```

The wizard prints the OpenLife banner, then walks you through:

1. **Profile** — choose `framework` (CLI only), `autonomous` (daemon),
   or `both`. `both` installs the autonomous profile, which includes
   the framework layer.
2. **Host** — `claude-code`, `gemini-cli`, or `codex`. Auto-detected
   when you launch `openlife init` from inside one of these CLIs.
3. **API keys** — paste your `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`,
   `GEMINI_API_KEY`, and/or `OPENROUTER_API_KEY`. Press Enter to skip
   any one. Keys are saved to `.env` in the project directory.
4. **OAuth pointer** — answer `y` if you plan to use `openlife auth
   gemini` or `openlife auth openai` later. The wizard does not start
   the OAuth flow itself; it just reminds you to run those commands
   after init completes.
5. **Model chain** — comma-separated `provider/model` list, e.g.
   `openai-api/gpt-5.4-mini,anthropic-api/claude-sonnet-4-6`. Leave
   blank to accept the defaults from `models.json`.
6. **Telegram** (autonomous only) — confirm whether `TELEGRAM_BOT_TOKEN`
   and `OPENLIFE_TELEGRAM_ALLOWED_USER_ID` are already in `.env`.
7. **Doctor** — answer `n` to run system diagnostics after install.
8. **Confirm** — review the summary and answer `Y` to proceed.

When the wizard finishes you should see:

```
✅ OpenLife ready.

Try:
  openlife ask "hello, what can you do?"
  openlife status
  openlife --help

Docs: https://github.com/GOOODZ/openlife-core
```

## 3. Try your first command

```bash
openlife ask "summarize this README in one sentence"
```

OpenLife will route the request to the highest-priority model in your
chain that has a working key. If no API key is configured, it falls
back to local Ollama (if available) or returns an error.

## 4. Common follow-ups

- **Set up OAuth (no API key needed):**
  ```bash
  openlife auth gemini    # browser-based Google login
  openlife auth openai    # browser-based OpenAI login
  ```
- **Start the autonomous daemon (autonomous profile):**
  ```bash
  openlife start --daemon
  ```
- **Inspect runtime state:**
  ```bash
  ls .openlife/
  cat .openlife/heartbeat.json
  cat .openlife/install-manifest.json
  ```
- **Update to latest version:**
  ```bash
  npm install -g @openlife/cli@latest
  ```

## Troubleshooting

### `openlife: command not found` after install

The global npm bin directory is probably not on your `PATH`. Run:

```bash
npm bin -g
```

Add that path to your shell profile (`~/.bashrc`, `~/.zshrc`).

### `npm install -g` says EEXIST

You have a leftover symlink from a previous `npm link`. Run:

```bash
npm unlink -g @openlife/cli
rm -f $(which openlife)
npm install -g @openlife/cli
```

### `openlife ask` fails with `MODEL_TIMEOUT` or `no provider available`

No API key is configured and no fallback (Ollama, OAuth) is wired up.
Either:

- Edit `.env` to add `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or
  `GEMINI_API_KEY`, then retry, or
- Run `openlife auth gemini` / `openlife auth openai` to use OAuth, or
- Start a local Ollama server (`ollama serve`) and set
  `OPENLIFE_ENABLE_OLLAMA=true` in `.env`.

### Telegram autonomous mode reports `TELEGRAM_NOT_CONFIGURED`

Set both in `.env`:

```
TELEGRAM_BOT_TOKEN=<from BotFather>
OPENLIFE_TELEGRAM_ALLOWED_USER_ID=<your Telegram user id>
```

Then restart with `openlife start --daemon`.

## Where to go next

- [INSTALL.md](../INSTALL.md) — full install options including
  non-interactive (`openlife system setup`) for CI use.
- [README.md](../README.md) — feature overview and architecture.
- [CHANGELOG.md](../CHANGELOG.md) — what changed across versions.
- [CONTRIBUTING.md](../CONTRIBUTING.md) — dev setup and conventions.
