@ape-church/skill 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/SKILL.md +389 -152
  2. package/assets/SKILL.md +389 -152
  3. package/bin/cli.js +364 -150
  4. package/package.json +1 -1
package/assets/SKILL.md CHANGED
@@ -2,7 +2,8 @@
2
2
  name: ape-church-gambler
3
3
  description: Autonomous gambling skill for ApeChain. Manages funds and plays casino games.
4
4
  version: 1.0.0
5
- # The Autonomy Hook: Wakes the agent every minute; internal cooldowns control play rate
5
+ homepage: https://ape.church
6
+ metadata: {"emoji": "🦍", "category": "gaming", "chain": "apechain"}
6
7
  cron:
7
8
  - schedule: "* * * * *"
8
9
  task: "autonomous_routine"
@@ -12,162 +13,398 @@ tools:
12
13
  - name: bet
13
14
  cmd: apechurch bet --game <GAME> --amount <APE> --mode <0-4> --balls <1-100> --spins <1-15>
14
15
  - name: heartbeat
15
- cmd: apechurch heartbeat --strategy <conservative|balanced|aggressive|degen> --cooldown <ms> --timeout <ms>
16
- - name: register
17
- cmd: apechurch register --username <NAME> --persona <conservative|balanced|aggressive|degen>
18
- - name: profile_show
19
- cmd: apechurch profile show --json
20
- - name: profile_set
21
- cmd: apechurch profile set --persona <conservative|balanced|aggressive|degen> --username <NAME>
16
+ cmd: apechurch heartbeat --strategy <conservative|balanced|aggressive|degen>
22
17
  - name: pause
23
18
  cmd: apechurch pause
24
19
  - name: resume
25
20
  cmd: apechurch resume
21
+ - name: register
22
+ cmd: apechurch register --username <NAME>
23
+ - name: profile_show
24
+ cmd: apechurch profile show --json
25
+ - name: profile_set
26
+ cmd: apechurch profile set --persona <TYPE>
27
+ ---
28
+
29
+ # Ape Church 🦍🎰
30
+
31
+ Autonomous gambling for AI agents on ApeChain. Install the skill, fund your wallet, and let your agent play casino games on-chain.
32
+
33
+ ## Skill Files
34
+
35
+ | File | URL |
36
+ |------|-----|
37
+ | **SKILL.md** (this file) | `https://ape.church/skill.md` |
38
+ | **HEARTBEAT.md** | `https://ape.church/heartbeat.md` |
39
+ | **STRATEGY.md** | `https://ape.church/strategy.md` |
40
+ | **skill.json** (metadata) | `https://ape.church/skill.json` |
41
+
42
+ **Install locally:**
43
+ ```bash
44
+ npm install -g @ape-church/skill
45
+ apechurch install
46
+ ```
47
+
48
+ **Check for updates:** `npm update -g @ape-church/skill`
49
+
50
+ ---
51
+
52
+ ## 🔒 Security Warning
53
+
54
+ Your agent's wallet private key is stored at `~/.apechurch-wallet.json`.
55
+
56
+ ⚠️ **CRITICAL:**
57
+ - **NEVER share your private key** with anyone or any service
58
+ - **NEVER paste your private key** into prompts, tools, or third-party sites
59
+ - Your private key controls real funds on ApeChain
60
+ - If compromised, your APE can be stolen permanently
61
+
62
+ The CLI handles all signing locally. No private key is ever sent over the network.
63
+
64
+ ---
65
+
66
+ ## Quick Start (3 Steps)
67
+
68
+ ### Step 1: Install
69
+
70
+ ```bash
71
+ npm install -g @ape-church/skill
72
+ apechurch install --username MY_AGENT
73
+ ```
74
+
75
+ Response:
76
+ ```
77
+ SETUP COMPLETE
78
+ ---------------------------------------
79
+ AGENT ADDRESS: 0x1234...abcd
80
+ USERNAME: MY_AGENT
81
+ (Change anytime: apechurch register --username <YOUR_NAME>)
82
+ PERSONA: balanced
83
+
84
+ ACTION REQUIRED: Send APE to this address.
85
+ ---------------------------------------
86
+ ```
87
+
88
+ **⚠️ Save your agent address!** You need to fund it with APE.
89
+
90
+ ### Step 2: Fund Your Agent
91
+
92
+ Send APE to your agent's address on ApeChain.
93
+
94
+ **Bridge from other chains:**
95
+ 1. Open: https://relay.link/bridge/apechain?toCurrency=0x0000000000000000000000000000000000000000
96
+ 2. Connect your wallet
97
+ 3. Paste your agent's address
98
+ 4. Send 50+ APE (recommended starting amount)
99
+
100
+ ### Step 3: Play!
101
+
102
+ ```bash
103
+ # Check your balance
104
+ apechurch status --json
105
+
106
+ # Start autonomous play
107
+ apechurch heartbeat --strategy balanced
108
+ ```
109
+
110
+ That's it! Your agent will now play games autonomously. 🎰
111
+
112
+ ---
113
+
114
+ ## Set Up Your Heartbeat 💓
115
+
116
+ Most agents have a periodic heartbeat. Add Ape Church to yours so you keep playing!
117
+
118
+ ### Add to your heartbeat file
119
+
120
+ ```markdown
121
+ ## Ape Church (every minute)
122
+ If can_play is true and not on cooldown:
123
+ 1. Run `apechurch heartbeat --strategy balanced`
124
+ 2. Track results in memory
125
+ ```
126
+
127
+ ### Or use cron
128
+
129
+ The skill defines a cron schedule in the header. If your framework supports it:
130
+ ```yaml
131
+ cron:
132
+ - schedule: "* * * * *"
133
+ task: "apechurch heartbeat --strategy balanced --json"
134
+ ```
135
+
136
+ ### Why This Matters
137
+
138
+ Without a heartbeat, your agent just... sits there. Funded but not playing. Your APE doing nothing.
139
+
140
+ The heartbeat keeps your agent active. It respects cooldowns, manages bankroll, and plays smart based on your chosen strategy.
141
+
142
+ **Think of it like:** An agent that checks its wallet and decides "should I play right now?" every minute. If yes, it plays one game. If not (cooldown, low funds, paused), it waits.
143
+
144
+ ---
145
+
146
+ ## Commands
147
+
148
+ ### Check Status
149
+
150
+ ```bash
151
+ apechurch status --json
152
+ ```
153
+
154
+ Response:
155
+ ```json
156
+ {
157
+ "address": "0x1234...abcd",
158
+ "balance": "52.4500",
159
+ "available_ape": "51.4500",
160
+ "gas_reserve_ape": "1.0000",
161
+ "paused": false,
162
+ "persona": "balanced",
163
+ "username": "MY_AGENT",
164
+ "can_play": true
165
+ }
166
+ ```
167
+
168
+ | Field | Meaning |
169
+ |-------|---------|
170
+ | `balance` | Total APE in wallet |
171
+ | `available_ape` | Balance minus 1 APE gas reserve |
172
+ | `gas_reserve_ape` | Always kept for gas (~0.2 APE per game) |
173
+ | `paused` | Whether autonomous play is paused |
174
+ | `can_play` | True if funds available AND not paused |
175
+
176
+ ### Place a Bet
177
+
178
+ ```bash
179
+ apechurch bet --game jungle-plinko --amount 10 --mode 2 --balls 50
180
+ ```
181
+
182
+ Response:
183
+ ```json
184
+ {
185
+ "status": "complete",
186
+ "action": "bet",
187
+ "game": "jungle-plinko",
188
+ "tx": "0xabc123...",
189
+ "gameId": "12345678901234567890",
190
+ "game_url": "https://www.ape.church/games/jungle-plinko?id=12345678901234567890",
191
+ "config": { "mode": 2, "balls": 50 },
192
+ "wager_ape": "10.000000",
193
+ "vrf_fee_ape": "0.015000",
194
+ "result": {
195
+ "buy_in_ape": "10.000000",
196
+ "payout_ape": "24.500000"
197
+ }
198
+ }
199
+ ```
200
+
201
+ ### Heartbeat (Autonomous Play)
202
+
203
+ ```bash
204
+ apechurch heartbeat --strategy balanced
205
+ ```
206
+
207
+ Response (played):
208
+ ```json
209
+ {
210
+ "action": "heartbeat",
211
+ "status": "complete",
212
+ "strategy": "balanced",
213
+ "balance_ape": "52.450000",
214
+ "available_ape": "51.450000",
215
+ "paused": false,
216
+ "wager_ape": "4.116000",
217
+ "game": "jungle-plinko",
218
+ "config": { "mode": 1, "balls": 67 },
219
+ "tx": "0xdef456...",
220
+ "game_url": "https://www.ape.church/games/jungle-plinko?id=...",
221
+ "result": {
222
+ "payout_ape": "6.200000"
223
+ }
224
+ }
225
+ ```
226
+
227
+ Response (skipped - cooldown):
228
+ ```json
229
+ {
230
+ "action": "heartbeat",
231
+ "status": "skipped",
232
+ "reason": "cooldown",
233
+ "next_play_after_ms": 18500
234
+ }
235
+ ```
236
+
237
+ Response (skipped - paused):
238
+ ```json
239
+ {
240
+ "action": "heartbeat",
241
+ "status": "skipped",
242
+ "reason": "paused",
243
+ "message": "Autonomous play is paused. Run `apechurch resume` to continue."
244
+ }
245
+ ```
246
+
247
+ ### Pause / Resume
248
+
249
+ ```bash
250
+ apechurch pause # Stop autonomous play
251
+ apechurch resume # Continue playing
252
+ ```
253
+
254
+ Use this when:
255
+ - You want to stop temporarily without uninstalling
256
+ - You're low on funds and waiting for deposit
257
+ - Your human asked you to stop
258
+
259
+ ### Change Username
260
+
261
+ ```bash
262
+ apechurch register --username NEW_NAME
263
+ ```
264
+
265
+ Usernames:
266
+ - Max 32 characters
267
+ - Letters, numbers, underscores only
268
+ - Can be changed anytime
269
+ - Registered via SIWE (Sign-In With Ethereum)
270
+
271
+ ### Change Strategy
272
+
273
+ ```bash
274
+ apechurch profile set --persona aggressive
275
+ ```
276
+
277
+ Options: `conservative`, `balanced`, `aggressive`, `degen`
278
+
279
+ ---
280
+
281
+ ## Games
282
+
283
+ | Game | Type | Command |
284
+ |------|------|---------|
285
+ | 🌴 Jungle Plinko | Plinko | `--game jungle-plinko --mode 0-4 --balls 1-100` |
286
+ | 🦖 Dino Dough | Slots | `--game dino-dough --spins 1-15` |
287
+ | 🫧 Bubblegum Heist | Slots | `--game bubblegum-heist --spins 1-15` |
288
+
289
+ ### Jungle Plinko
290
+
291
+ Drop balls through pegs. Each ball lands in a bucket with a multiplier.
292
+
293
+ ```bash
294
+ apechurch bet --game jungle-plinko --amount 50 --mode 2 --balls 100
295
+ ```
296
+
297
+ | Parameter | Range | Effect |
298
+ |-----------|-------|--------|
299
+ | `--mode` | 0-4 | Risk level. Higher = riskier, bigger payouts |
300
+ | `--balls` | 1-100 | Ball count. More balls = smoother variance |
301
+
302
+ **Example:** 50 APE with 100 balls = 0.5 APE per ball drop.
303
+
304
+ ### Dino Dough & Bubblegum Heist
305
+
306
+ Slot machines with multiple spins per bet.
307
+
308
+ ```bash
309
+ apechurch bet --game dino-dough --amount 30 --spins 10
310
+ ```
311
+
312
+ | Parameter | Range | Effect |
313
+ |-----------|-------|--------|
314
+ | `--spins` | 1-15 | Spins per bet. More spins = smoother variance |
315
+
316
+ **Example:** 30 APE with 10 spins = 3 APE per spin.
317
+
318
+ ---
319
+
320
+ ## Strategies
321
+
322
+ Your strategy controls bet sizing, risk level, and cooldowns.
323
+
324
+ | Strategy | Bet Size | Max Bet | Cooldown | Risk |
325
+ |----------|----------|---------|----------|------|
326
+ | `conservative` | 5% of balance | 10% | 60 sec | Low |
327
+ | `balanced` | 8% of balance | 15% | 30 sec | Medium |
328
+ | `aggressive` | 12% of balance | 25% | 15 sec | High |
329
+ | `degen` | 20% of balance | 35% | 10 sec | Extreme |
330
+
331
+ **Dynamic cooldowns:** Win streaks shorten cooldowns. Loss streaks lengthen them.
332
+
333
+ See [STRATEGY.md](https://ape.church/strategy.md) for full details.
334
+
335
+ ---
336
+
337
+ ## Costs
338
+
339
+ | Cost | Amount | Notes |
340
+ |------|--------|-------|
341
+ | Gas per game | ~0.2 APE | Varies by game/config |
342
+ | VRF fee | ~0.01-0.05 APE | Covers randomness oracle |
343
+ | Minimum bet | 10 APE | Below this, gas is too high relative to bet |
344
+ | Gas reserve | 1 APE | Always kept in wallet |
345
+
346
+ **Recommended starting balance:** 50+ APE
347
+
348
+ ---
349
+
350
+ ## How It Works
351
+
352
+ 1. CLI builds game data locally (mode, balls/spins, random seeds)
353
+ 2. Fetches VRF fee from the game contract
354
+ 3. Sends transaction: `wager + vrfFee`
355
+ 4. Contract uses VRF (Verifiable Random Function) for fair randomness
356
+ 5. CLI watches for `GameEnded` event
357
+ 6. Returns result with payout and replay URL
358
+
359
+ All games are **on-chain** and **provably fair** via Chainlink VRF.
360
+
26
361
  ---
27
362
 
28
- # Ape Church Protocol
29
-
30
- ## Overview
31
- This package plays Ape Church casino games on ApeChain using a single entrypoint:
32
- `play(address player, bytes gameData)` on the game contract.
33
- The CLI builds `gameData` locally, fetches the VRF fee on-chain, and sends
34
- `value = wager + vrfFee`. If the value is wrong, the transaction will revert.
35
-
36
- ## Setup (Human Step)
37
- 1. Run `apechurch install`.
38
- 2. Fund the printed agent address with APE on ApeChain.
39
- - Bridge APE using:
40
- `https://relay.link/bridge/apechain?toCurrency=0x0000000000000000000000000000000000000000`
41
- - Connect your wallet.
42
- - Paste the agent address in ApeChain buy area:
43
- `Select wallet -> Paste wallet address`
44
- 3. During install, the agent will auto-register a username via SIWE.
45
- - Customize: `apechurch install --username <NAME>`
46
- - Usernames must be 32 characters or fewer (letters, numbers, underscores).
47
- - If omitted, a unique username is auto-generated (e.g., `APE_BOT_A1B2C3D4`).
48
- - Change anytime: `apechurch register --username <NEW_NAME>`
49
-
50
- ## Status
51
- Run `apechurch status --json` to fetch:
52
- - `balance` in APE
53
- - `available_ape` (balance minus 1 APE gas reserve)
54
- - `gas_reserve_ape` (minimum to keep in wallet)
55
- - `paused` — whether autonomous play is paused
56
- - `can_play` true if balance is safe to play and not paused
57
-
58
- ## Autonomy (Heartbeat + Strategy)
59
- - The agent should run `apechurch heartbeat` on a schedule to decide if it should play.
60
- - Heartbeat places at most one bet per run.
61
- - Strategy profiles are defined in `STRATEGY.md`.
62
- - Heartbeat rules and state tracking are defined in `HEARTBEAT.md`.
63
- - Local state file: `~/.apechurch/state.json`
64
- - Cooldown is dynamic based on streaks, but can be overridden with `--cooldown`.
65
- - Persona is optional. If not set, default is `balanced`.
66
- - Set a persona with:
67
- - `apechurch profile set --persona conservative`
68
- - `apechurch profile set --persona balanced`
69
- - `apechurch profile set --persona aggressive`
70
- - `apechurch profile set --persona degen`
71
- - Advanced overrides (optional) live in `~/.apechurch/profile.json`:
72
- - `overrides.game_weights`
73
- - `overrides.plinko.mode`, `overrides.plinko.balls`
74
- - `overrides.slots.spins`
75
- - `overrides.min_bet_ape`, `overrides.target_bet_pct`, `overrides.max_bet_pct`
76
- - `overrides.base_cooldown_ms`
77
- - Example file: `profile.example.json`
78
-
79
- ## Pause & Resume
80
- - Pause autonomous play: `apechurch pause`
81
- - Resume autonomous play: `apechurch resume`
82
- - When paused, heartbeat skips gracefully (no play, no errors).
83
- - Status shows `paused: true/false` and `can_play` reflects paused state.
84
- - Use this to temporarily stop the agent without uninstalling.
85
-
86
- ## Registration (Username + Persona)
87
- - Agents can register or change username with `apechurch register --username <NAME>`.
88
- - Usernames must be 32 characters or fewer (letters, numbers, underscores only).
89
- - If no username is provided, one is auto-generated (e.g., `APE_BOT_A1B2C3D4`).
90
- - Registration uses SIWE and marks `isAI: true` on the server.
91
- - Usernames can be changed at any time by running the register command again.
92
- - Endpoint: `https://www.ape.church/api/profile`
93
-
94
- ## Autonomous Routine
95
- (Triggered automatically by cron)
96
-
97
- 1. **Self-Preservation**:
98
- - Run `apechurch status --json`.
99
- - IF `available_ape` <= 0: **STOP**. Do not play. (Wait for human funding).
100
-
101
- 2. **Action Loop**:
102
- - If funds are healthy, choose a game based on your own strategy.
103
- - Decide your risk level and wager size.
104
- - **Risk Check**: Never bet more than your strategy's max bet percentage.
105
- - Minimum wager target is 10 APE to avoid gas-heavy micro-bets.
106
- - Always keep **at least 1 APE** in the wallet for gas (each game usually costs ~0.2 APE).
107
- - Prefer using `apechurch heartbeat` so the agent can enforce cooldowns and track state.
108
- - Provide explicit parameters even though defaults exist:
109
- - Jungle Plinko:
110
- - Run `apechurch bet --game jungle-plinko --amount <APE> --mode <0-4> --balls <1-100>`
111
- - Dino Dough (slots):
112
- - Run `apechurch bet --game dino-dough --amount <APE> --spins <1-15>`
113
- - Bubblegum Heist (slots):
114
- - Run `apechurch bet --game bubblegum-heist --amount <APE> --spins <1-15>`
115
-
116
- ## Jungle Plinko Controls
117
- - `--mode` is difficulty: `0..4` where `4` is riskiest and has highest payouts.
118
- - `--balls` is `1..100` and affects VRF gas cost.
119
- - More balls is safer because the wager is split across more drops.
120
- - Example: 100 APE with 100 balls = 1 APE per ball.
121
- - Example: 50 APE with 100 balls = 0.5 APE per ball.
122
- - Defaults are `mode=0` and `balls=50`, but agents should choose explicitly.
123
-
124
- ## Dino Dough (Slots) Controls
125
- - `--spins` is `1..15` and affects risk and value per spin.
126
- - More spins is safer because the wager is split across more spins.
127
- - Example: 45 APE with 15 spins = 3 APE per spin.
128
- - 1 spin is very risky; target `5..15` spins for better risk balance.
129
- - Default is `spins=10`, but agents should choose explicitly.
130
-
131
- ## Bubblegum Heist (Slots) Controls
132
- - Same controls as Dino Dough (slots), with a different contract.
133
- - Use `--spins 1..15` and prefer `5..15` spins.
134
-
135
- ## How the CLI Works
136
- - Generates:
137
- - `gameId` (random uint256)
138
- - `userRandomWord` (random bytes32)
139
- - `ref = 0x0000000000000000000000000000000000000000`
140
- - Encodes `gameData` as:
141
- 1. `uint8 gameMode`
142
- 2. `uint8 numBalls`
143
- 3. `uint256 gameId`
144
- 4. `address ref`
145
- 5. `bytes32 userRandomWord`
146
- - Slots use a different `gameData` order:
147
- 1. `uint256 gameId`
148
- 2. `uint8 numSpins`
149
- 3. `address ref`
150
- 4. `bytes32 userRandomWord`
151
- - Calls `getVRFFee(uint32 customGasLimit)` for Plinko where:
152
- - `customGasLimit = 289000 + (numBalls * 11000)`
153
- - Calls `getVRFFee()` for slots (no input).
154
- - Sends `play(...)` with `value = wager + vrfFee`.
155
-
156
- ## Result Handling
157
- - The CLI listens for `GameEnded` and resolves the play when the event arrives.
158
- - Default behavior is to wait indefinitely. You can pass `--timeout <ms>` to return
159
- `pending` if the event hasn't arrived after that time.
160
- - JSON output includes `game_url` for replay:
161
- - `https://www.ape.church/games/jungle-plinko?id=<gameId>`
162
- - `https://www.ape.church/games/dino-dough?id=<gameId>`
163
- - `https://www.ape.church/games/bubblegum-heist?id=<gameId>`
164
-
165
- ## Hosted Docs (Reference)
166
- - `https://ape.church/skill.md`
167
- - `https://ape.church/heartbeat.md`
168
- - `https://ape.church/strategy.md`
169
- - `https://ape.church/skill.json`
363
+ ## Everything You Can Do 🦍
364
+
365
+ | Command | What it does |
366
+ |---------|--------------|
367
+ | `apechurch install` | Set up wallet and register |
368
+ | `apechurch status` | Check balance and state |
369
+ | `apechurch heartbeat` | Autonomous play (one game) |
370
+ | `apechurch bet` | Manual bet with full control |
371
+ | `apechurch pause` | Stop autonomous play |
372
+ | `apechurch resume` | Resume autonomous play |
373
+ | `apechurch register` | Change username |
374
+ | `apechurch profile show` | View current profile |
375
+ | `apechurch profile set` | Change persona/strategy |
376
+
377
+ ---
378
+
379
+ ## Tips
380
+
381
+ - **Start with `balanced`** Good risk/reward ratio
382
+ - **Use heartbeat, not manual bets** Handles cooldowns and state
383
+ - **Watch your balance** If you drop below 11 APE, you can't play
384
+ - **Pause when low** — Don't drain your gas reserve
385
+ - **Check replay URLs** — See your games visualized at ape.church
386
+
387
+ ---
388
+
389
+ ## Your Human Can Ask Anytime
390
+
391
+ Your human can prompt you to do anything on Ape Church:
392
+ - "Check your Ape Church balance"
393
+ - "Play a few games of Plinko"
394
+ - "Pause your gambling for now"
395
+ - "Switch to a more aggressive strategy"
396
+ - "How much have you won/lost today?"
397
+
398
+ You don't have to wait for heartbeat — if they ask, do it!
399
+
400
+ ---
170
401
 
171
402
  ## Updates
172
- - New games ship via package updates (local registry).
173
- - Installed agents must update the npm package to receive new games.
403
+
404
+ New games ship via npm package updates:
405
+
406
+ ```bash
407
+ npm update -g @ape-church/skill
408
+ ```
409
+
410
+ Check the changelog: https://github.com/ape-church/agent-skills/blob/main/CHANGELOG.md