# 安装 Shoplazza CLI

> 在 macOS、Windows 或 Linux 上通过 npm、安装脚本或 GitHub Release 二进制包安装 Shoplazza CLI，并验证版本、开启 Shell 补全。

本指南介绍如何在 macOS、Windows 或 Linux 上安装 [Shoplazza CLI](/zh-CN/docs/app/developer-tools/shoplazza-cli/)。

## 系统要求

| 依赖 | 版本 |
|------|------|
| [Node.js](https://nodejs.org/en/download) | 16.0.0 或更高 |
| [Git](https://git-scm.com/downloads) | 建议最新版 |

:::tip
Node.js 仅在 Checkout 扩展工具链（Vite）和通过 npm 更新的 `shoplazza update` 中需要。如果只使用 API 命令和快捷命令，独立二进制文件无需 Node.js。
:::

## 通过 npm 安装（推荐）

```shell
npm install -g shoplazza-cli
```

## 通过脚本安装（macOS / Linux）

```shell
curl -fsSL https://raw.githubusercontent.com/shoplazza/shoplazza-cli/main/install.sh | bash
```

脚本会自动检测操作系统和架构，下载对应的二进制文件并放置在 `/usr/local/bin`（设置 `INSTALL_DIR` 可改用其他目录）。

安装指定版本时设置 `VERSION`（不带前缀 `v`）：

```shell
curl -fsSL https://raw.githubusercontent.com/shoplazza/shoplazza-cli/main/install.sh | VERSION=2.0.0 bash
```

## 通过 Homebrew 安装（macOS / Linux）

```shell
brew install Shoplazza/tap/shoplazza-cli
```

## 从 GitHub Releases 安装

从 [GitHub Releases](https://github.com/shoplazza/shoplazza-cli/releases) 页面下载对应平台的预编译二进制文件。

| 平台 | 架构 | 文件名 |
|------|------|--------|
| macOS | Intel (x86_64) | `shoplazza-cli-<version>-darwin-amd64.tar.gz` |
| macOS | Apple Silicon (arm64) | `shoplazza-cli-<version>-darwin-arm64.tar.gz` |
| Linux | x86_64 | `shoplazza-cli-<version>-linux-amd64.tar.gz` |
| Linux | arm64 | `shoplazza-cli-<version>-linux-arm64.tar.gz` |
| Windows | x86_64 | `shoplazza-cli-<version>-windows-amd64.zip` |
| Windows | arm64 | `shoplazza-cli-<version>-windows-arm64.zip` |

下载后解压并移动到 `PATH` 目录：

```shell
tar -xzf shoplazza-cli-2.2.2-darwin-arm64.tar.gz
sudo mv shoplazza /usr/local/bin/
```

## 验证安装

```shell
shoplazza --version
```

该命令会打印版本号和构建日期，以及 Agent Skills 是否已安装。

## Shell 自动补全

```shell
# Bash
shoplazza completion bash > /etc/bash_completion.d/shoplazza

# Zsh
shoplazza completion zsh > "${fpath[1]}/_shoplazza"

# Fish
shoplazza completion fish > ~/.config/fish/completions/shoplazza.fish

# PowerShell
shoplazza completion powershell > shoplazza.ps1
```

## 升级

```shell
# npm（同时刷新 API 元数据和已安装的 Agent Skills）
shoplazza update
# 或
npm update -g shoplazza-cli

# Homebrew
brew upgrade shoplazza-cli

# 脚本（重新执行安装脚本）
curl -fsSL https://raw.githubusercontent.com/shoplazza/shoplazza-cli/main/install.sh | bash
```

## 下一步

* [快速上手](./quickstart) — 安装、认证并运行第一个命令
* [认证](./authentication) — 设置 OAuth 2.0 凭证
* [命令参考](./commands/) — 查看所有可用命令
