@chrischall/warapp-mcp 0.0.0 → 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 +4 -4
- package/.claude-plugin/plugin.json +2 -2
- package/README.md +199 -8
- 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 +117959 -36172
- 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 +174 -4
- package/mint.yaml +101 -14
- package/package.json +11 -6
- package/server.json +40 -3
- package/skills/warapp-api/SKILL.md +95 -4
- package/skills/warapp-api/references/scout.mjs +348 -0
- package/skills/warapp-api/scripts/warapp.sh +69 -8
- package/skills/warapp-mcp/SKILL.md +969 -21
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { bonusTerritories } from './bonuses.js';
|
|
2
|
+
import { neighborsOf } from './graph.js';
|
|
3
|
+
const byNum = (a, b) => a - b;
|
|
4
|
+
/** Why an opponent's estimate is what it is, in one line (ids and figures only). */
|
|
5
|
+
export function incomeBasis(e) {
|
|
6
|
+
const card = e.card ? `; with a Reinforcement card of ${e.card.armies} it may hold since turn ${e.card.due}` : '';
|
|
7
|
+
switch (e.source) {
|
|
8
|
+
case 'exact':
|
|
9
|
+
return `exact: every owner is shown${card}`;
|
|
10
|
+
case 'tracked':
|
|
11
|
+
return `tracked: ${e.tracked} over observed turns ${e.trackedTurns.join(', ')}${card}`;
|
|
12
|
+
case 'observed':
|
|
13
|
+
return `observed: deployed ${e.observed} since the previous board${card}`;
|
|
14
|
+
case 'prior':
|
|
15
|
+
return `a prior, not an observation: ${e.prior}${card}`;
|
|
16
|
+
default:
|
|
17
|
+
return `base ${e.base} + visibly held bonuses ${e.bonusIncome}${card}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Each opponent in `foes` (still playing, not on my team), ascending, with its estimate when one exists. */
|
|
21
|
+
export function opponentIncomes(estimates, foes) {
|
|
22
|
+
const by = new Map(estimates.map((e) => [e.playerId, e]));
|
|
23
|
+
return [...foes].sort(byNum).map((player) => {
|
|
24
|
+
const e = by.get(player);
|
|
25
|
+
return e
|
|
26
|
+
? { player, estimate: e.estimate, source: e.source, basis: incomeBasis(e) }
|
|
27
|
+
: { player, estimate: null, source: null, basis: 'nothing of theirs in view' };
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** The teammates' entries the board carries, theirs only, ascending by player. */
|
|
31
|
+
function mateEntries(board, allies) {
|
|
32
|
+
return (board.teammateOrders ?? []).filter((e) => allies.has(e.playerId) && e.orders).sort((a, b) => a.playerId - b.playerId);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The conflicts between my plan's moves and my teammates' entered orders (none when no orders were read:
|
|
36
|
+
* unknown, not "none"). In each teammate's entry order.
|
|
37
|
+
*/
|
|
38
|
+
export function briefConflicts(input) {
|
|
39
|
+
const { g, board, me, allies, moves, bonusesCompleted } = input;
|
|
40
|
+
const owner = new Map(board.territories.map((t) => [t.territoryId, t.owner]));
|
|
41
|
+
const mine = (id) => {
|
|
42
|
+
const o = owner.get(id);
|
|
43
|
+
return o?.kind === 'player' && o.playerId === me;
|
|
44
|
+
};
|
|
45
|
+
const myAttacks = new Map();
|
|
46
|
+
for (const m of moves)
|
|
47
|
+
if (m.kind === 'attack')
|
|
48
|
+
myAttacks.set(m.to, (myAttacks.get(m.to) ?? 0) + m.armies);
|
|
49
|
+
// The bonus my plan works toward at each territory: one it completes first (superbonuses flattened), else a
|
|
50
|
+
// positive bonus with one of my attack targets among its own members (G3: not only completions).
|
|
51
|
+
const working = new Map();
|
|
52
|
+
const completed = [...bonusesCompleted].sort(byNum);
|
|
53
|
+
for (const b of completed)
|
|
54
|
+
for (const t of bonusTerritories(g, b))
|
|
55
|
+
if (!working.has(t))
|
|
56
|
+
working.set(t, { bonus: b, completes: true });
|
|
57
|
+
for (const b of [...g.bonusById.values()].sort((x, y) => x.id - y.id)) {
|
|
58
|
+
if (b.value <= 0 || completed.includes(b.id) || !b.territoryIds.some((t) => myAttacks.has(t)))
|
|
59
|
+
continue;
|
|
60
|
+
for (const t of b.territoryIds)
|
|
61
|
+
if (!working.has(t))
|
|
62
|
+
working.set(t, { bonus: b.id, completes: false });
|
|
63
|
+
}
|
|
64
|
+
const out = [];
|
|
65
|
+
for (const e of mateEntries(board, allies)) {
|
|
66
|
+
const theirAttacks = new Map();
|
|
67
|
+
for (const m of e.orders.moves) {
|
|
68
|
+
if (mine(m.to)) {
|
|
69
|
+
out.push(m.attackTeammates && m.mode !== 'transfer'
|
|
70
|
+
? { kind: 'attacks-me', from: m.from, to: m.to, teammate: e.playerId, armies: m.armies }
|
|
71
|
+
: { kind: 'onto-mine', from: m.from, to: m.to, teammate: e.playerId, armies: m.armies });
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (m.mode === 'transfer')
|
|
75
|
+
continue;
|
|
76
|
+
const o = owner.get(m.to);
|
|
77
|
+
if (o?.kind === 'player' && allies.has(o.playerId))
|
|
78
|
+
continue;
|
|
79
|
+
theirAttacks.set(m.to, (theirAttacks.get(m.to) ?? 0) + m.armies);
|
|
80
|
+
const w = working.get(m.to);
|
|
81
|
+
if (w !== undefined && !myAttacks.has(m.to))
|
|
82
|
+
out.push({ kind: 'bonus', bonus: w.bonus, territory: m.to, teammate: e.playerId, completes: w.completes });
|
|
83
|
+
}
|
|
84
|
+
for (const [territory, theirs] of [...theirAttacks].sort((a, b) => a[0] - b[0])) {
|
|
85
|
+
const mineSent = myAttacks.get(territory);
|
|
86
|
+
if (mineSent === undefined)
|
|
87
|
+
continue;
|
|
88
|
+
out.push({ kind: 'same-target', territory, teammate: e.playerId, mine: mineSent, theirs, joint: input.joint?.has(territory) ?? false });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
/** The asks: each joint capture, then each conceded border of mine a teammate's stack borders. */
|
|
94
|
+
export function briefAsks(input) {
|
|
95
|
+
const { g, board, allies } = input;
|
|
96
|
+
const state = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
97
|
+
const out = input.jointCaptures.map((j) => ({
|
|
98
|
+
kind: 'joint-capture',
|
|
99
|
+
target: j.target,
|
|
100
|
+
teammates: [...j.teammates].sort(byNum),
|
|
101
|
+
...(j.mustGoFirst !== undefined ? { mustGoFirst: j.mustGoFirst } : {}),
|
|
102
|
+
}));
|
|
103
|
+
for (const territory of [...input.conceded].sort(byNum)) {
|
|
104
|
+
const beside = [];
|
|
105
|
+
for (const n of [...neighborsOf(g, territory)].sort(byNum)) {
|
|
106
|
+
const t = state.get(n);
|
|
107
|
+
if (t?.owner.kind !== 'player' || !allies.has(t.owner.playerId) || t.armies === null || t.armies <= 1)
|
|
108
|
+
continue;
|
|
109
|
+
beside.push({ teammate: t.owner.playerId, territory: n, armies: t.armies });
|
|
110
|
+
}
|
|
111
|
+
if (beside.length)
|
|
112
|
+
out.push({ kind: 'cover', territory, beside });
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
export function pickOverlap(g, mine, mates) {
|
|
117
|
+
const out = { overlap: [], sharedBonuses: [], unknown: [] };
|
|
118
|
+
const bonuses = [...g.bonusById.values()].filter((b) => b.value > 0).sort((a, b) => a.id - b.id);
|
|
119
|
+
for (const m of [...mates].sort((a, b) => a.player - b.player)) {
|
|
120
|
+
if (!m.list) {
|
|
121
|
+
out.unknown.push(m.player);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
mine.forEach((t, i) => {
|
|
125
|
+
const j = m.list.indexOf(t);
|
|
126
|
+
if (j >= 0)
|
|
127
|
+
out.overlap.push({ territory: t, mine: i + 1, teammate: m.player, theirs: j + 1 });
|
|
128
|
+
});
|
|
129
|
+
for (const b of bonuses) {
|
|
130
|
+
const members = new Set(bonusTerritories(g, b.id));
|
|
131
|
+
const a = mine.filter((t) => members.has(t)).sort(byNum);
|
|
132
|
+
const c = m.list.filter((t) => members.has(t)).sort(byNum);
|
|
133
|
+
if (a.length && c.length)
|
|
134
|
+
out.sharedBonuses.push({ bonus: b.id, mine: a, teammate: m.player, theirs: c });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
export function picksLost(list, r) {
|
|
140
|
+
const mates = new Set(r.teammateStarts ?? []);
|
|
141
|
+
const theirs = new Set(r.opponentStarts);
|
|
142
|
+
const team = r.teammateStarts !== undefined;
|
|
143
|
+
const lost = [];
|
|
144
|
+
list.forEach((territory, i) => {
|
|
145
|
+
if (mates.has(territory))
|
|
146
|
+
lost.push({ territory, rank: i + 1, by: 'teammate' });
|
|
147
|
+
else if (theirs.has(territory))
|
|
148
|
+
lost.push({ territory, rank: i + 1, by: team ? 'opponent' : 'other' });
|
|
149
|
+
});
|
|
150
|
+
return { granted: [...r.granted], lost, unlisted: [...r.unlisted] };
|
|
151
|
+
}
|