@chrischall/warapp-mcp 0.10.0 → 0.11.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 +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/dist/analysis/plan/relations.js +5 -0
- package/dist/analysis/player-record.js +31 -1
- package/dist/analysis/relations.js +54 -5
- package/dist/bundle.js +549 -224
- package/dist/chat-links.js +141 -0
- package/dist/player-record-store.js +5 -3
- package/dist/relations-store.js +29 -1
- package/dist/tools/chat-advice.js +1 -1
- package/dist/tools/chat-inbox.js +6 -2
- package/dist/tools/chat.js +46 -8
- package/dist/tools/check-plan.js +14 -1
- package/dist/tools/relations.js +104 -6
- package/dist/tools/turn.js +83 -12
- package/dist/version.js +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/warapp-mcp/SKILL.md +16 -2
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"metadata": {
|
|
9
9
|
"description": "MCP server for war.app (Warzone) — your games, players, settings, map bonuses and chokepoints, board analysis and route planning through war.app's per-player GameFeed API, plus the live board, territory picks, cards, turn planning and submission, turn notifications and game chat through your signed-in war.app tab (joining, leaving or surrendering a game, accepting another player's surrender, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, marking notifications and chat read, deleting notifications, importing local history and linking a session are confirm-gated).",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.11.0"
|
|
11
11
|
},
|
|
12
12
|
"plugins": [
|
|
13
13
|
{
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"displayName": "war.app (Warzone)",
|
|
16
16
|
"source": "./",
|
|
17
17
|
"description": "war.app (Warzone) game advisor for Claude — games, maps, bonuses, routes, live board, picks, turns, cards and chat",
|
|
18
|
-
"version": "0.
|
|
18
|
+
"version": "0.11.0",
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "Chris Hall"
|
|
21
21
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "warapp-mcp",
|
|
3
3
|
"displayName": "war.app (Warzone)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0",
|
|
5
5
|
"description": "war.app (Warzone) game advisor for Claude — games, maps, bonuses, routes, live board, picks, turns, cards and chat",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Chris Hall",
|
|
@@ -650,6 +650,10 @@ export function reportTruce(pc, ps, tp, freedOn) {
|
|
|
650
650
|
? `; the card lasts until turn ${r.enforcedUntil}.`
|
|
651
651
|
: '.')
|
|
652
652
|
: `${name}${notice}: none of its ${r.coveredTheirs.length} covered ${r.coveredTheirs.length === 1 ? 'territory is' : 'territories are'} a target this turn (T1), and player ${r.player} is no front for the no-second-front rule or the idle armies (T4).`);
|
|
653
|
+
for (const e of r.exceptions ?? [])
|
|
654
|
+
rationale.push(e.direction === 'mine'
|
|
655
|
+
? `${name}: player ${r.player} agreed to an exception this turn, so ${e.territories.map(label).join(', ')} ${e.territories.length === 1 ? 'is a normal target' : 'are normal targets'} — no break.`
|
|
656
|
+
: `${name}: I agreed to an exception this turn, so player ${r.player} may attack ${e.territories.map(label).join(', ')}: ${e.territories.length === 1 ? 'it is' : 'they are'} held as against any opponent.`);
|
|
653
657
|
if (mineRelaxed.length)
|
|
654
658
|
rationale.push(`${name}: ${mineRelaxed.map(label).join(', ')} ${mineRelaxed.length === 1 ? 'faces' : 'face'} only player ${r.player}, so ${mineRelaxed.length === 1 ? 'it is' : 'they are'} held against its visible stacks there attacking with no deploy (T2) — a break needs a visible build-up first; ${freed} ${freed === 1 ? 'army' : 'armies'} freed this turn.`);
|
|
655
659
|
const why = { commander: 'my commander stands there', value: `it protects more than ${TRUCE_RELAX_VALUE} × my income`, watch: `the trust is watch (${flags.join(', ') || 'a flag'})` };
|
|
@@ -677,6 +681,7 @@ export function reportTruce(pc, ps, tp, freedOn) {
|
|
|
677
681
|
armiesFreed: freed,
|
|
678
682
|
...(tp?.capMoved.get(i)?.length ? { capMoved: tp.capMoved.get(i) } : {}),
|
|
679
683
|
...(r.breach ? { breach: r.breach } : {}),
|
|
684
|
+
...(r.exceptions?.length ? { exceptions: r.exceptions } : {}),
|
|
680
685
|
// T6: filled in once the plan's orders are final (truceBreakLosses).
|
|
681
686
|
lossIfBroken: null,
|
|
682
687
|
};
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
// terms, the outcome (kept, ended with notice and whether it was honoured, broken by them or by
|
|
9
9
|
// me), the break turn and the strongest breach flag my boards showed, the context at the break
|
|
10
10
|
// (endgame, who led, outgrowing), whether they retaliated and whether they proposed again;
|
|
11
|
+
// - partner-approved exceptions (attacks the partner agreed to, either way) are no break: counted apart
|
|
12
|
+
// (`exceptionsMine` / `exceptionsTheirs`, and per entry), never in the outcome;
|
|
11
13
|
// - tallies (`RecordCounts`), each moved once by the recorded transition that earns it
|
|
12
14
|
// (`recordDelta`), so recording the same agreement again never counts it twice, and an entry
|
|
13
15
|
// dropped past the bound still counts.
|
|
@@ -59,6 +61,7 @@ export function recordEntryFor(a, input, previous) {
|
|
|
59
61
|
...outcomeOf(a),
|
|
60
62
|
...(previous?.proposedAgain ? { proposedAgain: true } : {}),
|
|
61
63
|
...(a.retaliated !== undefined ? { retaliated: a.retaliated } : {}),
|
|
64
|
+
...(a.exceptions?.length ? { exceptions: exceptionCounts(a) } : {}),
|
|
62
65
|
updated: input.now,
|
|
63
66
|
};
|
|
64
67
|
if (a.status === 'broken-by-them' || a.status === 'broken-by-me') {
|
|
@@ -76,8 +79,23 @@ export function upsertEntry(entries, entry) {
|
|
|
76
79
|
const rest = entries.filter((e) => e.key !== entry.key);
|
|
77
80
|
return [...rest, entry].sort(byUpdated).slice(-MAX_RECORD_ENTRIES);
|
|
78
81
|
}
|
|
79
|
-
export const ZERO_COUNTS = Object.freeze({
|
|
82
|
+
export const ZERO_COUNTS = Object.freeze({
|
|
83
|
+
made: 0,
|
|
84
|
+
kept: 0,
|
|
85
|
+
endedWithNotice: 0,
|
|
86
|
+
brokenByThem: 0,
|
|
87
|
+
brokenByMe: 0,
|
|
88
|
+
exceptionsMine: 0,
|
|
89
|
+
exceptionsTheirs: 0,
|
|
90
|
+
});
|
|
80
91
|
export const COUNT_KEYS = Object.keys(ZERO_COUNTS);
|
|
92
|
+
/** The tallies every stored version carries; the exception tallies came later and read as 0 when absent. */
|
|
93
|
+
export const CORE_COUNT_KEYS = ['made', 'kept', 'endedWithNotice', 'brokenByThem', 'brokenByMe'];
|
|
94
|
+
/** `a`'s exceptions counted by direction. */
|
|
95
|
+
function exceptionCounts(a) {
|
|
96
|
+
const list = a.exceptions ?? [];
|
|
97
|
+
return { mine: list.filter((e) => e.direction === 'mine').length, theirs: list.filter((e) => e.direction === 'theirs').length };
|
|
98
|
+
}
|
|
81
99
|
const OUTCOME_COUNT = {
|
|
82
100
|
kept: 'kept',
|
|
83
101
|
'ended-with-notice': 'endedWithNotice',
|
|
@@ -98,6 +116,16 @@ export function recordDelta(before, after) {
|
|
|
98
116
|
if (key)
|
|
99
117
|
delta[key] = 1;
|
|
100
118
|
}
|
|
119
|
+
// Each exception once, by its id: one already on `before` is not counted again.
|
|
120
|
+
const had = new Set((before?.exceptions ?? []).map((e) => e.id));
|
|
121
|
+
for (const e of after.exceptions ?? []) {
|
|
122
|
+
if (had.has(e.id))
|
|
123
|
+
continue;
|
|
124
|
+
if (e.direction === 'mine')
|
|
125
|
+
delta.exceptionsMine++;
|
|
126
|
+
else
|
|
127
|
+
delta.exceptionsTheirs++;
|
|
128
|
+
}
|
|
101
129
|
return delta;
|
|
102
130
|
}
|
|
103
131
|
export const isZero = (c) => COUNT_KEYS.every((k) => c[k] === 0);
|
|
@@ -116,6 +144,8 @@ export function talliesOf(entries) {
|
|
|
116
144
|
const key = OUTCOME_COUNT[e.outcome];
|
|
117
145
|
if (key)
|
|
118
146
|
out[key]++;
|
|
147
|
+
out.exceptionsMine += e.exceptions?.mine ?? 0;
|
|
148
|
+
out.exceptionsTheirs += e.exceptions?.theirs ?? 0;
|
|
119
149
|
}
|
|
120
150
|
return out;
|
|
121
151
|
}
|
|
@@ -44,6 +44,36 @@ export const TACIT_QUIET_TURNS = 3;
|
|
|
44
44
|
* and the partner's. The partner no longer needs me from there on.
|
|
45
45
|
*/
|
|
46
46
|
export const TRUCE_ENDGAME_RATIO = 0.5;
|
|
47
|
+
/**
|
|
48
|
+
* Who an exception lets attack: `mine` — the partner agreed I may attack its covered territories;
|
|
49
|
+
* `theirs` — I agreed the partner may attack (or take) covered territories of mine.
|
|
50
|
+
*/
|
|
51
|
+
export const EXCEPTION_DIRECTIONS = ['mine', 'theirs'];
|
|
52
|
+
/** Exceptions kept per agreement (the newest). */
|
|
53
|
+
export const MAX_EXCEPTIONS = 50;
|
|
54
|
+
/** The longest note an exception keeps (the owner's own words, names scrubbed). */
|
|
55
|
+
export const MAX_EXCEPTION_NOTE = 200;
|
|
56
|
+
/** The next exception id on `a`: `e1`, `e2`, … */
|
|
57
|
+
export function nextExceptionId(a) {
|
|
58
|
+
const n = (a.exceptions ?? []).reduce((m, e) => Math.max(m, Number(/^e(\d+)$/.exec(e.id)?.[1] ?? 0)), 0);
|
|
59
|
+
return `e${n + 1}`;
|
|
60
|
+
}
|
|
61
|
+
/** `a` with `exceptions` appended (fresh ids), at most {@link MAX_EXCEPTIONS} kept (the newest). */
|
|
62
|
+
export function withExceptions(a, exceptions) {
|
|
63
|
+
let next = a;
|
|
64
|
+
for (const e of exceptions)
|
|
65
|
+
next = { ...next, exceptions: [...(next.exceptions ?? []), { id: nextExceptionId(next), ...e }] };
|
|
66
|
+
return next.exceptions && next.exceptions.length > MAX_EXCEPTIONS ? { ...next, exceptions: next.exceptions.slice(-MAX_EXCEPTIONS) } : next;
|
|
67
|
+
}
|
|
68
|
+
/** The territories `a`'s exceptions in `direction` open on `turn` (the turn's orders), ascending. */
|
|
69
|
+
export function exceptedOn(a, turn, direction) {
|
|
70
|
+
const out = new Set();
|
|
71
|
+
for (const e of a.exceptions ?? [])
|
|
72
|
+
if (e.direction === direction && e.fromTurn <= turn && turn <= e.toTurn)
|
|
73
|
+
for (const t of e.territories)
|
|
74
|
+
out.add(t);
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
47
77
|
const byNum = (a, b) => a - b;
|
|
48
78
|
const alive = (p) => p !== undefined && (p.state === undefined || p.state === 'Playing');
|
|
49
79
|
const turnedAI = (p) => p.isAI === true || p.humanTurnedIntoAI === true;
|
|
@@ -234,7 +264,8 @@ function fedByHitSource(t, orders, mine, was, now, me) {
|
|
|
234
264
|
* leaves ambiguous;
|
|
235
265
|
* - `outgrowing`: its income passed {@link TRUCE_OUTGROW_RATIO} × mine;
|
|
236
266
|
* - `kept`: the consecutive quiet turns up to the newest board (when nothing broke).
|
|
237
|
-
* A
|
|
267
|
+
* A covered territory under a `theirs` exception on a turn (the partner may attack it by agreement) raises
|
|
268
|
+
* nothing that turn. A proposal that was never agreed has no flags.
|
|
238
269
|
*/
|
|
239
270
|
export function breachWatch(input) {
|
|
240
271
|
const { agreement: a, graph, me } = input;
|
|
@@ -261,7 +292,11 @@ export function breachWatch(input) {
|
|
|
261
292
|
const taken = [];
|
|
262
293
|
const attacked = [];
|
|
263
294
|
const ambiguous = [];
|
|
295
|
+
// A `theirs` exception on this turn: the partner may attack or take these by agreement — no event.
|
|
296
|
+
const allowed = exceptedOn(a, from.turn, 'theirs');
|
|
264
297
|
for (const c of covered) {
|
|
298
|
+
if (allowed.has(c))
|
|
299
|
+
continue;
|
|
265
300
|
const after = now.get(c);
|
|
266
301
|
const shown = ownerShown(after);
|
|
267
302
|
const neighbours = neighborsOf(graph, c);
|
|
@@ -518,7 +553,8 @@ const WATCH_KINDS = ['broken', 'cap-exceeded', 'massing', 'outgrowing'];
|
|
|
518
553
|
/**
|
|
519
554
|
* B2 (warapp_submit_turn): the active or in-notice agreements that `moves` would break — an order that
|
|
520
555
|
* attacks a territory the partner holds on `board` and the terms cover (a transfer-only order attacks
|
|
521
|
-
* nothing), or a Bomb (`bombs`, the targets) on such a territory
|
|
556
|
+
* nothing), or a Bomb (`bombs`, the targets) on such a territory — except one a `mine` exception opens on `turn`
|
|
557
|
+
* (the partner agreed to it). By agreement id; empty when nothing binds. Pure; reads only the ledger's own agreements and
|
|
522
558
|
* the board (the breach watch is not consulted: a break by them is recorded as broken-by-them first).
|
|
523
559
|
*/
|
|
524
560
|
export function truceBreaksIn(input) {
|
|
@@ -530,7 +566,9 @@ export function truceBreaksIn(input) {
|
|
|
530
566
|
if (state.phase !== 'active' && state.phase !== 'notice')
|
|
531
567
|
continue;
|
|
532
568
|
const held = new Set(input.board.territories.filter((t) => ownerShown(t) && ownerOn(t) === a.with).map((t) => t.territoryId));
|
|
533
|
-
|
|
569
|
+
// A `mine` exception on this turn: the partner agreed to these attacks — no break.
|
|
570
|
+
const allowed = exceptedOn(a, input.turn, 'mine');
|
|
571
|
+
const covered = new Set(coveredTerritories(input.graph, a.terms.scope, held).filter((t) => !allowed.has(t)));
|
|
534
572
|
const moves = input.moves.flatMap((m, index) => (m.mode !== 'transfer-only' && covered.has(m.to) ? [{ index, from: m.from, to: m.to }] : []));
|
|
535
573
|
const bombs = (input.bombs ?? []).flatMap((target, index) => (covered.has(target) ? [{ index, target }] : []));
|
|
536
574
|
if (moves.length || bombs.length)
|
|
@@ -566,10 +604,21 @@ export function planRelationsFrom(input) {
|
|
|
566
604
|
if (endgame)
|
|
567
605
|
watch.push('endgame');
|
|
568
606
|
const broke = flags.find((f) => f.kind === 'broken' && !f.ambiguous);
|
|
607
|
+
// Partner-approved exceptions on this turn: those territories are no longer covered (normal targets
|
|
608
|
+
// for me, or open to the partner), and the plan lists them.
|
|
609
|
+
const exceptMine = exceptedOn(a, turn, 'mine');
|
|
610
|
+
const exceptTheirs = exceptedOn(a, turn, 'theirs');
|
|
611
|
+
const coveredMine = coveredTerritories(graph, a.terms.scope, mine);
|
|
612
|
+
const coveredTheirs = coveredTerritories(graph, a.terms.scope, holding(a.with));
|
|
613
|
+
const exceptions = [
|
|
614
|
+
{ direction: 'mine', territories: coveredTheirs.filter((t) => exceptMine.has(t)) },
|
|
615
|
+
{ direction: 'theirs', territories: coveredMine.filter((t) => exceptTheirs.has(t)) },
|
|
616
|
+
].filter((e) => e.territories.length);
|
|
569
617
|
relations.push({
|
|
570
618
|
player: a.with,
|
|
571
|
-
coveredMine:
|
|
572
|
-
coveredTheirs:
|
|
619
|
+
coveredMine: coveredMine.filter((t) => !exceptTheirs.has(t)),
|
|
620
|
+
coveredTheirs: coveredTheirs.filter((t) => !exceptMine.has(t)),
|
|
621
|
+
...(exceptions.length ? { exceptions } : {}),
|
|
573
622
|
state: broke ? 'broken' : state.phase,
|
|
574
623
|
...(state.endsTurn !== undefined ? { endsTurn: state.endsTurn } : {}),
|
|
575
624
|
...(a.terms.borderCap !== undefined ? { borderCap: a.terms.borderCap } : {}),
|