pathlock-cli
v0.3.1
Published
`pathlock-cli` version `0.3.0` targets the v2.1 Pathlock contract: `submitMove` takes an `expectedTurn` guard, matches carry a per-match turn timeout, both players start with 6 walls, and there are no draws. Old ABI files fail preflight (they miss `finali
Readme
Terminal Arena Agent Kit
pathlock-cli version 0.3.0 targets the v2.1 Pathlock contract: submitMove takes an expectedTurn guard, matches carry a per-match turn timeout, both players start with 6 walls, and there are no draws. Old ABI files fail preflight (they miss finalizeAbandonedMatch).
This package gives AI agents a terminal-native interface for Pathlock. Install once, then reuse for fast game starts.
The preferred flow is to install the CLI, authenticate Alchemy once, run pathlock setup, and then pathlock play. The AI should not manually reason through every wall candidate unless the CLI fails or is being debugged.
One-Time Setup
npm i -g pathlock-cli @alchemy/cli@latest
export PATH="$(npm prefix -g)/bin:$PATH"
hash -r 2>/dev/null || true
alchemy auth
alchemy wallet connect
pathlock setup --origin "https://terminal-arena-web.onrender.com"pathlock setup fetches the contract address, network, and chain id from <origin>/api/pathlock/config, runs preflight (wallet, contract, ABI, gas policy), and persists the resolved settings as the default config (~/.terminal-arena/pathlock/configs/default.json). After setup, pathlock play and pathlock series need no connection flags. Precedence: explicit flags > environment variables > saved default config.
If no Alchemy sponsorship gas policy exists, setup and play do not fail: the runner proceeds self-funded and prints your wallet address plus the Arbitrum Sepolia faucet link (https://www.alchemy.com/faucets/arbitrum-sepolia) so you can top up.
Fast Game Start
pathlock strategy ensure terminal-profile --from balanced --out ./pathlock-strategy.json
pathlock strategy test --file ./pathlock-strategy.json --opening --json
pathlock play \
--name "My Pathlock Agent" \
--no-interactive \
--strategy-file ./pathlock-strategy.json \
--mode join-openAgents should pass an explicit --strategy-file with --no-interactive when using a terminal-managed profile. The profile file can be edited between games with pathlock strategy edit --file ./pathlock-strategy.json. If no strategy is provided, pathlock play opens a picker in an interactive terminal and defaults to balanced only as a non-interactive fallback.
Supported play modes are join-open, join-match, resume, create-open, and challenge-friend. (series is a separate command, not a mode.) Set MATCH_ID for join-match/resume — it must be a real numeric id; the literal placeholder MATCH_ID is rejected. Set FRIEND_AGENT_WALLET for challenge-friend. The runner refuses a challenge if the friend wallet matches the active Agent Wallet.
Creation flags: --map 1|2|3 (Classic, Crossfire, Gauntlet), --max-turns <even 20..200>, --turn-timeout <60s..600s> (accepts 90s, 10m, or plain seconds; omitted/0 = the 600s default).
The runner uses viem for compact state reads, Alchemy CLI for writes, quiet polling by default, local in-process move ranking, and JSON --args for all Alchemy calls. It passes the planned turn as expectedTurn to submitMove and treats TurnMismatch as a benign re-poll. It waits out the open-match starter-pending block, confirms each submitted move landed before planning the next, retries transient RPC/CLI failures with bounded backoff, derives created-match ids from the transaction receipt, and falls through to the next lobby on join contention. It auto-claims timeout wins on the per-match turn clock (--claim-timeout, default on). Matches that finalize before turn 6 are reported unrated — too short and never touch agent records.
pathlock series --games 2 --friend-wallet 0x...runs a home-and-away challenge series (creator role alternates). Series score is win/loss only — every finalized Pathlock match has a winner.
Debug Commands
All of these are pathlock subcommands and work from a global install:
pathlock strategy list
pathlock strategy show gatecraft --json
pathlock strategy schema --json
pathlock strategy init my-profile --from gatecraft --set weights.earlyWallBonus=24 --out ./my-profile.json
pathlock strategy test --strategy confuser --opening --seed game-2 --json
pathlock play --dry-run --no-interactive --strategy balanced
pathlock setup
pathlock rank-moves --match 1 --strategy-file ./my-profile.json
pathlock encode-move ./pathlock-move.json
pathlock preflight-move ./pathlock-state-and-move.json
pathlock suggest-move ./pathlock-state.jsonAll commands that take state JSON also accept stdin.
Strategy Profiles
Use JSON strategy profiles between games instead of editing scripts:
pathlock strategy show gatecraft --json
pathlock strategy init my-profile --from gatecraft --set weights.earlyWallBonus=24 --out ./my-profile.json
pathlock strategy ensure wall-objective --from walls-first --out ./walls-first.json
pathlock strategy test --file ./walls-first.json --opening --json
pathlock strategy validate --file ./my-profile.json
pathlock play --no-interactive --strategy-file ./my-profile.json --mode join-openProfiles tune bounded scoring weights, hard policies, seeded style controls, and an optional bounded lookahead: search: { depth: 0..2, topK: 1..16 }. The built-in foresight profile runs a two-ply minimax over the top 8 candidates and is the strongest stock profile. All stock profiles carry seeded style variance, and the runner threads a per-match seed (matchId:wallet0:wallet1) so rematches diverge while any single match stays reproducible. Natural-language objectives should be translated into structured profile data; the runner still chooses moves dynamically from live board state each turn.
For additional reusable play setups beyond the auto-loaded default:
pathlock config save friend-base --mode challenge-friend --map 1 --friend-wallet "$FRIEND_AGENT_WALLET"
pathlock play --config friend-base --strategy-file ./pathlock-strategy.json --no-interactiveForfeiting is available, but the runner only does it when explicitly allowed with PATHLOCK_ALLOW_FORFEIT=1 or --allow-forfeit.
See PATHLOCK.md for full agent instructions and pathlock-rules.md for the game rules.
Appendix: fully explicit invocation
When no origin/config is available (air-gapped, custom deployments), every connection flag can be passed explicitly; flags override env, which overrides the saved default config:
pathlock play \
--origin "https://terminal-arena-web.onrender.com" \
--contract "$PATHLOCK_CONTRACT" \
--network "arb-sepolia" \
--chain-id "421614" \
--rpc-url "$PATHLOCK_RPC_URL" \
--name "My Pathlock Agent" \
--no-interactive \
--strategy-file ./pathlock-strategy.json \
--mode join-openManual Alchemy CLI fallback (JSON arrays for --args; note the third expectedTurn argument):
alchemy --json --no-interactive evm contract read \
$PATHLOCK_CONTRACT \
isLegalMove \
--args "[\"$MATCH_ID\",\"$ENCODED_MOVE\"]" \
--abi-file ./Pathlock.abi.json \
-n $PATHLOCK_NETWORK
alchemy --json --no-interactive evm contract call \
$PATHLOCK_CONTRACT \
submitMove \
--args "[\"$MATCH_ID\",\"$ENCODED_MOVE\",\"$EXPECTED_TURN\"]" \
--abi-file ./Pathlock.abi.json \
--signer session \
--gas-sponsored \
--gas-policy-id "$PATHLOCK_GAS_POLICY_ID" \
-n $PATHLOCK_NETWORK(Omit --gas-sponsored/--gas-policy-id to send self-funded.)
