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

# MITHUNAI Command Line Interface (CLI)

> Manage knowledge sources, trigger ingestion pipelines, query assistants, and run automated evaluation benchmarks directly from your terminal or CI/CD workflows.

The MITHUNAI CLI provides command-line control over your enterprise knowledge collections, document ingestion pipelines, and grounded assistants. Designed for developers and automated CI/CD environments, the tool enables scripted repository indexing upon git commit, headless verification of documentation changes, and instant terminal querying.

```bash Terminal Ingestion Workflow theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Authenticate your terminal session
mithunai login --key "$MITHUNAI_API_KEY"

# Trigger a sync on a GitHub documentation source
mithunai sync trigger --source src_gh_01j982 --wait

# Test an answer directly from the command line
mithunai ask --assistant asst_prod_01 "How do I revoke an API key?"
```

***

## Installation

Install the MITHUNAI CLI globally using npm, pnpm, or Homebrew:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Via npm
npm install -g @mithunai/cli

# Via Homebrew
brew install mithunaihq/tap/mithunai
```

***

## Core Command Reference

### `mithunai login`

Configures authentication for the current developer environment.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
mithunai login --key "arukz_sk_..." --endpoint "https://app.mithunai.com"
```

Credentials are saved in `~/.config/mithunai/config.json` with restricted file permissions (`chmod 600`).

### `mithunai knowledge`

Manages corporate collections and data connectors.

| Subcommand | Description                                    | Example                                                |
| :--------- | :--------------------------------------------- | :----------------------------------------------------- |
| `list`     | Displays all collections and sources.          | `mithunai knowledge list`                              |
| `upload`   | Uploads local Markdown, PDF, or Word files.    | `mithunai knowledge upload --collection col_01 ./docs` |
| `sync`     | Triggers delta re-indexing on a source.        | `mithunai knowledge sync src_gh_01 --wait`             |
| `status`   | Checks background ingestion worker job status. | `mithunai knowledge status --job job_99812`            |

### `mithunai ask`

Interactively queries an assistant from the terminal with rendered citation footnotes.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
mithunai ask --assistant asst_prod_01 "Explain the prompt fencing algorithm"
```

Output format options include `--format pretty` (default ANSI colored Markdown), `--format json` (complete citations and confidence scores), and `--format raw` (prose only for shell piping).

***

## CI/CD Pipeline Integration

Integrate MITHUNAI into GitHub Actions or GitLab CI to keep knowledge continuously updated whenever documentation or code changes:

```yaml GitHub Actions Workflow (.github/workflows/mithunai-sync.yml) theme={"theme":{"light":"github-light","dark":"github-dark"}}
name: Sync Documentation to MITHUNAI
on:
  push:
    branches: [main]
    paths:
      - 'docs/**'
      - 'README.md'

jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install MITHUNAI CLI
        run: npm install -g @mithunai/cli
      - name: Trigger Source Re-Index
        env:
          MITHUNAI_API_KEY: ${{ secrets.MITHUNAI_API_KEY }}
        run: |
          mithunai sync trigger --source ${{ secrets.MITHUNAI_SOURCE_ID }} --wait --timeout 300
```
