# 安裝 CLI
URL: /zh-TW/docs/install/cli

使用安裝腳本、SPIRIT_HOME 和 SPIRIT_VERSION 安裝 Spirit Agent CLI。



CLI 是一個終端主機，具有 TUI 和非互動式 `-p` 模式。它與 [Desktop](./desktop.mdx) 使用相同的本地守護程序。

## 安裝腳本 [#安裝腳本]

macOS 和 Linux：

```bash
curl -fsSL https://spirit.fast/install | bash
```

Windows（PowerShell）：

```powershell
irm https://spirit.fast/install.ps1 | iex
```

該腳本從 `download.spirit.fast` 下載構建，解壓縮，並將 `spirit` 放入您的 `PATH`。

打開一個新的終端，然後：

```bash
spirit --version
```

## 安裝位置 [#安裝位置]

安裝根目錄**不是** Spirit Agent 資料目錄。

|               | 預設                                                                                                                       | 覆寫                      |
| ------------- | ------------------------------------------------------------------------------------------------------------------------ | ----------------------- |
| CLI 二進位檔      | Unix：`~/.spirit` · Windows：`%LOCALAPPDATA%\Spirit`                                                                       | `SPIRIT_HOME`           |
| 工作階段、設定、金鑰環指標 | macOS：`~/Library/Application Support/SpiritAgent` · Windows：`%APPDATA%\SpiritAgent` · Linux：`~/.local/share/SpiritAgent` | `SPIRIT_AGENT_DATA_DIR` |

在 Unix 上，腳本會建立 `$SPIRIT_HOME/bin/spirit` → `$SPIRIT_HOME/cli/current/bin/spirit` 的符號連結，並將 `export PATH="$SPIRIT_HOME/bin:$PATH"` 附加到 `~/.profile`、`~/.bashrc` 和 `~/.zshrc`（標記為 `# spirit-agent cli`）。

## 固定版本或鏡像 [#固定版本或鏡像]

| 變數                     | 預設                                    | 角色             |
| ---------------------- | ------------------------------------- | -------------- |
| `SPIRIT_HOME`          | `~/.spirit` 或 `%LOCALAPPDATA%\Spirit` | CLI 二進位檔的安裝根目錄 |
| `SPIRIT_VERSION`       | `latest`                              | 下載 URL 中的版本段   |
| `SPIRIT_DOWNLOAD_HOST` | `download.spirit.fast`                | CDN 主機         |

```bash
SPIRIT_VERSION=0.1.0 curl -fsSL https://spirit.fast/install | bash
```

您也可以從[下載頁面](/en-US/download)或 [GitHub Releases](https://github.com/SpiritAgents/SpiritAgent/releases/latest) 下載 CLI 壓縮檔，然後自行解壓縮。

## 首次執行 [#首次執行]

```bash
cd /path/to/your/project
spirit
```

這會開啟 TUI。使用 `/model add` 新增供應商，或從 shell 使用 `spirit model add`。請參閱[快速入門](../quickstart.mdx)。
