Metadata-Version: 2.4
Name: bocai-cli-core
Version: 0.2.0
Summary: Shared core for Bocai CLI products
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Requires-Dist: tenacity>=9.0.0
Requires-Dist: tomli-w>=1.0.0
Requires-Dist: typer>=0.12.3
Provides-Extra: dev
Requires-Dist: pytest>=8.2.0; extra == 'dev'
Requires-Dist: respx>=0.21.1; extra == 'dev'
Description-Content-Type: text/markdown

# bocai-cli

使用 Python + Typer 封装 SaaS API 的命令行工具。当前提供健身房和工作室两个产品入口，共享同一套核心代码和配置。

| 产品 | 安装包 | 命令 |
| --- | --- | --- |
| 健身房 | `bocai-cli` | `bocai-cli` |
| 工作室 | `bocai-studio-cli` | `bocai-studio-cli` |

## 开发安装

先安装共享核心，再安装两个产品入口：

```bash
python -m pip install -e .
python -m pip install --no-deps -e packages/bocai-cli -e packages/bocai-studio-cli
```

也可以只安装某一个产品入口：

```bash
python -m pip install --no-deps -e packages/bocai-cli
```

## 构建离线 wheel

构建机需要先安装 hatchling：

```bash
python -m pip install "hatchling>=1.24.2"
```

构建三个同版本 wheel，并同时收集运行依赖：

```bash
python scripts/build_wheels.py
```

如果依赖已经由内网镜像提供，只构建产品 wheel：

```bash
python scripts/build_wheels.py --no-deps
```

构建产物位于 `dist/`，包括 `bocai-cli-core`、`bocai-cli` 和 `bocai-studio-cli`。

## 离线安装

健身房机器：

```bash
python -m pip install --no-index --find-links dist bocai-cli==0.2.0
```

工作室机器：

```bash
python -m pip install --no-index --find-links dist bocai-studio-cli==0.2.0
```

如果机器上已有旧版 `bocai-cli`，仅安装工作室版前先执行：

```bash
python -m pip uninstall -y bocai-cli
```

如果机器上安装过旧包名 `bocai-cli-studio`，先卸载旧包再安装 `bocai-studio-cli`：

```bash
python -m pip uninstall -y bocai-cli-studio
```

## 安装后验证

```bash
bocai-cli --help
bocai-studio-cli --help
bocai-cli report --help
bocai-studio-cli card --help
```

## 工作室命令迁移

健身房版只包含健身房命令，不包含 `studio-*` 命令。工作室能力统一在 `bocai-studio-cli` 中提供，并去掉 `studio-` 前缀。旧版命令迁移如下：

| 旧版 `bocai-cli` 命令 | 新工作室命令 |
| --- | --- |
| `center studio-seller-list` | `bocai-studio-cli center seller-list` |
| `center studio-trainer-list` | `bocai-studio-cli center trainer-list` |
| `member studio-proposed-list` | `bocai-studio-cli member proposed-list` |
| `member studio-member-list` | `bocai-studio-cli member member-list` |
| `card studio-contract-list` | `bocai-studio-cli card contract-list` |
| `card studio-sale-performance` | `bocai-studio-cli card sale-performance` |
| `card studio-private-consume-performance` | `bocai-studio-cli card private-consume-performance` |

`center card-list`、`center source-list`、`center tag-list` 现在只保留在工作室版；健身房 `bocai-cli center` 只提供 `list` 和 `manager-phone`。

`bocai-cli` 暂不提供 `member` 命令组，所有会员命令请使用 `bocai-studio-cli member ...`，包括 `detail`、`proposed-list` 和 `member-list`。

`bocai-cli card contract-detail` 暂时移除，需要使用 `bocai-studio-cli card contract-detail`。

工作室版不提供 `course` 命令组；课程相关命令仅保留在健身房版 `bocai-cli course ...`。

`bocai-studio-cli card sale-performance` 指向工作室销售业绩；`bocai-cli card sale-performance` 仍指向健身房售卡业绩。两组命令不会互相出现在对方的帮助中。

`guanyuan absence-statistics` 和 `guanyuan absence-detail` 按产品设置默认业态：健身房默认 `--type 2`，允许 `2/3`；工作室默认 `--type 1`，只允许 `1`。

## 配置文件

两个产品共用现有配置：

- 优先读取环境变量 `BOCAI_CLI_CONFIG_PATH`。
- 未设置时读取 `~/.config/bocai-cli/config.toml`。
- Windows 默认路径为 `C:\Users\{用户名}\.config\bocai-cli\config.toml`。

`config.toml` 示例（`base_url`、`app_id`、`secret` 按实际替换）：

```toml
base_url = "http://10.0.0.227:10086"
app_id = "test_app_001"
secret = "test_secret_123456"
```
