@chrischall/warapp-mcp 0.19.0 → 0.21.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.
@@ -32,6 +32,9 @@ const READ_BACK_TARGETED = new Set(['Bomb', 'Blockade', 'EmergencyBlockade']);
32
32
  import { compareScores, planAirlift, STAGING_DISCOUNT } from '../analysis/airlift-plan.js';
33
33
  import { planBomb } from '../analysis/bomb-plan.js';
34
34
  import { planBlockade, planWall } from '../analysis/blockade-plan.js';
35
+ import { alternativePlans, STRATEGY_NOTE, stressSummary, turnOptions } from '../analysis/options.js';
36
+ import { FACT_PARTS, FACTS_AVAILABLE, MORE_ON_REQUEST, OWN_PLAN_STEPS, pickFacts, situation } from '../analysis/situation.js';
37
+ import { stressPlan } from '../analysis/stress.js';
35
38
  import { breaksInOrders } from '../mod-alliances.js';
36
39
  import { allyAttackLine, attacksOnAllies, MOD_ALLIANCES_NOTE, modAllianceWarnings, readModAlliances } from './mod-alliances.js';
37
40
  import { adviseCards, cardGame, cardPieceOption, giftInOrders, intelOrders, handOwners, lastTurnPlays, opponentCanHold, opponentReinforcement, reinforcementPlaysShown, seenReinforcementPlays, TEAM_HAND } from './card-advice.js';
@@ -1663,6 +1666,8 @@ export async function livePlanSetup(ctx, a) {
1663
1666
  effect, sanction, incomeCap, capUnknown: incomeOnBoard.capUnknown === true, estimates, trip, teams, commerce, statedShifts: shifts,
1664
1667
  // #427: the last turn's Reinforcement plays, for warapp_plan_turn to keep (only when plays show).
1665
1668
  seenPlays: playsShown ? lastPlays : undefined,
1669
+ // #606: the earlier boards (and my orders on them) for the strategy view's summary of past turns.
1670
+ pastBoards: history.boards,
1666
1671
  };
1667
1672
  }
1668
1673
  /** The Airlift card's type id. */
@@ -2218,9 +2223,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
2218
2223
  'an opponent is bounded above by all it can have received (its start, or an even share of the map; each turn\'s most it could earn; ' +
2219
2224
  'a fixed Reinforcement card by the card clock) — a scenario\'s starts, a Gift card or a progressive Reinforcement card leave it unbounded, and then `winning` is never read; ' +
2220
2225
  'once winning or losing, payback tests count the turns the game has left instead of 10). With no `goal` the profile picks and tunes it (`goalSource` ' +
2221
- '"profile"): siege when it fits (in contact, not ahead, one target — in an FFA the leader, earning 1.5× any other ' +
2222
- 'opponent beside me — with a sure break costing at most 2 turns of its bonus and at most my income; handed back ' +
2223
- 'once its assault trigger fires), else defend when behind outside a 1v1, else balanced — in an FFA with two or more opponents, no ' +
2226
+ '"profile"): defend when behind outside a 1v1, else balanced — in an FFA with two or more opponents, no ' +
2224
2227
  'second front; in a 1v1, one strike stack facing the opponent; ahead in a 1v1, fog pressure ' +
2225
2228
  `up to ${AHEAD_PRESSURE_FACTOR}× a typical neutral capture. Goals: "balanced" (default) — income per army ` +
2226
2229
  'across holds, bonuses and breaking enemy bonuses, at least 30% on expansion; "expand" — neutrals only; ' +
@@ -2347,7 +2350,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
2347
2350
  goal: z
2348
2351
  .enum(GOALS)
2349
2352
  .optional()
2350
- .describe('Omit to let the game profile pick (siege when it fits, else defend when behind on income outside a 1v1, else balanced, tuned to the format). ' +
2353
+ .describe('Omit to let the game profile pick (defend when behind on income outside a 1v1, else balanced, tuned to the format). ' +
2351
2354
  'balanced (default): best income per army across holds, bonuses and breaking enemy bonuses; expand: take ' +
2352
2355
  'neutrals only; complete-bonus: also attack players to finish bonuses; defend: hold threatened borders first; ' +
2353
2356
  "siege: against one opponent (siege_target), fund its cheapest bonus breaks first and build one strike stack " +
@@ -2426,10 +2429,30 @@ export function registerTurnTools(server, ctx, opts = {}) {
2426
2429
  .optional()
2427
2430
  .describe('Airlift cards to keep in reserve: `airliftPlan` plays only those held beyond this many (default 0). ' +
2428
2431
  'Changes nothing when you hold no Airlift.'),
2432
+ strategy: z
2433
+ .boolean()
2434
+ .optional()
2435
+ .describe('true adds `strategy` (#606), a menu for choosing a turn yourself: `options.captures` — each territory in view beside ' +
2436
+ 'yours that is not yours, ranked by income gained per army: its defenders, the attackers that take it (and, a ' +
2437
+ "player's, after its owner's whole deploy), the spare armies beside it, the bonuses it completes or advances and the new " +
2438
+ 'borders facing a player it opens; `options.holds` — each border facing a player: the armies to add to hold against ' +
2439
+ 'the stacks beside it alone and against them plus one whole deploy, and the held bonuses it protects; `alternatives` — ' +
2440
+ "this plan and the planner under the goals expand and defend, each with its orders, what it expects and its stress test " +
2441
+ "against the opponents' replies (safe, harmful replies, the worst one); `available` — the raw facts you can ask for " +
2442
+ 'with `facts`; and `steps`. Choose, combine or build your own, then check with warapp_check_plan; ' +
2443
+ 'warapp_submit_turn keeps an override reason in the decision log. Default false.'),
2444
+ facts: z
2445
+ .array(z.enum(FACT_PARTS))
2446
+ .min(1)
2447
+ .optional()
2448
+ .describe('The raw game state behind the plan, only the parts you name (#606), as `facts`: `me` (' + FACTS_AVAILABLE.me + '), ' +
2449
+ '`territories` (' + FACTS_AVAILABLE.territories + '), `bonuses` (' + FACTS_AVAILABLE.bonuses + '), `opponents` (' +
2450
+ FACTS_AVAILABLE.opponents + '), `changes` (' + FACTS_AVAILABLE.changes + '), `past` (' + FACTS_AVAILABLE.past + '). ' +
2451
+ 'Ask for what your decision needs; whole past boards are in warapp_turn_history. Default none.'),
2429
2452
  view: viewArg(VIEWS, 'compact (default) gives the plan and orders (the profile as format, phase and standing); "full" adds each ' +
2430
2453
  'move\'s reason, the whole profile and the settings the plan assumed.'),
2431
2454
  }),
2432
- }, async ({ game_id, player, goal, siege_target, jabs, focus, reserve, enemy_deploy, known_income, fogged_attackers, avoid_territories, avoid_players, min_win_chance, first_mover, keep_cards, view }) => {
2455
+ }, async ({ game_id, player, goal, siege_target, jabs, focus, reserve, enemy_deploy, known_income, fogged_attackers, avoid_territories, avoid_players, min_win_chance, first_mover, keep_cards, strategy, facts, view }) => {
2433
2456
  // The chat comes in the same GameFeed read: the fallback for the unread counts (part A1).
2434
2457
  const feed = await ctx.client.getGame(game_id, { settings: true, chat: true });
2435
2458
  requireTurnPhase(feed);
@@ -2807,6 +2830,77 @@ export function registerTurnTools(server, ctx, opts = {}) {
2807
2830
  guessSkip = { reason: 'commander', message };
2808
2831
  }
2809
2832
  }
2833
+ // #606: the raw game state behind the plan, only the parts asked for (report only).
2834
+ const factsView = facts
2835
+ ? pickFacts(situation({
2836
+ graph,
2837
+ board,
2838
+ ...(setup.input.previousBoard ? { previousBoard: setup.input.previousBoard } : {}),
2839
+ me: me.id,
2840
+ ...(setup.teams ? { friends: new Set([...setup.teams].filter(([id, t]) => id !== me.id && t === setup.teams.get(me.id)).map(([id]) => id)) } : {}),
2841
+ rates: { offensiveKillRate: settings.offensiveKillRate, defensiveKillRate: settings.defensiveKillRate },
2842
+ guard: settings.oneArmyStandsGuard !== false,
2843
+ myIncome: income,
2844
+ ...(setup.input.incomeHistory ? { incomeHistory: setup.input.incomeHistory } : {}),
2845
+ pastBoards: setup.pastBoards,
2846
+ opponents: estimates.map((e) => {
2847
+ const t = tracks?.find((x) => x.playerId === e.playerId);
2848
+ return {
2849
+ playerId: e.playerId,
2850
+ estimate: e.estimate,
2851
+ source: e.source,
2852
+ visibleIncome: e.base + e.bonusIncome,
2853
+ tracked: t?.income ?? null,
2854
+ range: e.thinEvidence ? { low: e.thinEvidence.lower, high: e.thinEvidence.upper } : null,
2855
+ coverage: t?.coverage?.share ?? null,
2856
+ ...(t ? { history: t.turns.map((x) => ({ turn: x.to, observed: x.observed })) } : {}),
2857
+ };
2858
+ }),
2859
+ }), facts)
2860
+ : undefined;
2861
+ // #606: ranked options and alternative plans, each stress-tested (opt-in; never changes the plan above).
2862
+ const strategyView = strategy
2863
+ ? (() => {
2864
+ const deployOf = (p) => estimates.find((e) => e.playerId === p)?.estimate ?? 0;
2865
+ const stressOpp = estimates.map((e) => ({ id: e.playerId, deploy: e.estimate }));
2866
+ const stress = (p) => {
2867
+ if (!stressOpp.length)
2868
+ return undefined;
2869
+ try {
2870
+ return stressSummary(stressPlan({
2871
+ graph,
2872
+ board,
2873
+ me: me.id,
2874
+ deploys: p.deploys,
2875
+ moves: p.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies })),
2876
+ opponents: stressOpp,
2877
+ settings,
2878
+ ...(setup.teams ? { teams: setup.teams } : {}),
2879
+ lookAhead: false,
2880
+ maxReplies: 1,
2881
+ }));
2882
+ }
2883
+ catch {
2884
+ return undefined;
2885
+ }
2886
+ };
2887
+ return {
2888
+ options: turnOptions({
2889
+ graph,
2890
+ board,
2891
+ me: me.id,
2892
+ deployOf,
2893
+ rates: { offensiveKillRate: settings.offensiveKillRate, defensiveKillRate: settings.defensiveKillRate },
2894
+ guard: settings.oneArmyStandsGuard !== false,
2895
+ ...(setup.teams ? { friends: new Set([...setup.teams].filter(([id, t]) => id !== me.id && t === setup.teams.get(me.id)).map(([id]) => id)) } : {}),
2896
+ }),
2897
+ alternatives: alternativePlans(setup.input, plan, stress),
2898
+ available: FACTS_AVAILABLE,
2899
+ steps: OWN_PLAN_STEPS,
2900
+ note: STRATEGY_NOTE,
2901
+ };
2902
+ })()
2903
+ : undefined;
2810
2904
  // #275 (a): the smallest single deploy that takes each border of mine after the plan's orders.
2811
2905
  const headroom = safeHeadroom({
2812
2906
  graph,
@@ -3173,6 +3267,11 @@ export function registerTurnTools(server, ctx, opts = {}) {
3173
3267
  : `${plan.incomeTrend.turns.map((t) => t.income).join(' → ')} over turns ${plan.incomeTrend.turns[0].turn}–${plan.incomeTrend.turns[plan.incomeTrend.turns.length - 1].turn}: ${plan.incomeTrend.slope >= 0 ? '+' : ''}${plan.incomeTrend.slope}/turn${plan.incomeTrend.flat ? ', flat' : ''}`,
3174
3268
  }
3175
3269
  : {}),
3270
+ // #606: the mechanics for the calling model's own choice (opt-in).
3271
+ ...(strategyView ? { strategy: strategyView } : {}),
3272
+ ...(factsView ? { facts: factsView } : {}),
3273
+ // #606: every plan says what more can be asked for (the menu itself names the facts).
3274
+ ...(strategyView ? {} : { more: MORE_ON_REQUEST }),
3176
3275
  // #275 (a): each border's headroom, the weakest first (compact: the first few).
3177
3276
  headroom: headroomView(headroom, map, myIncome, rung === 'full', !teamsKnown, (p) => estimates.find((e) => e.playerId === p)?.estimate),
3178
3277
  ...(rung !== 'full' && headroom.length > HEADROOM_COMPACT ? { headroomMore: headroom.length - HEADROOM_COMPACT } : {}),
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // Single source of truth for the server version. release-please bumps the
2
2
  // literal on the marked line (registered in release-please-config.json
3
3
  // extra-files); every other module imports VERSION from here.
4
- export const VERSION = '0.19.0'; // x-release-please-version
4
+ export const VERSION = '0.21.0'; // x-release-please-version
package/manifest.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "manifest_version": "0.3",
4
4
  "name": "warapp-mcp",
5
5
  "display_name": "war.app (Warzone)",
6
- "version": "0.19.0",
6
+ "version": "0.21.0",
7
7
  "description": "war.app (Warzone) game advisor for Claude — your games, maps, bonuses, board analysis and routes via the GameFeed API, plus your games list (waiting on you first), opponent scouting with your head-to-head, the live board, territory picks, cards, turn planning and submission, turn notifications, and chat through your signed-in war.app tab (ContextMint Bridge). Joining, leaving or surrendering a game, closing out a finished 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 into a hosted server and linking a session (local only) are confirm-gated.",
8
8
  "author": {
9
9
  "name": "Chris Hall",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrischall/warapp-mcp",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "mcpName": "io.github.chrischall/warapp-mcp",
5
5
  "description": "war.app (Warzone) game advisor MCP server for Claude — games, maps, bonuses and board analysis via the GameFeed API, plus your games list, opponent scouting, the live board, territory picks, cards, turn planning and submission, turn notifications and chat through your signed-in war.app tab. Developed and maintained by AI (Claude Code).",
6
6
  "author": "Claude Code (AI) <https://www.anthropic.com/claude>",
package/server.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "url": "https://github.com/chrischall/warapp-mcp",
7
7
  "source": "github"
8
8
  },
9
- "version": "0.19.0",
9
+ "version": "0.21.0",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "@chrischall/warapp-mcp",
14
- "version": "0.19.0",
14
+ "version": "0.21.0",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  },
@@ -1,42 +0,0 @@
1
- /** #432: the payback horizon, in turns, of a 1v1 whose gates are short at the start of the turn. */
2
- export const SHORT_GATES_PAYBACK_TURNS = 5;
3
- /**
4
- * The start-of-turn gate budget (#297's arithmetic on my start-of-turn holdings and armies), and the shorter horizon
5
- * when it is short: adapting only (as #201), a 1v1 only, in contact, the gates' summed shortfall over my income, and
6
- * only when that horizon is shorter than the one the plan already counts (a decided game's may be shorter still).
7
- * `undefined` otherwise.
8
- */
9
- export function shortGatesHorizon(pc, threats) {
10
- if (!pc.auto || pc.profile.format !== '1v1' || pc.capturePaybackTurns <= SHORT_GATES_PAYBACK_TURNS)
11
- return undefined;
12
- const ours = (n) => pc.mineSet.has(n);
13
- let deficit = 0;
14
- let player;
15
- for (const x of pc.mine) {
16
- const th = threats.nextTurnAt(x, ours);
17
- if (!th)
18
- continue;
19
- player ??= th.player;
20
- deficit += Math.max(0, threats.holdArmies(th.threat) - pc.armiesOf(x) - pc.unitsAt(x));
21
- }
22
- if (player === undefined || deficit <= pc.income)
23
- return undefined;
24
- return { player, deficit, turns: SHORT_GATES_PAYBACK_TURNS };
25
- }
26
- /** The rationale line for {@link shortGatesHorizon}'s reading. */
27
- export function shortGatesLine(pc, s) {
28
- return `Gate budget short (#432): in this 1v1 the gates facing player ${s.player} need ${s.deficit} more than stands on them against its one floating deploy, more than my income of ${pc.income}, so every capture's payback test counts ${s.turns} turns instead of ${pc.capturePaybackTurns} (holds keep ${pc.paybackTurns}).`;
29
- }
30
- /**
31
- * Apply {@link shortGatesHorizon} to the plan: its rationale line, and the shorter horizon every later phase reads
32
- * from `pc.capturePaybackTurns` (holds keep `pc.paybackTurns`). Run right after the threats phase (nothing before it applies a payback test).
33
- */
34
- export function applyShortGates(pc, ps, threats) {
35
- const sg = shortGatesHorizon(pc, threats);
36
- if (!sg)
37
- return undefined;
38
- ps.rationale.push(shortGatesLine(pc, sg));
39
- pc.capturePaybackTurns = sg.turns;
40
- pc.shortGates = sg;
41
- return sg;
42
- }