@chrischall/warapp-mcp 0.6.0 → 0.7.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.
Files changed (90) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +99 -6
  4. package/dist/analysis/accept-surrender.js +20 -2
  5. package/dist/analysis/calibrate.js +1 -0
  6. package/dist/analysis/card-support.js +175 -16
  7. package/dist/analysis/card-threats.js +68 -3
  8. package/dist/analysis/chat-advice.js +182 -0
  9. package/dist/analysis/chat-blocks.js +106 -0
  10. package/dist/analysis/chat-intent.js +559 -0
  11. package/dist/analysis/chat-read.js +159 -0
  12. package/dist/analysis/decision-replay.js +279 -0
  13. package/dist/analysis/decision-truth.js +146 -0
  14. package/dist/analysis/finished-game.js +62 -3
  15. package/dist/analysis/game-lessons.js +12 -6
  16. package/dist/analysis/opponent-profile.js +46 -3
  17. package/dist/analysis/opponents.js +245 -19
  18. package/dist/analysis/outlook.js +323 -17
  19. package/dist/analysis/plan/after-leftover.js +4 -1
  20. package/dist/analysis/plan/captures.js +4 -3
  21. package/dist/analysis/plan/estimates.js +70 -6
  22. package/dist/analysis/plan/guard-off.js +2 -1
  23. package/dist/analysis/plan/holds.js +79 -6
  24. package/dist/analysis/plan/leftover.js +145 -5
  25. package/dist/analysis/plan/relations.js +115 -2
  26. package/dist/analysis/plan/shared.js +201 -11
  27. package/dist/analysis/plan/stand-still.js +2 -2
  28. package/dist/analysis/plan/stockpile.js +104 -0
  29. package/dist/analysis/plan/strike.js +34 -7
  30. package/dist/analysis/plan/targets.js +168 -53
  31. package/dist/analysis/plan/threats.js +108 -5
  32. package/dist/analysis/plan/transfers.js +11 -0
  33. package/dist/analysis/plan/two-move.js +70 -0
  34. package/dist/analysis/plan/vacated.js +124 -2
  35. package/dist/analysis/planner.js +302 -42
  36. package/dist/analysis/since-last.js +18 -5
  37. package/dist/board.js +36 -2
  38. package/dist/build-id.js +106 -0
  39. package/dist/bundle.js +14943 -10146
  40. package/dist/chat-automation.js +22 -0
  41. package/dist/client.js +14 -0
  42. package/dist/decision-log.js +1093 -0
  43. package/dist/finished-store.js +5 -1
  44. package/dist/lessons-store.js +322 -21
  45. package/dist/open-games.js +36 -16
  46. package/dist/outlook-log.js +42 -1
  47. package/dist/protocol/methods.js +4 -2
  48. package/dist/review-export.js +198 -0
  49. package/dist/state-bundle.js +62 -3
  50. package/dist/state-cli.js +5 -3
  51. package/dist/strategy/notes.js +56 -0
  52. package/dist/tools/accept-surrender.js +23 -9
  53. package/dist/tools/award.js +5 -1
  54. package/dist/tools/card-advice.js +77 -23
  55. package/dist/tools/card-support-advice.js +36 -7
  56. package/dist/tools/chat-advice.js +330 -0
  57. package/dist/tools/chat-inbox.js +15 -4
  58. package/dist/tools/chat.js +41 -11
  59. package/dist/tools/check-plan.js +14 -2
  60. package/dist/tools/decision-capture.js +459 -0
  61. package/dist/tools/end-of-game.js +146 -18
  62. package/dist/tools/game-kind.js +92 -0
  63. package/dist/tools/how-lost.js +7 -2
  64. package/dist/tools/index.js +3 -0
  65. package/dist/tools/join-game.js +10 -4
  66. package/dist/tools/live-context.js +6 -0
  67. package/dist/tools/live.js +10 -1
  68. package/dist/tools/map-curves.js +73 -0
  69. package/dist/tools/notifications.js +4 -3
  70. package/dist/tools/opponents.js +2 -0
  71. package/dist/tools/past-games.js +74 -8
  72. package/dist/tools/picks.js +49 -10
  73. package/dist/tools/profile-hook.js +62 -3
  74. package/dist/tools/profile-opponents.js +2 -0
  75. package/dist/tools/push.js +2 -2
  76. package/dist/tools/relations.js +2 -0
  77. package/dist/tools/scout.js +16 -2
  78. package/dist/tools/state.js +6 -1
  79. package/dist/tools/strategy.js +3 -3
  80. package/dist/tools/stress-opponents.js +2 -0
  81. package/dist/tools/surrender-pending.js +10 -1
  82. package/dist/tools/surrender.js +18 -3
  83. package/dist/tools/turn.js +313 -18
  84. package/dist/tools/where.js +3 -1
  85. package/dist/version.js +1 -1
  86. package/manifest.json +23 -2
  87. package/mint.yaml +23 -0
  88. package/package.json +1 -1
  89. package/server.json +20 -2
  90. package/skills/warapp-mcp/SKILL.md +42 -8
@@ -0,0 +1,70 @@
1
+ // #439: a high-value single-territory bonus two moves away through a visible neutral is a two-turn
2
+ // completion. The planner plans one turn ahead, so such a bonus (a city, a capital) was never a bonus
3
+ // plan — its one member is not next to mine, so no capture reaches it — and the neutral in between
4
+ // lost to captures that complete nothing: live, two cities came a turn late (about 17 armies of income).
5
+ import { bonusTerritories } from '../bonuses.js';
6
+ import { neighborsOf } from '../graph.js';
7
+ import { teammateAt } from './state.js';
8
+ /** #439: the least value of a single-territory bonus worth staging toward two moves ahead. */
9
+ export const TWO_MOVE_MIN_VALUE = 5;
10
+ /**
11
+ * The single-territory bonuses of at least {@link TWO_MOVE_MIN_VALUE} two moves from mine through a
12
+ * visible neutral target, each with its cheapest neutral in between, best income per army first (then
13
+ * bonus id). The bonus territory is a visible neutral, or a fogged one the picking board showed as a
14
+ * neutral (`rememberedNeutrals`, costed at that size); never a player's, a teammate's, a truce's or one
15
+ * whose bonus was dropped. Kept only when the two captures repay their armies within the payback turns.
16
+ */
17
+ export function twoMoveStages(pc, tgt) {
18
+ const { g, territories: state, mineSet, costAt, completedOver, paybackTurns, opts } = pc;
19
+ const out = [];
20
+ for (const b of [...g.map.bonuses].sort((x, y) => x.id - y.id)) {
21
+ if (b.value < TWO_MOVE_MIN_VALUE || tgt.bonusDropped.has(b.id))
22
+ continue;
23
+ const ts = bonusTerritories(g, b.id);
24
+ if (ts.length !== 1)
25
+ continue;
26
+ const member = ts[0];
27
+ if (mineSet.has(member) || tgt.fromMine.get(member) !== 2 || pc.truce.noTarget(member) || teammateAt(pc, member))
28
+ continue;
29
+ const st = state.get(member);
30
+ let memberCost = null;
31
+ if (st?.owner.kind === 'neutral' && st.armies !== null)
32
+ memberCost = costAt(member);
33
+ else if (!st || st.owner.kind === 'unknown' || st.armies === null) {
34
+ const was = opts.rememberedNeutrals?.get(member);
35
+ if (was !== undefined && st?.owner.kind !== 'player')
36
+ memberCost = costAt(member, was);
37
+ }
38
+ if (memberCost === null)
39
+ continue;
40
+ let best;
41
+ for (const via of [...neighborsOf(g, member)].sort((x, y) => x - y)) {
42
+ const tg = tgt.targets.get(via);
43
+ if (!tg || tg.enemy || state.get(via)?.owner.kind !== 'neutral')
44
+ continue;
45
+ const cost = tg.cost + memberCost;
46
+ const net = completedOver((x) => mineSet.has(x) || x === via || x === member, [via, member]).reduce((n, id) => n + g.bonusById.get(id).value, 0);
47
+ if (net <= 0 || cost > paybackTurns * net)
48
+ continue;
49
+ if (!best || cost < best.cost)
50
+ best = { bonusId: b.id, member, via, cost, net };
51
+ }
52
+ if (best)
53
+ out.push(best);
54
+ }
55
+ return out.sort((a, b) => b.net / b.cost - a.net / a.cost || a.bonusId - b.bonusId);
56
+ }
57
+ /**
58
+ * #439: take `s.via` toward its bonus (pass 3's capture: R3, rule 4d and the usual sizing), unless this
59
+ * turn's captures already took it or stand next to the bonus territory, or it lowers income. Says so.
60
+ */
61
+ export function stageTwoMove(pc, ps, s, gainWith, tryExpand) {
62
+ const { g, label, bonusName } = pc;
63
+ if (ps.captured.has(s.via) || neighborsOf(g, s.member).some((n) => ps.captured.has(n)) || gainWith([s.via]) < 0)
64
+ return;
65
+ const value = g.bonusById.get(s.bonusId).value;
66
+ const worth = s.net === value ? `+${value}` : `+${value}, net +${s.net}`;
67
+ if (!tryExpand(s.via, `stages bonus ${bonusName(s.bonusId)} (${worth}) two moves away (#439)`))
68
+ return;
69
+ ps.rationale.push(`Stage toward ${bonusName(s.bonusId)} (${worth}), two moves away: ${label(s.via)} now, ${label(s.member)} next turn — ${s.cost} armies over two turns (#439).`);
70
+ }
@@ -22,10 +22,132 @@
22
22
  // judged by rule 4d as before. Never a truce's covered territory, one my attacks failed on (#240) or
23
23
  // one lowering income; the capture spends what stands above its source's hold, as any.
24
24
  import { neighborsOf } from '../graph.js';
25
+ import { visibleState } from './shared.js';
25
26
  /** The end of every empty enemy capture's reason (#281, the owner's extension): tests and sweeps match on it. */
26
27
  export const CHEAP_EXPANSION = 'cheap expansion (#281)';
27
- /** A vacated territory costing at most this many armies to take is cheap enough to deny (#281). */
28
- export const VACATED_MAX_COST = 2;
28
+ /**
29
+ * #417 / #428: for each territory fogged on `board`, its sighting on the newest earlier board that showed
30
+ * its owner (`boards` in any order; boards that fog it too are skipped): the owner, and the armies that
31
+ * board showed (`null` when only its owner was shown). The one source of both {@link foggedLastSeen}
32
+ * (#417, who held it) and the planner's last-seen price (#428, `PlanOptions.lastSeen`), so they never
33
+ * read different boards. A GameFeed history board (`source: 'history'`) gives its owner only: no army count.
34
+ */
35
+ export function fogSightings(board, boards) {
36
+ const fogged = new Set(board.territories.filter((t) => t.owner.kind === 'unknown').map((t) => t.territoryId));
37
+ const out = new Map();
38
+ for (const b of [...boards].sort((x, y) => y.turn - x.turn))
39
+ for (const t of b.board.territories) {
40
+ if (!fogged.has(t.territoryId) || out.has(t.territoryId) || t.owner.kind === 'unknown')
41
+ continue;
42
+ // A GameFeed history board (unverified while the game is played) gives the owner, never a count.
43
+ const armies = b.source === 'history' ? null : (visibleState(t)?.armies ?? null);
44
+ out.set(t.territoryId, { owner: t.owner.kind === 'player' ? t.owner.playerId : null, armies });
45
+ }
46
+ return out;
47
+ }
48
+ /**
49
+ * #417: for each territory fogged on `board`, the player who held it on the newest earlier board that
50
+ * showed it (`boards` in any order; boards that fog it too are skipped). None when that sighting was
51
+ * neutral, or no earlier board showed it. A static seat's land stays costed as vacated however many
52
+ * turns it has been out of view, not only on the turn after vision was lost. The owners of {@link fogSightings}.
53
+ */
54
+ export function foggedLastSeen(board, boards) {
55
+ return ownersOf(fogSightings(board, boards));
56
+ }
57
+ /** #417: the players of a {@link fogSightings} map (its neutral sightings left out). */
58
+ export function ownersOf(sightings) {
59
+ const out = new Map();
60
+ for (const [t, s] of sightings)
61
+ if (s.owner !== null)
62
+ out.set(t, s.owner);
63
+ return out;
64
+ }
65
+ /** #428: the counts of a {@link fogSightings} map (a sighting that showed only the owner left out). */
66
+ export function countsOf(sightings) {
67
+ const out = new Map();
68
+ for (const [t, s] of sightings)
69
+ if (s.armies !== null)
70
+ out.set(t, { armies: s.armies, owner: s.owner });
71
+ return out;
72
+ }
73
+ /**
74
+ * A vacated territory costing at most this many armies to take is cheap enough to deny (#281). #417:
75
+ * raised from 2 to 3, what {@link VACATED_FOG_ARMIES} defenders cost at the default settings.
76
+ */
77
+ export const VACATED_MAX_COST = 3;
78
+ /**
79
+ * #417: the defenders a static seat's fogged territory is costed at. A seat deploys on its borders, so
80
+ * its interior stands on 0-2: its border stack in view says nothing about the land behind it.
81
+ */
82
+ export const VACATED_FOG_ARMIES = 2;
83
+ /**
84
+ * #417 (the breach force): `id` is land a static seat left (`vacated`) whose armies the fog hides now —
85
+ * owner hidden, or shown neutral (a seat's own, planned as a neutral) without its armies. It is priced at
86
+ * {@link VACATED_FOG_ARMIES} defenders. Never one the fog shows another player holding: that player got there first.
87
+ */
88
+ export function fogVacated(vacated, st, id) {
89
+ if (!vacated?.has(id))
90
+ return false;
91
+ if (!st || st.owner.kind === 'unknown')
92
+ return true;
93
+ return st.owner.kind === 'neutral' && st.armies === null;
94
+ }
95
+ /**
96
+ * #417 (the breach force): the land a static seat left beside `t` that is still untaken — not captured
97
+ * this turn, still neutral or hidden (never a live player's in view), in no negative bonus
98
+ * — and cheap at the 2-defender price: fogged ({@link fogVacated}), or costing at most {@link VACATED_MAX_COST}. By id.
99
+ */
100
+ export function breachOf(pc, captured, t) {
101
+ if (!pc.vacated.size)
102
+ return [];
103
+ return neighborsOf(pc.g, t)
104
+ .filter((x) => {
105
+ if (!pc.vacated.has(x) || pc.mineSet.has(x) || captured.has(x))
106
+ return false;
107
+ // Never a negative bonus's member (pass 3 never takes one): nothing to race for.
108
+ if ((pc.bonusesWith.get(x) ?? []).some((id) => (pc.g.bonusById.get(id)?.value ?? 0) < 0))
109
+ return false;
110
+ const st = pc.territories.get(x);
111
+ if (fogVacated(pc.vacated, st, x))
112
+ return true;
113
+ if (st?.owner.kind !== 'neutral')
114
+ return false;
115
+ const c = pc.costAt(x);
116
+ return c !== null && c <= VACATED_MAX_COST;
117
+ })
118
+ .sort((a, b) => a - b);
119
+ }
120
+ /**
121
+ * #417, the 1v1 race (owner decision of 2026-11-20): the land a static seat left that this turn's greedy
122
+ * step races for ahead of rule 0p.1's "expansion last" — a capture target next to mine, still untaken
123
+ * (neutral, or hidden: {@link fogVacated}), costing at most {@link VACATED_MAX_COST} (the 2-defender price
124
+ * included), never a negative bonus's member. Cheapest first, then by id. Pure.
125
+ */
126
+ export function raceTargets(pc, targets, captured) {
127
+ const out = [];
128
+ for (const t of [...pc.vacated.keys()].sort((a, b) => a - b)) {
129
+ const tg = targets.get(t);
130
+ if (!tg || tg.enemy || pc.mineSet.has(t) || captured.has(t) || tg.cost > VACATED_MAX_COST)
131
+ continue;
132
+ const st = pc.territories.get(t);
133
+ if (st?.owner.kind !== 'neutral' && !fogVacated(pc.vacated, st, t))
134
+ continue;
135
+ if ((pc.bonusesWith.get(t) ?? []).some((id) => (pc.g.bonusById.get(id)?.value ?? 0) < 0))
136
+ continue;
137
+ out.push({ t, cost: tg.cost });
138
+ }
139
+ return out.sort((a, b) => a.cost - b.cost || a.t - b.t);
140
+ }
141
+ /** #417: the 1v1 race's rationale line, said once when the greedy step has races. */
142
+ export function raceLine(pc, races) {
143
+ const left = [...new Set(races.map((r) => pc.vacated.get(r.t)))].sort((a, b) => a - b).map((p) => `player ${p}`).join(' and ');
144
+ return `1v1 race for vacated land (#417): ${races.map((r) => `${pc.label(r.t)} (${r.cost})`).join(', ')}, land ${left} left (out, no AI), ${races.length === 1 ? 'goes' : 'go'} ahead of the "expansion last" rule while it is up for taking — the opponent takes it otherwise; holds of my held bonuses and my commander still come first.`;
145
+ }
146
+ /** #417: the rationale line for a stack the breach force keeps beside land a static seat left. */
147
+ export function breachLine(pc, t, n, land) {
148
+ const left = [...new Set(land.map((x) => pc.vacated.get(x)))].sort((a, b) => a - b).map((p) => `player ${p}`).join(' and ');
149
+ return `Keep the ${n} idle armies on ${pc.label(t)}: the breach force beside ${land.map(pc.label).join(', ')}, land ${left} left (out, no AI), until it is taken (#417).`;
150
+ }
29
151
  /** The vacated territories that are denials (#281), by territory: {@link denialOf} over them, computed once. */
30
152
  export function denialsOf(pc) {
31
153
  const out = new Map();