### [mi](https://github.com/av/mi)

> Handle: `mi`

![mi splash image](./harbor-mi.png)

mi is a minimal agentic coding CLI: a loop, shell access, delegation, skills, and an OpenAI-compatible model API. In Harbor it runs against the caller's current directory and can use Harbor inference backends such as Ollama, llama.cpp, vLLM, or LiteLLM.

## Starting

```bash
harbor pull mi
```

Harbor uses the official ghcr.io/av/mi image. mi is a CLI tool that runs on demand:

```bash
# Interactive REPL
harbor mi

# One-shot prompt
harbor mi -p "inspect this project and summarize it"

# Pipe stdin into mi
git diff | harbor mi -p "review this diff"
```

Harbor runs mi with the caller's current directory mounted as the container working directory, so the agent sees the same project path you launched it from.

## Configuration

### Environment Variables

Following options can be set via [`harbor config`](./3.-Harbor-CLI-Reference.md#harbor-config):

```bash
HARBOR_MI_IMAGE                 # Official Docker image for the mi CLI
HARBOR_MI_VERSION               # Official image tag
HARBOR_MI_WORKSPACE             # Persistent MI_HOME directory
HARBOR_MI_OPENAI_BASE_URL       # Default OpenAI-compatible API URL
HARBOR_MI_OPENAI_API_KEY        # Default API key
HARBOR_MI_MODEL                 # Default model
HARBOR_MI_REASONING_EFFORT      # Optional reasoning effort
HARBOR_MI_OLLAMA_MODEL          # Model name used with the Ollama integration
HARBOR_MI_LLAMACPP_MODEL        # Model name used with the llama.cpp integration
HARBOR_MI_VLLM_MODEL            # Model name used with the vLLM integration
HARBOR_MI_LITELLM_MODEL         # Model name used with the LiteLLM integration
```

### Volumes

- `${HARBOR_MI_WORKSPACE}` -> `/home/mi/.mi` - persistent mi config directory.
- The directory where `harbor mi ...` is invoked is mounted at the same absolute path inside the container and used as the working directory.

## Harbor Integrations

Start mi with a Harbor backend to automatically point `OPENAI_BASE_URL`, `OPENAI_API_KEY`, and `MODEL` at that backend:

```bash
harbor up ollama
harbor mi -p "say hello"
```

Available cross-service files:

| Backend | Cross-file |
|---------|------------|
| Ollama | `compose.x.mi.ollama.yml` |
| llama.cpp | `compose.x.mi.llamacpp.yml` |
| vLLM | `compose.x.mi.vllm.yml` |
| LiteLLM | `compose.x.mi.litellm.yml` |

If you want to use a cloud provider directly, configure the default API values:

```bash
harbor config set mi.openai.api.key sk-...
harbor config set mi.model gpt-5.4
```

## Host tool adapter

If you have `mi` installed locally (via npm), `harbor launch mi` runs the local binary against a running Harbor backend instead of the container. This is useful when you want mi to access local files directly without container mounts:

```bash
harbor launch mi -p "say hello"
harbor launch --backend ollama --model qwen3.5:4b mi
harbor launch --web mi -p "search for the latest news"
harbor launch --config mi
```

Use `harbor launch --service mi` to explicitly run the container service through `launch` instead of the host adapter.

## Troubleshooting

```bash
harbor pull mi
harbor mi --help
```

If mi cannot reach a model, check the selected base URL and model:

```bash
harbor config get mi.openai.base.url
harbor config get mi.model
```

For local backends, make sure the backend service is running and has a usable chat model loaded.

## Links

- [GitHub Repository](https://github.com/av/mi)
- [npm Package](https://www.npmjs.com/package/@avcodes/mi)
