Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 48 additions & 63 deletions SKILL.md
Original file line number Diff line number Diff line change
@@ -1,113 +1,98 @@
---
---
name: text-legend-openclaw-deploy
description: Install OpenClaw/Skillhub (if needed) and deploy Text-Legend with Docker Compose (MySQL/SQLite), including start/stop and health checks.
description: "Set up, deploy, and manage Text-Legend game server using Docker Compose with MySQL or SQLite. Handles OpenClaw/Skillhub installation, container orchestration, database configuration, service health checks, and local Node.js development. Use when the user wants to run, start, stop, or troubleshoot Text-Legend services."
metadata: {"clawdbot":{"requires":{"anyBins":["docker"]},"os":["win32","linux","darwin"]}}
---

# Text-Legend OpenClaw 部署技能

本技能用于在本仓库中自动化部署与运行 Text-Legend。覆盖以下任务:

- 安装 OpenClaw/Skillhub(仅在用户明确要求时)
- 检查 Docker 与 Compose 环境
- 填充 `docker-compose.mysql.yml` 的数据库配置
- 启动与停止服务
- 基本访问验证与日志查看
- 本地 npm 运行(非 Docker)
# Text-Legend Deployment Skill

## 触发场景
Automate deployment and management of Text-Legend in this repository.

- 用户希望用 OpenClaw 自动部署/运行本项目
- 用户需要一键启动(MySQL 或 SQLite)
- 用户需要标准化的启动/停止/日志命令
## Workflow

## 操作流程
### 1. Install OpenClaw/Skillhub (only when user explicitly requests)

### 1. 安装 OpenClaw/Skillhub(仅在用户要求时)

如果用户明确要安装 OpenClaw 生态或 Skillhub,提供以下命令并提醒会下载远程脚本:
Warn the user that this downloads and runs a remote script before executing:

```bash
# Full install
curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash
```

仅安装 CLI:

```bash
# CLI only
curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash -s -- --cli-only
```

安装后提醒用户重启 OpenClaw 以加载 Skillhub
Remind the user to restart OpenClaw after installation to load Skillhub.

### 2. 环境检查

确认 Docker 可用:
### 2. Verify Docker Environment

```bash
docker version
docker compose version
```

若 `docker compose` 不存在,提示用户升级 Docker Desktop 或安装 Compose 插件。
If `docker compose` is missing, prompt the user to upgrade Docker Desktop or install the Compose plugin. Do not proceed until both commands succeed.

### 3. Configure Database and Admin Account

### 3. 配置数据库与后台账号
Edit `docker-compose.mysql.yml` with the required environment variables:

编辑 `docker-compose.mysql.yml`,填入以下环境变量:
- `DB_HOST`, `DB_USER`, `DB_PASSWORD`, `DB_NAME`
- `ADMIN_BOOTSTRAP_SECRET`, `ADMIN_BOOTSTRAP_USER`

- `DB_HOST`
- `DB_USER`
- `DB_PASSWORD`
- `DB_NAME`
- `ADMIN_BOOTSTRAP_SECRET`
- `ADMIN_BOOTSTRAP_USER`
If the user does not have MySQL, use the SQLite path (step 4b).

若用户没有 MySQL,改用 SQLite 流程:
### 4. Start Services

**4a. MySQL:**

```bash
docker compose up --build
docker compose -f docker-compose.mysql.yml up -d
```

### 4. 启动服务(MySQL)
**4b. SQLite:**

```bash
docker compose -f docker-compose.mysql.yml up -d
docker compose up --build
```

### 5. 访问验证
### 5. Verify Deployment

- 游戏:`http://localhost:3000/`
- 后台:`http://localhost:3000/admin/`
Run a health check to confirm the service is responding:

### 6. 常用运维
```bash
curl -sf http://localhost:3000/ -o /dev/null && echo "Game server: OK" || echo "Game server: FAILED"
curl -sf http://localhost:3000/admin/ -o /dev/null && echo "Admin panel: OK" || echo "Admin panel: FAILED"
```

- 查看日志:`docker logs -f text-legend`
- 停止服务:`docker compose -f docker-compose.mysql.yml down`
If either check fails:

### 7. 本地 npm 运行(非 Docker)
1. Check container status: `docker compose ps`
2. Review logs: `docker logs -f text-legend`
3. Common issues: port 3000 already in use, missing environment variables, database connection refused.

前置条件:
### 6. Operations

- Node.js 24+(建议 LTS)
- 可用的 SQLite 或 MySQL
- View logs: `docker logs -f text-legend`
- Stop (MySQL): `docker compose -f docker-compose.mysql.yml down`
- Stop (SQLite): `docker compose down`

步骤:
### 7. Local Node.js Development (non-Docker)

Prerequisites: Node.js 24+ (LTS recommended), SQLite or MySQL available.

```bash
npm install
node src/index.js
```

若使用 MySQL,确保已通过环境变量提供连接信息(`DB_CLIENT=mysql` 等)。
若使用 SQLite,建议设置:

- `DB_CLIENT=sqlite`
- `DB_FILENAME=/app/data/game.sqlite`(可按本地路径调整)
- `DB_POOL_MAX=1`
For MySQL, set connection variables (`DB_CLIENT=mysql`, `DB_HOST`, etc.).
For SQLite, set: `DB_CLIENT=sqlite`, `DB_FILENAME=./data/game.sqlite`, `DB_POOL_MAX=1`.

默认端口:`3000`
Default port: `3000`.

## 注意事项
## Important

- 仅在用户明确授权时运行远程安装脚本。
- 不要在日志或输出中泄漏数据库密码或 GM 密钥。
- 如需持久化数据,请确认 `./data` 已挂载并可写。
- Only run remote install scripts when the user explicitly authorizes it.
- Never expose database passwords or GM keys in logs or output.
- For data persistence, confirm `./data` is mounted and writable.