Files
lanspread/crates/lanspread-peer-cli/README.md
T
ddidderr dc9e13e6a1 feat(peer-cli): add JSONL peer test harness
Agents need a way to exercise multiple peers without launching the Tauri GUI.
Add `lanspread-peer-cli` as a workspace crate that starts the core peer runtime,
reads JSON commands from stdin, and writes result, event, and error records as
JSONL on stdout.

The harness supports status, peer listing, game listing, direct connect,
set-game-dir, download, install, uninstall, wait-peers, and shutdown commands.
It can seed tiny fixture archives that use a fixture unpacker, or delegate real
archives to an external `unrar` program when one is supplied.

Add a Dockerfile, `.dockerignore`, and `just` recipes for building the binary,
building the image, and running named harness containers with state and games
mounted under `target/peer-cli/`. The documentation now lists the crate and the
new test harness commands in the project map, with a crate-local README for the
JSONL protocol.

This commit depends on the non-GUI peer hooks introduced in the previous commit:
startup options, local-ready events, direct connects, snapshots, and explicit
post-download install policy. It does not add old-peer compatibility paths.

Test Plan:
- `git diff --check`
- `just fmt`
- `just clippy`
- `just test`
- `just peer-cli-build`
- Not run: `just peer-cli-image` requires a Docker daemon and base image access.

Depends-on: e711cf3454
Refs: crates/lanspread-peer-cli/README.md
2026-05-16 18:33:18 +02:00

37 lines
1.1 KiB
Markdown

# lanspread-peer-cli
Scriptable peer harness for automated LAN-spread tests. The binary starts the
core peer runtime without the Tauri GUI, reads one JSON command per stdin line,
and writes JSONL events, results, and errors to stdout.
## Running
```bash
just peer-cli-build
just peer-cli-image
just peer-cli-run alpha
```
Useful flags:
- `--games-dir PATH` stores local archives and installs.
- `--state-dir PATH` stores the generated peer identity.
- `--fixture GAME_ID` seeds a tiny archive that the fixture unpacker can install.
- `--no-mdns` disables mDNS so tests can use explicit `connect` commands.
## Commands
Every command is a JSON object with `cmd` or `command`; `id` is optional and is
echoed back on the result or error line.
```json
{"id":"s1","cmd":"status"}
{"id":"p1","cmd":"wait-peers","count":1,"timeout_ms":5000}
{"id":"c1","cmd":"connect","addr":"127.0.0.1:34567"}
{"id":"g1","cmd":"list-games"}
{"id":"d1","cmd":"download","game_id":"fixture-one","install":true}
{"id":"i1","cmd":"install","game_id":"fixture-one"}
{"id":"u1","cmd":"uninstall","game_id":"fixture-one"}
{"id":"q1","cmd":"shutdown"}
```