@chrischall/warapp-mcp 0.0.0-stage → 0.1.0
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/.claude-plugin/marketplace.json +34 -0
- package/.claude-plugin/plugin.json +21 -0
- package/.mcp.json +11 -0
- package/LICENSE +21 -0
- package/README.md +264 -2
- package/dist/analysis/award.js +159 -0
- package/dist/analysis/bonuses.js +98 -0
- package/dist/analysis/breach.js +62 -0
- package/dist/analysis/card-support.js +329 -0
- package/dist/analysis/card-threats.js +234 -0
- package/dist/analysis/cards-in-effect.js +130 -0
- package/dist/analysis/chains.js +59 -0
- package/dist/analysis/chokepoints.js +140 -0
- package/dist/analysis/combat.js +231 -0
- package/dist/analysis/commander-safety.js +149 -0
- package/dist/analysis/commitments.js +338 -0
- package/dist/analysis/exchange.js +155 -0
- package/dist/analysis/graph.js +82 -0
- package/dist/analysis/guard-off.js +54 -0
- package/dist/analysis/guess.js +351 -0
- package/dist/analysis/headroom.js +241 -0
- package/dist/analysis/hold-diff.js +64 -0
- package/dist/analysis/how-lost.js +130 -0
- package/dist/analysis/index.js +14 -0
- package/dist/analysis/local-deploy.js +159 -0
- package/dist/analysis/lookahead.js +108 -0
- package/dist/analysis/opponent-profile.js +551 -0
- package/dist/analysis/opponents.js +1245 -0
- package/dist/analysis/outlook.js +633 -0
- package/dist/analysis/overrides.js +60 -0
- package/dist/analysis/picks.js +1879 -0
- package/dist/analysis/plan/after-leftover.js +140 -0
- package/dist/analysis/plan/cap-spend.js +242 -0
- package/dist/analysis/plan/captures.js +1195 -0
- package/dist/analysis/plan/commander.js +236 -0
- package/dist/analysis/plan/completed.js +29 -0
- package/dist/analysis/plan/conceded-out.js +131 -0
- package/dist/analysis/plan/estimates.js +715 -0
- package/dist/analysis/plan/guard-off.js +232 -0
- package/dist/analysis/plan/holds.js +1631 -0
- package/dist/analysis/plan/leftover.js +760 -0
- package/dist/analysis/plan/move-order.js +319 -0
- package/dist/analysis/plan/orders.js +317 -0
- package/dist/analysis/plan/relations.js +702 -0
- package/dist/analysis/plan/report.js +672 -0
- package/dist/analysis/plan/shared.js +1218 -0
- package/dist/analysis/plan/stand-still.js +823 -0
- package/dist/analysis/plan/state.js +44 -0
- package/dist/analysis/plan/strike.js +1416 -0
- package/dist/analysis/plan/targets.js +651 -0
- package/dist/analysis/plan/team.js +299 -0
- package/dist/analysis/plan/threats.js +927 -0
- package/dist/analysis/plan/transfers.js +328 -0
- package/dist/analysis/plan/util.js +5 -0
- package/dist/analysis/plan/vacated.js +285 -0
- package/dist/analysis/planner.js +2922 -0
- package/dist/analysis/player-record.js +144 -0
- package/dist/analysis/player.js +268 -0
- package/dist/analysis/profile.js +347 -0
- package/dist/analysis/relations.js +1030 -0
- package/dist/analysis/schedule.js +88 -0
- package/dist/analysis/since-last.js +50 -0
- package/dist/analysis/static-seats.js +71 -0
- package/dist/analysis/stress.js +577 -0
- package/dist/analysis/team-brief.js +151 -0
- package/dist/analysis/tripwire.js +644 -0
- package/dist/analysis/turn-sim.js +259 -0
- package/dist/analysis/whereabouts.js +1109 -0
- package/dist/board.js +105 -0
- package/dist/bundle.js +143479 -0
- package/dist/cards.js +435 -0
- package/dist/chat-cursor.js +135 -0
- package/dist/chat.js +192 -0
- package/dist/client.js +361 -0
- package/dist/config.js +62 -0
- package/dist/direct/link.js +102 -0
- package/dist/direct/session.js +267 -0
- package/dist/direct/transport.js +424 -0
- package/dist/guess-salt.js +65 -0
- package/dist/hosted.js +24 -0
- package/dist/index.js +33 -0
- package/dist/join-color.js +140 -0
- package/dist/live.js +278 -0
- package/dist/map-stats.js +152 -0
- package/dist/map-store.js +204 -0
- package/dist/move-order.js +141 -0
- package/dist/my-games.js +180 -0
- package/dist/normalize.js +411 -0
- package/dist/open-games.js +537 -0
- package/dist/outlook-log.js +138 -0
- package/dist/path-lock.js +22 -0
- package/dist/pick-list.js +193 -0
- package/dist/player-record-store.js +229 -0
- package/dist/player-states.js +31 -0
- package/dist/profile-store.js +677 -0
- package/dist/protocol/bundle.js +375 -0
- package/dist/protocol/codec.js +556 -0
- package/dist/protocol/decoded.js +12 -0
- package/dist/protocol/interp.js +1904 -0
- package/dist/protocol/methods.js +531 -0
- package/dist/protocol/rpc.js +202 -0
- package/dist/push/listener.js +393 -0
- package/dist/push/packets.js +66 -0
- package/dist/push/socketio.js +333 -0
- package/dist/push/websocket.js +179 -0
- package/dist/redact.js +62 -0
- package/dist/relations-store.js +242 -0
- package/dist/replay.js +215 -0
- package/dist/scalars.js +28 -0
- package/dist/scout.js +346 -0
- package/dist/stats.js +269 -0
- package/dist/strategy/card-clock.js +185 -0
- package/dist/strategy/map-notes.js +128 -0
- package/dist/strategy/notes.js +2168 -0
- package/dist/team-cards.js +84 -0
- package/dist/team-orders.js +150 -0
- package/dist/teams.js +19 -0
- package/dist/tools/award.js +206 -0
- package/dist/tools/begin-turn.js +162 -0
- package/dist/tools/board.js +77 -0
- package/dist/tools/card-advice.js +256 -0
- package/dist/tools/card-effects.js +49 -0
- package/dist/tools/card-plays.js +434 -0
- package/dist/tools/card-support-advice.js +140 -0
- package/dist/tools/chat-inbox.js +146 -0
- package/dist/tools/chat.js +483 -0
- package/dist/tools/check-plan.js +688 -0
- package/dist/tools/commander-check.js +102 -0
- package/dist/tools/commitments.js +216 -0
- package/dist/tools/common.js +143 -0
- package/dist/tools/diplomacy.js +342 -0
- package/dist/tools/game.js +126 -0
- package/dist/tools/guess-view.js +56 -0
- package/dist/tools/healthcheck.js +90 -0
- package/dist/tools/hints.js +34 -0
- package/dist/tools/how-lost.js +154 -0
- package/dist/tools/index.js +142 -0
- package/dist/tools/join-game.js +327 -0
- package/dist/tools/leave-game.js +181 -0
- package/dist/tools/live-context.js +339 -0
- package/dist/tools/live.js +404 -0
- package/dist/tools/map-stats.js +117 -0
- package/dist/tools/map.js +133 -0
- package/dist/tools/my-games.js +123 -0
- package/dist/tools/open-games.js +104 -0
- package/dist/tools/opponents.js +151 -0
- package/dist/tools/order-options.js +135 -0
- package/dist/tools/picks.js +292 -0
- package/dist/tools/profile-hook.js +156 -0
- package/dist/tools/profile-opponents.js +121 -0
- package/dist/tools/profile-reads.js +99 -0
- package/dist/tools/push.js +385 -0
- package/dist/tools/relations.js +611 -0
- package/dist/tools/resolve.js +45 -0
- package/dist/tools/route.js +36 -0
- package/dist/tools/scout.js +87 -0
- package/dist/tools/session.js +163 -0
- package/dist/tools/strategy.js +200 -0
- package/dist/tools/stress-opponents.js +83 -0
- package/dist/tools/surrender.js +240 -0
- package/dist/tools/survival.js +189 -0
- package/dist/tools/team-brief.js +266 -0
- package/dist/tools/team-source.js +222 -0
- package/dist/tools/team.js +182 -0
- package/dist/tools/turn.js +2761 -0
- package/dist/tools/uncommit.js +160 -0
- package/dist/tools/where.js +275 -0
- package/dist/tools/write-kit.js +158 -0
- package/dist/transport-bridge.js +33 -0
- package/dist/trend.js +452 -0
- package/dist/version.js +4 -0
- package/manifest.json +247 -0
- package/mint.yaml +140 -0
- package/package.json +68 -4
- package/server.json +72 -0
- package/skills/warapp-api/SKILL.md +226 -0
- package/skills/warapp-api/references/scout.mjs +348 -0
- package/skills/warapp-api/scripts/warapp.sh +228 -0
- package/skills/warapp-mcp/SKILL.md +1011 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# warapp-api helper — source me (bash or zsh), then pipe into jq:
|
|
2
|
+
#
|
|
3
|
+
# source <skill>/scripts/warapp.sh
|
|
4
|
+
# warapp_game 45670418 | jq '{name, state}'
|
|
5
|
+
# warapp_map 45670418 | jq '.bonuses | length'
|
|
6
|
+
#
|
|
7
|
+
# Every call is POST https://war.app/API/GameFeed?GameID=<n> with the form body
|
|
8
|
+
# Email=<email>&APIToken=<token>. Credentials come from WARAPP_EMAIL /
|
|
9
|
+
# WARAPP_API_TOKEN, else from the dotenv file WARAPP_ENV_FILE (default
|
|
10
|
+
# ~/.config/warapp-mcp/.env — the same file warapp-mcp reads). The environment
|
|
11
|
+
# wins over the file. The file is parsed, never sourced, and the credentials
|
|
12
|
+
# live only in function-local variables: they are never exported, never put
|
|
13
|
+
# on curl's command line (the body goes in on stdin) and never printed — an
|
|
14
|
+
# upstream error has both scrubbed before it reaches stderr.
|
|
15
|
+
#
|
|
16
|
+
# Extra Param=value arguments are checked against a conservative character set, and
|
|
17
|
+
# curl runs with URL globbing off, reads no config file (-q, which must come first),
|
|
18
|
+
# speaks only the checked origin's protocol and follows no redirect, so every request
|
|
19
|
+
# of a call (one, or two when curl's single retry answers a transient error) goes to
|
|
20
|
+
# the checked origin and nowhere else. A loopback test origin bypasses every proxy;
|
|
21
|
+
# war.app keeps the environment's proxy settings.
|
|
22
|
+
#
|
|
23
|
+
# Return codes: 0 ok · 1 usage (bad game id, bad extra argument, refused
|
|
24
|
+
# WARAPP_BASE_URL) · 2 no credentials ·
|
|
25
|
+
# 3 Auth failed (wrong email/token) · 4 no such game · 5 anything else
|
|
26
|
+
# (network, HTTP error, non-JSON answer, other GameFeed error).
|
|
27
|
+
#
|
|
28
|
+
# war.app answers errors as HTTP 200 {"termsOfUse": …, "error": …}; these
|
|
29
|
+
# functions turn that into the codes above, so a 0 means a real game body.
|
|
30
|
+
#
|
|
31
|
+
# Variable names avoid `path` and `status` (special in zsh).
|
|
32
|
+
|
|
33
|
+
# Character classes are spelled out, never ranges: under a UTF-8 locale some shells
|
|
34
|
+
# (macOS /bin/bash 3.2) match [A-Za-z0-9] by collation order, letting accented and
|
|
35
|
+
# fullwidth letters through. Spelled out, the sets hold ASCII only in every shell and locale.
|
|
36
|
+
|
|
37
|
+
# _warapp_gameid <id>: a positive whole number below 2^31.
|
|
38
|
+
_warapp_gameid() {
|
|
39
|
+
case "${1:-}" in
|
|
40
|
+
'' | *[!0123456789]* | 0*)
|
|
41
|
+
echo "warapp: game id must be a positive whole number, got '${1:-}'" >&2
|
|
42
|
+
return 1
|
|
43
|
+
;;
|
|
44
|
+
esac
|
|
45
|
+
if [ "${#1}" -gt 10 ] || [ "$1" -gt 2147483647 ]; then
|
|
46
|
+
echo "warapp: game id must be below 2^31, got '$1'" >&2
|
|
47
|
+
return 1
|
|
48
|
+
fi
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# _warapp_base: print the GameFeed origin. WARAPP_BASE_URL is a test seam only: the
|
|
52
|
+
# credentials go in every request, so it is honoured only when it is exactly
|
|
53
|
+
# https://war.app or a loopback stand-in (http://127.0.0.1:<port> or
|
|
54
|
+
# http://localhost:<port>). Anything else is refused before a request is made.
|
|
55
|
+
_warapp_base() {
|
|
56
|
+
local url="${WARAPP_BASE_URL:-https://war.app}" port=''
|
|
57
|
+
case "$url" in
|
|
58
|
+
https://war.app) printf '%s' "$url"; return 0 ;;
|
|
59
|
+
http://127.0.0.1:*) port="${url#http://127.0.0.1:}" ;;
|
|
60
|
+
http://localhost:*) port="${url#http://localhost:}" ;;
|
|
61
|
+
esac
|
|
62
|
+
case "$port" in
|
|
63
|
+
'' | *[!0123456789]*) ;;
|
|
64
|
+
*)
|
|
65
|
+
if [ "${#port}" -le 5 ] && [ "$port" -ge 1 ] && [ "$port" -le 65535 ]; then
|
|
66
|
+
printf '%s' "$url"
|
|
67
|
+
return 0
|
|
68
|
+
fi
|
|
69
|
+
;;
|
|
70
|
+
esac
|
|
71
|
+
echo "warapp: refusing WARAPP_BASE_URL: it must be https://war.app or http://127.0.0.1:<port> / http://localhost:<port>" >&2
|
|
72
|
+
return 1
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# _warapp_arg <Name=value>: an extra query parameter. Name is a letter then letters or
|
|
76
|
+
# digits; value is letters, digits, '.', '_' or '-' (possibly empty). Nothing that could
|
|
77
|
+
# change the query, the URL or the shell's reading of it gets through.
|
|
78
|
+
_warapp_arg() {
|
|
79
|
+
local name="${1%%=*}" val="${1#*=}" ok=1
|
|
80
|
+
case "$1" in *=*) ;; *) ok=0 ;; esac
|
|
81
|
+
case "$name" in
|
|
82
|
+
'' | [!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]* | *[!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]*) ok=0 ;;
|
|
83
|
+
esac
|
|
84
|
+
case "$val" in
|
|
85
|
+
*[!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-]*) ok=0 ;;
|
|
86
|
+
esac
|
|
87
|
+
if [ "$ok" -ne 1 ]; then
|
|
88
|
+
echo "warapp: refusing extra argument: expected Name=value (letters/digits, value also . _ -)" >&2
|
|
89
|
+
return 1
|
|
90
|
+
fi
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# _warapp_load: fill the CALLER's local _warapp_email/_warapp_token.
|
|
94
|
+
_warapp_load() {
|
|
95
|
+
local file line key val
|
|
96
|
+
_warapp_email="${WARAPP_EMAIL:-}"
|
|
97
|
+
_warapp_token="${WARAPP_API_TOKEN:-}"
|
|
98
|
+
file="${WARAPP_ENV_FILE:-$HOME/.config/warapp-mcp/.env}"
|
|
99
|
+
if [ -r "$file" ] && [ -f "$file" ]; then
|
|
100
|
+
while IFS= read -r line || [ -n "$line" ]; do
|
|
101
|
+
line="${line%$'\r'}"
|
|
102
|
+
line="${line#export }"
|
|
103
|
+
case "$line" in *=*) ;; *) continue ;; esac
|
|
104
|
+
key="${line%%=*}"
|
|
105
|
+
val="${line#*=}"
|
|
106
|
+
case "$val" in
|
|
107
|
+
\"*\") val="${val#\"}"; val="${val%\"}" ;;
|
|
108
|
+
\'*\') val="${val#\'}"; val="${val%\'}" ;;
|
|
109
|
+
esac
|
|
110
|
+
case "$key" in
|
|
111
|
+
WARAPP_EMAIL) [ -n "$_warapp_email" ] || _warapp_email="$val" ;;
|
|
112
|
+
WARAPP_API_TOKEN) [ -n "$_warapp_token" ] || _warapp_token="$val" ;;
|
|
113
|
+
esac
|
|
114
|
+
done <"$file"
|
|
115
|
+
fi
|
|
116
|
+
if [ -z "$_warapp_email" ] || [ -z "$_warapp_token" ]; then
|
|
117
|
+
echo "warapp: set WARAPP_EMAIL and WARAPP_API_TOKEN (or put them in $file)." >&2
|
|
118
|
+
echo "warapp: the token is shown at https://war.app/API/GetAPIToken while signed in." >&2
|
|
119
|
+
return 2
|
|
120
|
+
fi
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
# _warapp_uri: URL-encode stdin (kept off argv).
|
|
124
|
+
_warapp_uri() {
|
|
125
|
+
jq -sRr @uri
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
# warapp_feed <game-id> [Param=value …]: the raw GameFeed body for one game.
|
|
129
|
+
# Extra arguments are appended to the query, e.g. GetSettings=true GetMap=false
|
|
130
|
+
# GetHistory=true GetChat=true (each checked by _warapp_arg; anything else exits 1).
|
|
131
|
+
warapp_feed() {
|
|
132
|
+
local game="${1:-}" query='' arg body rc err origin proto noproxy _warapp_email _warapp_token
|
|
133
|
+
_warapp_gameid "$game" || return 1
|
|
134
|
+
shift
|
|
135
|
+
origin="$(_warapp_base)" || return 1
|
|
136
|
+
case "$origin" in
|
|
137
|
+
https://*) proto='=https' noproxy="${no_proxy-${NO_PROXY-}}" ;;
|
|
138
|
+
*) proto='=http' noproxy='*' ;;
|
|
139
|
+
esac
|
|
140
|
+
for arg in "$@"; do
|
|
141
|
+
_warapp_arg "$arg" || return 1
|
|
142
|
+
query="$query&$arg"
|
|
143
|
+
done
|
|
144
|
+
_warapp_load || return 2
|
|
145
|
+
body="$(
|
|
146
|
+
printf 'Email=%s&APIToken=%s' \
|
|
147
|
+
"$(printf '%s' "$_warapp_email" | _warapp_uri)" \
|
|
148
|
+
"$(printf '%s' "$_warapp_token" | _warapp_uri)" |
|
|
149
|
+
curl -q --globoff --proto "$proto" --max-redirs 0 --noproxy "$noproxy" \
|
|
150
|
+
-sS --fail-with-body --max-time 30 --retry 1 \
|
|
151
|
+
-H 'Content-Type: application/x-www-form-urlencoded' \
|
|
152
|
+
--data-binary @- \
|
|
153
|
+
"$origin/API/GameFeed?GameID=$game$query"
|
|
154
|
+
)"
|
|
155
|
+
rc=$?
|
|
156
|
+
if [ "$rc" -ne 0 ]; then
|
|
157
|
+
echo "warapp: request to war.app failed (curl exit $rc)" >&2
|
|
158
|
+
return 5
|
|
159
|
+
fi
|
|
160
|
+
if ! printf '%s' "$body" | jq -e 'type == "object"' >/dev/null 2>&1; then
|
|
161
|
+
echo "warapp: war.app answered with something that is not JSON" >&2
|
|
162
|
+
return 5
|
|
163
|
+
fi
|
|
164
|
+
err="$(printf '%s' "$body" | jq -r '.error // empty | tostring')"
|
|
165
|
+
case "$err" in
|
|
166
|
+
'') ;;
|
|
167
|
+
'Auth failed')
|
|
168
|
+
echo "warapp: Auth failed — wrong email or API token. Get the current token at https://war.app/API/GetAPIToken while signed in (changing the password rotates it)." >&2
|
|
169
|
+
return 3
|
|
170
|
+
;;
|
|
171
|
+
*ServerGameKeyNotFound*)
|
|
172
|
+
echo "warapp: no game $game (or it is not visible to you)" >&2
|
|
173
|
+
return 4
|
|
174
|
+
;;
|
|
175
|
+
*)
|
|
176
|
+
err="${err//"$_warapp_token"/[redacted]}"
|
|
177
|
+
err="${err//"$_warapp_email"/[redacted]}"
|
|
178
|
+
echo "warapp: war.app error: $err" >&2
|
|
179
|
+
return 5
|
|
180
|
+
;;
|
|
181
|
+
esac
|
|
182
|
+
printf '%s\n' "$body"
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
# warapp_game <game-id> [Param=value …]: game, players and settings, without the
|
|
186
|
+
# map (GetSettings=true GetMap=false). Use warapp_map for the map.
|
|
187
|
+
warapp_game() {
|
|
188
|
+
local game="${1:-}"
|
|
189
|
+
_warapp_gameid "$game" || return 1
|
|
190
|
+
shift
|
|
191
|
+
warapp_feed "$game" GetSettings=true GetMap=false "$@"
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
# warapp_map <game-id>: the game's map object. Maps never change for a map id,
|
|
195
|
+
# and war.app asks callers to cache, so it is kept in WARAPP_CACHE_DIR
|
|
196
|
+
# (default ~/.cache/warapp-mcp) and fetched once per game.
|
|
197
|
+
warapp_map() {
|
|
198
|
+
local game="${1:-}" dir mapid out rc
|
|
199
|
+
_warapp_gameid "$game" || return 1
|
|
200
|
+
dir="${WARAPP_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/warapp-mcp}"
|
|
201
|
+
if [ -r "$dir/game-$game.map" ]; then
|
|
202
|
+
mapid="$(cat "$dir/game-$game.map")"
|
|
203
|
+
case "$mapid" in
|
|
204
|
+
'' | *[!0123456789]*) ;;
|
|
205
|
+
*)
|
|
206
|
+
if [ -r "$dir/map-$mapid.json" ]; then
|
|
207
|
+
cat "$dir/map-$mapid.json"
|
|
208
|
+
return 0
|
|
209
|
+
fi
|
|
210
|
+
;;
|
|
211
|
+
esac
|
|
212
|
+
fi
|
|
213
|
+
out="$(warapp_feed "$game")"
|
|
214
|
+
rc=$?
|
|
215
|
+
[ "$rc" -eq 0 ] || return "$rc"
|
|
216
|
+
mapid="$(printf '%s' "$out" | jq -r '.map.id // empty | tostring')"
|
|
217
|
+
case "$mapid" in
|
|
218
|
+
'' | *[!0123456789]*)
|
|
219
|
+
echo "warapp: the response for game $game carries no usable map id" >&2
|
|
220
|
+
return 5
|
|
221
|
+
;;
|
|
222
|
+
esac
|
|
223
|
+
mkdir -p "$dir" &&
|
|
224
|
+
printf '%s' "$out" | jq '.map' >"$dir/map-$mapid.json.tmp" &&
|
|
225
|
+
mv "$dir/map-$mapid.json.tmp" "$dir/map-$mapid.json" &&
|
|
226
|
+
printf '%s\n' "$mapid" >"$dir/game-$game.map"
|
|
227
|
+
printf '%s' "$out" | jq '.map'
|
|
228
|
+
}
|