dev / templates / bot / README.md
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# ardegazu-__NAME__

A resident of the [ardegazu.ro](https://ardegazu.ro) suite that lives on a
server: a peer like any other, minus the browser. It holds one suite
identity, shows up for its friends, and answers invites into any suite room
— games, chat, boards. This scaffold is the complete chassis; **the guided
build-out lives in [`docs/NEW-BOT-PROMPT.md`](docs/NEW-BOT-PROMPT.md)** —
behaviors, optional learned brains, deploy, hub card.

Built on the suite's Node kits:
[`ardegazu-peer-kit`](https://git.ardegazu.ro/peer-kit/) (games, identity,
social, hosting) and
[`ardegazu-rooms-kit`](https://git.ardegazu.ro/rooms-kit/) (chat + board),
with [`ardegazu-train-kit`](https://git.ardegazu.ro/train-kit/) for the
optional learning layer.

ClojureScript on Node: four isolated shadow-cljs `:esm` builds — one per
process entry (`dist/main.js`, `dist/worker.js`, `dist/rl/train.js`,
`dist/fleet/link.js`) — enforce the two-stack law by construction.
`dev/docs/CLJS.md` (in the suite's dev repo) is the build canon; `deps.edn`
carries a `:dev` alias with cider-nrepl, so `cider-jack-in-cljs` works out
of the box. `dist/` is **committed** (the VPS never builds) and
`deploy/check-dist.sh` gates on it matching a fresh cold-cache build.

`scripts/build.mjs` and `scripts/normalize-gensyms.mjs` are copies of
bot.git's (the CLJS bot canon) taken at scaffold time — if bot.git's build
recipe changes, re-sync them by hand; check-dist failing on a shadow upgrade
is the usual tell.

## Run

```sh
npm install && npm run check && npm run build   # needs JVM ≥ 17 (dev machine only)
node dist/main.js ./bot.json
```

With npm's `ignore-scripts` on, fetch the chat/board native prebuild once
(or the chat/board worker dies at spawn with MODULE_NOT_FOUND):

```sh
(cd node_modules/@ipshipyard/node-datachannel && npx prebuild-install -r napi)
```

`bot.json` (see `deploy/bot.example.json`): `rooms` pins standing rooms
(usually empty — invites do the work), `fleet.siblings` lists the other
bots' friend-link fragments, `fleet.matchmaker` arranges self-play for
fleets of two or more.

## Deploy

One systemd template unit runs any number of instances:

```sh
rsync -a --exclude node_modules --exclude .git . server:/opt/ardegazu-__NAME__/
ssh server 'cd /opt/ardegazu-__NAME__ && npm install && sh deploy/install-fleet.sh'
```

Logs: `journalctl -u 'ardegazu-__NAME__@*' -f`.

**The two warnings that matter:**

- **Two stacks, never one process.** The `:main` build (`__NAME__.main` /
  `__NAME__.rooms`) requires peer-kit only; chat/board rooms run in forked
  workers (`:worker` build) on rooms-kit only. The kits' native WebRTC
  builds abort any process that loads both — that worker fork is
  load-bearing, not an optimization, and `deploy/check-dist.sh` greps the
  emitted bundles for the wrong kit's specifier.
- **Seeds are secrets and the only irreplaceable state.** A bot's seed file
  is its identity. `sh deploy/backup-state.sh <ssh-host>` from day one; the
  tarball is 0600 and never enters a repo.

Public mirror (git dumb-HTTP — no git server):

```sh
git clone https://git.ardegazu.ro/__NAME__.git
```

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/dev.git