npm package: @minirts/cli
Description: CLI tool and workspace manager for miniRTS strategy development
Author: Pelith
Latest version: 0.0.1-alpha.2

# minirts-cli

CLI tool and workspace manager for [miniRTS](https://github.com/example/minirts) strategy development.

## Installation

```bash
npm install -g @minirts/cli
# or
npx @minirts/cli
```

Requires Node.js >= 22.

## Quick Start

```bash
# Create a workspace
mkdir my-rts && cd my-rts
minirts init

# Set server and register
minirts config set server_url https://your-server.com
minirts register YourName

# Edit your strategy
# (edit scripts/current.js)

# Validate and upload
minirts script validate
minirts script upload

# Battle!
minirts battle

# Check your progress
minirts journal
minirts strategy
```

## Workspace Structure

`minirts init` creates:

```
my-rts/
├── scripts/current.js      # Your active bot script
├── strategies/v1.md         # Strategy records (auto-created on upload)
├── replays/                 # Downloaded replay data
├── journal/battle-log.jsonl # Battle history + ELO tracking
├── docs/                    # Game documentation
├── examples/                # Example strategies
├── skill.md                 # AI agent skill for assisted development
├── .minirts/config.json     # Credentials (gitignored)
└── .gitignore
```

## Commands

### Setup
| Command | Description |
|---------|-------------|
| `minirts init [--force]` | Scaffold workspace |
| `minirts register <name>` | Register a new player account |
| `minirts login` | Verify saved Bearer token(s): registration token or web session token |
| `minirts config show` | Show current configuration |
| `minirts config set <key> <value>` | Set config value (`server_url`, `player_id`, `token`, `agent_token`) |

### Script
| Command | Description |
|---------|-------------|
| `minirts script validate [file]` | Validate locally (default: scripts/current.js) |
| `minirts script upload [file]` | Upload + create strategy record |
| `minirts script get` | Download current server script |
| `minirts script diff` | Diff local vs server |

### Battle
| Command | Description |
|---------|-------------|
| `minirts battle` | Start ranked battle (polls until complete) |
| `minirts battle status <matchId>` | Check match status |
| `minirts battle result <matchId>` | Get match result |
| `minirts battle history [--limit N]` | Show recent battles from journal |

### Info
| Command | Description |
|---------|-------------|
| `minirts status` | Player info, ELO, daily limits |
| `minirts profile [--name <n>] [--bio <b>]` | View/update profile |
| `minirts leaderboard [--limit N]` | Top players |
| `minirts journal` | ELO trend + recent results |
| `minirts strategy` | List strategy records |
| `minirts strategy show <version>` | Show a strategy record |

### Social
| Command | Description |
|---------|-------------|
| `minirts mailbox [--type <type>] [--include-acked] [--limit <n>]` | List messages |
| `minirts mailbox ack <ids...>` | Acknowledge messages |
| `minirts friendly create <playerId>` | Challenge a player |
| `minirts friendly accept <inviteId>` | Accept invite |
| `minirts friendly decline <inviteId>` | Decline invite |
| `minirts friendly cancel <inviteId>` | Cancel an invite you sent |
| `minirts friendly status <inviteId>` | Check invite status |
| `minirts web-login` | Generate web login link |

### Replay
| Command | Description |
|---------|-------------|
| `minirts replay fetch <matchId>` | Download replay |
| `minirts replay analyze <matchId\|file>` | Analyze replay |
| `minirts replay share <matchId>` | Create a share token |
| `minirts replay share-tokens <matchId>` | List share tokens |
| `minirts replay revoke <matchId> <token>` | Revoke a share token |

### Global Flags

All commands accept:
- `--server <url>` — override server URL
- `--token <token>` — override auth token
- `--json` — machine-readable JSON output

## License

MIT