---
name: game-student-deploy
description: Student-facing deployment workflow for uploading static game homework to the fixed game.cihua.run learning server. Use when a learner asks Codex or another AI agent to deploy a static HTML/CSS/JS game, save a latest build, publish a fixed version under versions/v0.0.x, initialize or remember their deployment ID, or troubleshoot basic SSH/SCP upload prerequisites without touching Nginx, DNS, certificates, firewall, sudo, or other students' directories.
---

# Game Student Deploy

Use this skill when a learner says things like "帮我部署这个游戏", "上传当前版本", "发布 v0.0.3", or "把作业放到 game.cihua.run".

This skill deploys static game files only. It does not deploy backends. Online multiplayer backends are managed by the teacher as shared services; student projects only connect to those services from their frontend.

## Server Contract

- Public learning entry: `https://game.cihua.run/learn/`
- Student game URL: `https://game.cihua.run/<student-id>/<project>/`
- Fixed version URL: `https://game.cihua.run/<student-id>/<project>/versions/v0.0.x/`
- SSH host: `38.207.178.253`
- SSH port: `8398`
- Remote root: `/var/www/game.cihua.run/<student-id>/`

The teacher has already configured Nginx, HTTPS, DNS, and the student's SSH account.

## First Use

If the local deployment ID is missing, ask the learner:

```text
你的部署 ID 是什么？老师给你的 ID 一般也是你的网址路径，例如 fara 或 zqy。
```

Then save it with:

```bash
python3 /path/to/game-student-deploy/scripts/deploy_student_game.py init --student-id <student-id>
```

The script stores non-secret config at:

- macOS/Linux: `~/.config/game-student-deploy/config.json`
- Windows: `%APPDATA%\game-student-deploy\config.json`

## Deploy Workflow

1. Confirm the project folder or `index.html`.
2. Confirm the project slug, such as `gomoku` or `badminton`.
3. Run a local doctor check if upload tools might be missing:

   ```bash
   python3 /path/to/game-student-deploy/scripts/deploy_student_game.py doctor
   ```

4. Package and preview the deployment:

   ```bash
   python3 /path/to/game-student-deploy/scripts/deploy_student_game.py deploy <source-path> <project> latest --dry-run
   ```

5. Deploy latest:

   ```bash
   python3 /path/to/game-student-deploy/scripts/deploy_student_game.py deploy <source-path> <project> latest --yes
   ```

6. Deploy a fixed version:

   ```bash
   python3 /path/to/game-student-deploy/scripts/deploy_student_game.py deploy <source-path> <project> v0.0.1 --yes
   ```

7. Report both URLs when relevant:

   ```text
   latest: https://game.cihua.run/<student-id>/<project>/
   fixed:  https://game.cihua.run/<student-id>/<project>/versions/v0.0.1/
   ```

## Allowed

- Upload static files for the current student's own project.
- Replace the latest project files.
- Create a new fixed version under `versions/v0.0.x/`.
- Update `README.md`, `RELEASES.md`, screenshots, and static assets.
- Let Codex install or enable the smallest missing local upload tool when safe.

## Not Allowed

- Do not use `sudo`.
- Do not edit Nginx, DNS, HTTPS certificates, firewall, or server users.
- Do not upload `.env`, private keys, passwords, tokens, or SSH config.
- Do not write outside `/var/www/game.cihua.run/<student-id>/`.
- Do not overwrite an existing fixed version.
- Do not deploy backend services or bind public ports.

If a project needs a backend, stop and tell the teacher. For online Gomoku, use the teacher-managed shared service instead of deploying a student backend.

## Windows and Missing Tools

Do not expect the learner to understand Git Bash, WSL, OpenSSH, or SCP.

Use the script's `doctor` output to decide what is missing. If `ssh` or `scp` is unavailable, Codex may install or enable a minimal SSH/SCP upload tool when the platform supports it. If installation requires administrator permission, a system prompt, or unclear changes, stop and ask the learner to confirm or send the error to the teacher.

## Release Rules

- `latest` replaces current project files but preserves the remote `versions/` directory.
- `v0.0.x` publishes to `versions/v0.0.x/`.
- Fixed versions are immutable by default: if the remote version path already exists, stop.
- The package must contain a root-level `index.html`.
- Version paths use `/versions/v0.0.x/`, not `/<project>/v0.0.x/`.
