@ape-church/skill 1.0.4 → 1.0.5
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.
- package/HEARTBEAT.md +76 -37
- package/README.md +27 -42
- package/SKILL.md +108 -105
- package/assets/HEARTBEAT.md +76 -37
- package/assets/SKILL.md +108 -105
- package/bin/cli.js +321 -53
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -857,37 +857,74 @@ program
|
|
|
857
857
|
}
|
|
858
858
|
|
|
859
859
|
// 4. The Handshake
|
|
860
|
-
console.log('\
|
|
861
|
-
console.log('
|
|
862
|
-
console.log(
|
|
863
|
-
console.log(`USERNAME: ${username}`);
|
|
864
|
-
console.log(`PERSONA: ${persona}`);
|
|
860
|
+
console.log('\n========================================');
|
|
861
|
+
console.log('🎰 APE CHURCH - SETUP COMPLETE');
|
|
862
|
+
console.log('========================================');
|
|
865
863
|
console.log('');
|
|
866
|
-
console.log('
|
|
864
|
+
console.log('Ape Church is a FULLY on-chain, 100% decentralized casino on ApeChain.');
|
|
865
|
+
console.log('Every bet is placed and settled on-chain. Zero servers.');
|
|
867
866
|
console.log('');
|
|
868
|
-
console.log('
|
|
869
|
-
console.log('
|
|
870
|
-
console.log('
|
|
867
|
+
console.log('Player vs Player: The "house" is a public staking pool where anyone');
|
|
868
|
+
console.log('can deposit or withdraw APE anytime. You\'re playing against other');
|
|
869
|
+
console.log('players, not the house. Truly PvP.');
|
|
871
870
|
console.log('');
|
|
872
|
-
console.log('
|
|
873
|
-
console.log(
|
|
874
|
-
console.log(
|
|
875
|
-
console.log(
|
|
871
|
+
console.log('YOUR AGENT:');
|
|
872
|
+
console.log(` Address: ${address}`);
|
|
873
|
+
console.log(` Username: ${username}`);
|
|
874
|
+
console.log(` Strategy: ${persona}`);
|
|
876
875
|
console.log('');
|
|
877
|
-
console.log('
|
|
878
|
-
console.log('
|
|
879
|
-
console.log('
|
|
880
|
-
console.log('
|
|
876
|
+
console.log('========================================');
|
|
877
|
+
console.log('STEP 1: FUND YOUR AGENT');
|
|
878
|
+
console.log('========================================');
|
|
879
|
+
console.log('Send APE (on ApeChain) to the address above.');
|
|
880
|
+
console.log('Bridge: https://relay.link/bridge/apechain');
|
|
881
881
|
console.log('');
|
|
882
|
-
console.log('
|
|
883
|
-
console.log('
|
|
884
|
-
console.log('
|
|
885
|
-
console.log('
|
|
882
|
+
console.log('========================================');
|
|
883
|
+
console.log('STEP 2: START PLAYING');
|
|
884
|
+
console.log('========================================');
|
|
885
|
+
console.log('Easiest way - just run:');
|
|
886
886
|
console.log('');
|
|
887
|
-
console.log('
|
|
888
|
-
console.log('
|
|
889
|
-
console.log('
|
|
890
|
-
console.log('
|
|
887
|
+
console.log(' apechurch play --loop');
|
|
888
|
+
console.log('');
|
|
889
|
+
console.log('Or tell your AI agent (copy this message):');
|
|
890
|
+
console.log('');
|
|
891
|
+
console.log('---START MESSAGE---');
|
|
892
|
+
console.log(`I've installed the Ape Church skill for you. Read the skill file at`);
|
|
893
|
+
console.log(`~/.openclaw/skills/ape-church/SKILL.md to understand how to play.`);
|
|
894
|
+
console.log(`Then run: apechurch play --loop`);
|
|
895
|
+
console.log(`This will play casino games continuously on ApeChain.`);
|
|
896
|
+
console.log('---END MESSAGE---');
|
|
897
|
+
console.log('');
|
|
898
|
+
console.log('========================================');
|
|
899
|
+
console.log('QUICK REFERENCE');
|
|
900
|
+
console.log('========================================');
|
|
901
|
+
console.log('PLAY:');
|
|
902
|
+
console.log(' apechurch play Play one game');
|
|
903
|
+
console.log(' apechurch play --loop Play continuously (2s between games)');
|
|
904
|
+
console.log('');
|
|
905
|
+
console.log('GAMES (auto-selected, or use --game):');
|
|
906
|
+
console.log(' jungle-plinko Plinko (--mode 0-4, --balls 1-100)');
|
|
907
|
+
console.log(' dino-dough Slots (--spins 1-15)');
|
|
908
|
+
console.log(' bubblegum-heist Slots (--spins 1-15)');
|
|
909
|
+
console.log('');
|
|
910
|
+
console.log('STRATEGIES (controls bet sizing):');
|
|
911
|
+
console.log(' conservative 5% of balance per bet');
|
|
912
|
+
console.log(' balanced 8% of balance per bet (default)');
|
|
913
|
+
console.log(' aggressive 12% of balance per bet');
|
|
914
|
+
console.log(' degen 20% of balance per bet');
|
|
915
|
+
console.log('');
|
|
916
|
+
console.log('CONTROL:');
|
|
917
|
+
console.log(' apechurch status Check balance');
|
|
918
|
+
console.log(' apechurch pause Pause play');
|
|
919
|
+
console.log(' apechurch resume Resume play');
|
|
920
|
+
console.log(' apechurch games List all games');
|
|
921
|
+
console.log(' apechurch commands Full command reference');
|
|
922
|
+
console.log(' apechurch help Show help');
|
|
923
|
+
console.log('');
|
|
924
|
+
console.log('CHANGE SETTINGS:');
|
|
925
|
+
console.log(' apechurch register --username <NAME>');
|
|
926
|
+
console.log(' apechurch profile set --persona <STRATEGY>');
|
|
927
|
+
console.log('========================================');
|
|
891
928
|
});
|
|
892
929
|
|
|
893
930
|
// --- COMMAND: STATUS (The Agent Experience) ---
|
|
@@ -1323,6 +1360,177 @@ program
|
|
|
1323
1360
|
}
|
|
1324
1361
|
});
|
|
1325
1362
|
|
|
1363
|
+
// --- COMMAND: PLAY (Simple play command - no cooldowns) ---
|
|
1364
|
+
program
|
|
1365
|
+
.command('play')
|
|
1366
|
+
.description('Play a game immediately (no cooldowns)')
|
|
1367
|
+
.option('--strategy <name>', 'conservative | balanced | aggressive | degen', 'balanced')
|
|
1368
|
+
.option('--loop', 'Play continuously with 2s between games')
|
|
1369
|
+
.option('--delay <seconds>', 'Seconds between games in loop mode', '2')
|
|
1370
|
+
.option('--json', 'Output JSON only')
|
|
1371
|
+
.action(async (opts) => {
|
|
1372
|
+
const account = getWallet();
|
|
1373
|
+
const loopMode = Boolean(opts.loop);
|
|
1374
|
+
const delaySeconds = Math.max(parseFloat(opts.delay) || 2, 1);
|
|
1375
|
+
const delayMs = delaySeconds * 1000;
|
|
1376
|
+
|
|
1377
|
+
// Check if paused
|
|
1378
|
+
const profile = loadProfile();
|
|
1379
|
+
if (profile.paused) {
|
|
1380
|
+
const response = {
|
|
1381
|
+
action: 'play',
|
|
1382
|
+
status: 'skipped',
|
|
1383
|
+
reason: 'paused',
|
|
1384
|
+
message: 'Play is paused. Run `apechurch resume` to continue.',
|
|
1385
|
+
};
|
|
1386
|
+
if (opts.json) console.log(JSON.stringify(response));
|
|
1387
|
+
else console.log(JSON.stringify(response, null, 2));
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
if (loopMode && !opts.json) {
|
|
1392
|
+
console.log(`🎰 Starting continuous play (${delaySeconds}s between games, Ctrl+C to stop)...\n`);
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
async function playOnce() {
|
|
1396
|
+
const state = loadState();
|
|
1397
|
+
const freshProfile = loadProfile();
|
|
1398
|
+
|
|
1399
|
+
if (freshProfile.paused) {
|
|
1400
|
+
return { shouldStop: true, reason: 'paused' };
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
const strategy = normalizeStrategy(opts.strategy);
|
|
1404
|
+
const strategyConfig = applyProfileOverrides(
|
|
1405
|
+
getStrategyConfig(strategy),
|
|
1406
|
+
freshProfile.overrides
|
|
1407
|
+
);
|
|
1408
|
+
|
|
1409
|
+
const { publicClient } = createClients();
|
|
1410
|
+
let balance;
|
|
1411
|
+
try {
|
|
1412
|
+
balance = await publicClient.getBalance({ address: account.address });
|
|
1413
|
+
} catch (error) {
|
|
1414
|
+
console.error(JSON.stringify({ error: `Failed to fetch balance: ${sanitizeError(error)}` }));
|
|
1415
|
+
return { shouldStop: true, reason: 'balance_error' };
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
const balanceApe = parseFloat(formatEther(balance));
|
|
1419
|
+
const availableApe = Math.max(balanceApe - GAS_RESERVE_APE, 0);
|
|
1420
|
+
|
|
1421
|
+
if (availableApe <= 0 || availableApe < strategyConfig.minBetApe) {
|
|
1422
|
+
const response = {
|
|
1423
|
+
action: 'play',
|
|
1424
|
+
status: 'skipped',
|
|
1425
|
+
reason: 'insufficient_balance',
|
|
1426
|
+
balance_ape: balanceApe.toFixed(6),
|
|
1427
|
+
available_ape: availableApe.toFixed(6),
|
|
1428
|
+
};
|
|
1429
|
+
if (opts.json) console.log(JSON.stringify(response));
|
|
1430
|
+
else console.log(JSON.stringify(response, null, 2));
|
|
1431
|
+
return { shouldStop: true, reason: 'insufficient_balance' };
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
const wagerApe = calculateWager(availableApe, strategyConfig);
|
|
1435
|
+
const selection = selectGameAndConfig(strategyConfig);
|
|
1436
|
+
const wagerApeString = formatApeAmount(wagerApe);
|
|
1437
|
+
|
|
1438
|
+
try {
|
|
1439
|
+
const playResponse = await playGame({
|
|
1440
|
+
account,
|
|
1441
|
+
game: selection.game,
|
|
1442
|
+
amountApe: wagerApeString,
|
|
1443
|
+
mode: selection.mode,
|
|
1444
|
+
balls: selection.balls,
|
|
1445
|
+
spins: selection.spins,
|
|
1446
|
+
timeoutMs: 0,
|
|
1447
|
+
});
|
|
1448
|
+
|
|
1449
|
+
// Update state
|
|
1450
|
+
if (playResponse?.result) {
|
|
1451
|
+
const pnlWei = (BigInt(playResponse.result.payout_wei) -
|
|
1452
|
+
BigInt(playResponse.result.buy_in_wei)).toString();
|
|
1453
|
+
state.totalPnLWei = addBigIntStrings(state.totalPnLWei, pnlWei);
|
|
1454
|
+
if (BigInt(pnlWei) >= 0n) {
|
|
1455
|
+
state.sessionWins += 1;
|
|
1456
|
+
state.consecutiveWins += 1;
|
|
1457
|
+
state.consecutiveLosses = 0;
|
|
1458
|
+
} else {
|
|
1459
|
+
state.sessionLosses += 1;
|
|
1460
|
+
state.consecutiveLosses += 1;
|
|
1461
|
+
state.consecutiveWins = 0;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
state.lastPlay = Date.now();
|
|
1465
|
+
saveState(state);
|
|
1466
|
+
|
|
1467
|
+
const response = {
|
|
1468
|
+
action: 'play',
|
|
1469
|
+
status: playResponse.status,
|
|
1470
|
+
strategy,
|
|
1471
|
+
balance_ape: balanceApe.toFixed(6),
|
|
1472
|
+
wager_ape: wagerApeString,
|
|
1473
|
+
game: playResponse.game,
|
|
1474
|
+
config: playResponse.config,
|
|
1475
|
+
tx: playResponse.tx,
|
|
1476
|
+
gameId: playResponse.gameId,
|
|
1477
|
+
game_url: playResponse.game_url,
|
|
1478
|
+
result: playResponse.result,
|
|
1479
|
+
session: {
|
|
1480
|
+
wins: state.sessionWins,
|
|
1481
|
+
losses: state.sessionLosses,
|
|
1482
|
+
total_pnl_ape: formatEther(BigInt(state.totalPnLWei)),
|
|
1483
|
+
},
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
if (opts.json) console.log(JSON.stringify(response));
|
|
1487
|
+
else console.log(JSON.stringify(response, null, 2));
|
|
1488
|
+
|
|
1489
|
+
return { shouldStop: false };
|
|
1490
|
+
} catch (error) {
|
|
1491
|
+
console.error(JSON.stringify({ error: error.message }));
|
|
1492
|
+
return { shouldStop: true, reason: 'play_error' };
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
if (!loopMode) {
|
|
1497
|
+
await playOnce();
|
|
1498
|
+
} else {
|
|
1499
|
+
let running = true;
|
|
1500
|
+
process.on('SIGINT', () => {
|
|
1501
|
+
if (!opts.json) console.log('\n👋 Stopping...');
|
|
1502
|
+
running = false;
|
|
1503
|
+
});
|
|
1504
|
+
process.on('SIGTERM', () => {
|
|
1505
|
+
running = false;
|
|
1506
|
+
});
|
|
1507
|
+
|
|
1508
|
+
while (running) {
|
|
1509
|
+
const result = await playOnce();
|
|
1510
|
+
|
|
1511
|
+
if (!running) break;
|
|
1512
|
+
if (result.shouldStop) {
|
|
1513
|
+
if (!opts.json) console.log(`\n⏹️ Stopped: ${result.reason}`);
|
|
1514
|
+
break;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
if (!opts.json) {
|
|
1518
|
+
console.log(`\n⏳ Next game in ${delaySeconds}s...\n`);
|
|
1519
|
+
}
|
|
1520
|
+
await new Promise((resolve) => {
|
|
1521
|
+
const timeout = setTimeout(resolve, delayMs);
|
|
1522
|
+
const checkStop = setInterval(() => {
|
|
1523
|
+
if (!running) {
|
|
1524
|
+
clearTimeout(timeout);
|
|
1525
|
+
clearInterval(checkStop);
|
|
1526
|
+
resolve();
|
|
1527
|
+
}
|
|
1528
|
+
}, 200);
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
});
|
|
1533
|
+
|
|
1326
1534
|
// --- COMMAND: GAMES (Show available games and parameters) ---
|
|
1327
1535
|
program
|
|
1328
1536
|
.command('games')
|
|
@@ -1393,54 +1601,114 @@ program
|
|
|
1393
1601
|
// --- COMMAND: COMMANDS (Show all commands overview) ---
|
|
1394
1602
|
program
|
|
1395
1603
|
.command('commands')
|
|
1604
|
+
.alias('help')
|
|
1396
1605
|
.description('Show all available commands with examples')
|
|
1397
1606
|
.action(() => {
|
|
1398
1607
|
console.log(`
|
|
1399
|
-
|
|
1608
|
+
========================================
|
|
1609
|
+
🎰 APE CHURCH CLI - FULL REFERENCE
|
|
1610
|
+
========================================
|
|
1400
1611
|
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1612
|
+
ABOUT
|
|
1613
|
+
Ape Church is a FULLY on-chain, 100% decentralized casino on ApeChain.
|
|
1614
|
+
Every bet is placed and settled on-chain. Zero servers.
|
|
1615
|
+
|
|
1616
|
+
Player vs Player: The "house" is a public staking pool - anyone can
|
|
1617
|
+
deposit or withdraw APE anytime. You're playing against other players,
|
|
1618
|
+
not the house. Truly PvP. Games use VRF for provably fair randomness.
|
|
1405
1619
|
|
|
1406
|
-
|
|
1407
|
-
|
|
1620
|
+
========================================
|
|
1621
|
+
GETTING STARTED
|
|
1622
|
+
========================================
|
|
1623
|
+
|
|
1624
|
+
apechurch install [--username NAME] [--persona TYPE]
|
|
1625
|
+
Set up your agent wallet and register on Ape Church.
|
|
1408
1626
|
|
|
1409
|
-
STATUS
|
|
1410
1627
|
apechurch status [--json]
|
|
1411
|
-
Check your wallet balance and
|
|
1628
|
+
Check your wallet balance and current status.
|
|
1412
1629
|
|
|
1413
|
-
|
|
1414
|
-
|
|
1630
|
+
========================================
|
|
1631
|
+
PLAYING GAMES
|
|
1632
|
+
========================================
|
|
1415
1633
|
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1634
|
+
apechurch play [--strategy TYPE] [--loop] [--json]
|
|
1635
|
+
Play games automatically. Picks a random game, bets based on strategy.
|
|
1636
|
+
--loop Play continuously (2s between games)
|
|
1637
|
+
--delay <sec> Custom delay between games (default: 2)
|
|
1638
|
+
--strategy conservative | balanced | aggressive | degen
|
|
1420
1639
|
|
|
1421
|
-
apechurch bet --game <NAME> --amount <APE> [
|
|
1640
|
+
apechurch bet --game <NAME> --amount <APE> [options]
|
|
1422
1641
|
Place a manual bet on a specific game.
|
|
1423
|
-
|
|
1642
|
+
--game jungle-plinko | dino-dough | bubblegum-heist
|
|
1643
|
+
--amount APE to wager
|
|
1644
|
+
--mode <0-4> Plinko risk level (higher = riskier)
|
|
1645
|
+
--balls <1-100> Plinko balls to drop
|
|
1646
|
+
--spins <1-15> Slots spins per bet
|
|
1647
|
+
|
|
1648
|
+
apechurch games [--json]
|
|
1649
|
+
List all available games with parameters.
|
|
1650
|
+
|
|
1651
|
+
========================================
|
|
1652
|
+
STRATEGIES (controls how much your agent bets)
|
|
1653
|
+
========================================
|
|
1654
|
+
|
|
1655
|
+
conservative 5% of balance per bet, low-risk game configs
|
|
1656
|
+
balanced 8% of balance per bet (default)
|
|
1657
|
+
aggressive 12% of balance per bet, high-risk game configs
|
|
1658
|
+
degen 20% of balance per bet, max risk
|
|
1424
1659
|
|
|
1660
|
+
Change your strategy anytime:
|
|
1661
|
+
apechurch profile set --persona aggressive
|
|
1662
|
+
|
|
1663
|
+
Or specify per-session:
|
|
1664
|
+
apechurch play --loop --strategy degen
|
|
1665
|
+
|
|
1666
|
+
========================================
|
|
1425
1667
|
CONTROL
|
|
1426
|
-
|
|
1427
|
-
Pause autonomous play.
|
|
1668
|
+
========================================
|
|
1428
1669
|
|
|
1429
|
-
apechurch
|
|
1430
|
-
|
|
1670
|
+
apechurch pause Stop playing (loop will exit)
|
|
1671
|
+
apechurch resume Resume playing
|
|
1672
|
+
Ctrl+C Stop the current loop
|
|
1673
|
+
|
|
1674
|
+
========================================
|
|
1675
|
+
PROFILE & SETTINGS
|
|
1676
|
+
========================================
|
|
1431
1677
|
|
|
1432
|
-
PROFILE
|
|
1433
1678
|
apechurch profile show [--json]
|
|
1434
|
-
View your current profile
|
|
1679
|
+
View your current profile.
|
|
1435
1680
|
|
|
1436
1681
|
apechurch profile set [--persona TYPE] [--username NAME]
|
|
1437
|
-
Update your
|
|
1682
|
+
Update your strategy or username.
|
|
1683
|
+
|
|
1684
|
+
apechurch register --username <NAME>
|
|
1685
|
+
Change your on-chain username.
|
|
1438
1686
|
|
|
1687
|
+
========================================
|
|
1439
1688
|
EXAMPLES
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
apechurch
|
|
1689
|
+
========================================
|
|
1690
|
+
|
|
1691
|
+
# Quick start - play continuously
|
|
1692
|
+
apechurch play --loop
|
|
1693
|
+
|
|
1694
|
+
# Play aggressively
|
|
1695
|
+
apechurch play --loop --strategy aggressive
|
|
1696
|
+
|
|
1697
|
+
# Single manual bet
|
|
1698
|
+
apechurch bet --game jungle-plinko --amount 10 --mode 3 --balls 50
|
|
1699
|
+
|
|
1700
|
+
# Check status
|
|
1701
|
+
apechurch status
|
|
1702
|
+
|
|
1703
|
+
========================================
|
|
1704
|
+
FOR AI AGENTS
|
|
1705
|
+
========================================
|
|
1706
|
+
|
|
1707
|
+
To activate this skill, tell your agent:
|
|
1708
|
+
|
|
1709
|
+
"Read ~/.openclaw/skills/ape-church/SKILL.md and run: apechurch play --loop"
|
|
1710
|
+
|
|
1711
|
+
All commands support --json for machine-readable output.
|
|
1444
1712
|
`);
|
|
1445
1713
|
});
|
|
1446
1714
|
|