161 lines
3.6 KiB
Markdown
161 lines
3.6 KiB
Markdown
# Codemao CLI
|
|
|
|
编程猫 (Codemao) 社区命令行工具。无需登录即可访问公开 API,解析 BCM 作品文件。
|
|
|
|
## 安装
|
|
|
|
```bash
|
|
npm install -g codemao-cli
|
|
```
|
|
|
|
或直接运行:
|
|
|
|
```bash
|
|
npx codemao-cli help
|
|
```
|
|
|
|
## 功能
|
|
|
|
| 命令 | 说明 |
|
|
|------|------|
|
|
| `codemao sample list` | 列出 14 个官方示例作品 |
|
|
| `codemao sample download <id>` | 下载示例 BCM 文件 |
|
|
| `codemao bcm info <file>` | 解析 BCM 文件摘要 |
|
|
| `codemao bcm actors <file>` | 列出所有角色 |
|
|
| `codemao bcm blocks <file>` | 列出所有积木 |
|
|
| `codemao bcm extract <file>` | 提取资源 URL |
|
|
| `codemao work list` | 列出用户作品 (需登录) |
|
|
| `codemao download <template>` | 下载 BCM 模板 |
|
|
| `codemao endpoints [filter]` | 搜索 62 个 API 端点 |
|
|
| `codemao domains` | 显示 13 个域名 |
|
|
| `codemao api <path>` | 直接调用 API |
|
|
|
|
## 快速开始
|
|
|
|
```bash
|
|
# 列出示例作品
|
|
codemao sample list
|
|
|
|
# 下载 "脸萌" 示例
|
|
codemao sample download 2
|
|
|
|
# 查看作品结构
|
|
codemao bcm info 脸萌.bcmkn
|
|
|
|
# 提取所有图片/音频 URL
|
|
codemao bcm extract 脸萌.bcmkn
|
|
|
|
# 下载默认模板
|
|
codemao download default-v
|
|
```
|
|
|
|
## BCM 文件格式
|
|
|
|
BCM (Block Code Metadata) 是编程猫的积木作品文件格式,纯 JSON 结构:
|
|
|
|
```json
|
|
{
|
|
"projectName": "我的作品",
|
|
"version": "0.18.0",
|
|
"toolType": "KN",
|
|
"stageSize": { "width": 562, "height": 900 },
|
|
"scenes": {
|
|
"scenesDict": { "scene-uuid": { "name": "背景", "actorIds": [...] } }
|
|
},
|
|
"actors": {
|
|
"actorsDict": { "actor-uuid": { "name": "角色", "nekoBlockJsonList": [...] } }
|
|
},
|
|
"styles": {
|
|
"stylesDict": { "style-uuid": { "name": "造型", "url": "https://..." } }
|
|
},
|
|
"audios": { "audiosDict": {} },
|
|
"variables": { "variablesDict": {} },
|
|
"broadcasts": { "broadcastsDict": {} },
|
|
"procedures": { "proceduresDict": {} }
|
|
}
|
|
```
|
|
|
|
### 积木结构
|
|
|
|
```json
|
|
{
|
|
"type": "sprite_on_tap",
|
|
"id": "block-uuid",
|
|
"fields": { "type": "mouse_click", "sprite": "actor-uuid" },
|
|
"parent_id": "",
|
|
"next": { "type": "self_prev_next_style", "id": "..." }
|
|
}
|
|
```
|
|
|
|
### 已知积木类型
|
|
|
|
| 类型 | 说明 |
|
|
|------|------|
|
|
| `sprite_on_tap` | 角色点击事件 |
|
|
| `event_when_run` | 绿旗点击 |
|
|
| `event_when_key` | 按键事件 |
|
|
| `move` | 移动 |
|
|
| `turn_right` / `turn_left` | 转向 |
|
|
| `goto_xy` | 移到坐标 |
|
|
| `show` / `hide` | 显示/隐藏 |
|
|
| `say` | 说话 |
|
|
| `wait` | 等待 |
|
|
| `repeat` | 重复 |
|
|
| `forever` | 重复执行 |
|
|
| `if` / `if_else` | 条件判断 |
|
|
| `self_prev_next_style` | 切换造型 |
|
|
|
|
## API 端点
|
|
|
|
完整端点列表 (62 个):
|
|
|
|
```bash
|
|
codemao endpoints # 全部
|
|
codemao endpoints ranking # 搜索
|
|
codemao search 作品 # 搜索
|
|
```
|
|
|
|
### 公开端点 (无需登录)
|
|
|
|
| 端点 | 说明 |
|
|
|------|------|
|
|
| `GET /neko/sample/list` | 示例作品列表 |
|
|
| `GET /neko/sample/detail` | 示例作品详情 |
|
|
| `GET /coconut/clouddb/currentTime` | 云数据库时间 |
|
|
| `GET /tiger/online/check` | 在线检查 |
|
|
|
|
### 需认证端点
|
|
|
|
设置环境变量:
|
|
|
|
```bash
|
|
export CODEMAO_COOKIE="your_cookie_value"
|
|
```
|
|
|
|
从浏览器开发者工具获取 Cookie。
|
|
|
|
## 域名
|
|
|
|
| 名称 | 域名 | 用途 |
|
|
|------|------|------|
|
|
| creation | api-creation.codemao.cn | 创作服务 |
|
|
| api | api.codemao.cn | 主 API |
|
|
| open | open-service.codemao.cn | 开放服务 |
|
|
| ai | cr-aichat.codemao.cn | AI 服务 |
|
|
| cdn | creation.codemao.cn | CDN 资源 |
|
|
| staticCdn | static.codemao.cn | 静态资源 |
|
|
| bcmcdn | creation.bcmcdn.com | BCM CDN |
|
|
|
|
## 开发
|
|
|
|
```bash
|
|
git clone https://gitee.com/shuiyu1123/codemao-cli
|
|
cd codemao-cli
|
|
npm install
|
|
npm test
|
|
```
|
|
|
|
## License
|
|
|
|
MIT
|