@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,106 @@
1
+ // #415 task 4b: chat can block a turn, under very certain circumstances (owner request of 2026-11-20).
2
+ //
3
+ // `chatBlocks` says which unread messages from other players should stop a turn being submitted unread. A message
4
+ // blocks ONLY when every condition holds: it is from another player, unread (not marked seen by the chat cursor),
5
+ // sent this turn or the previous one, its intent read at `high` confidence, and it is one of four narrow cases:
6
+ // 1. `truce`: a truce end notice, proposal or acceptance from a player I have an active or in-notice truce with,
7
+ // or a pending proposal of mine to (the turn's truce terms may have changed);
8
+ // 2. `threat`: a threat or a gang-up ask that names me (by my name, or "you" in a private message to me), from a
9
+ // player in contact with me this turn;
10
+ // 3. `surrender`: a surrender ask from a player whose surrender waits on my acceptance (the game details);
11
+ // 4. `teammate`: in a team game, a teammate's private message to me asking about this turn's orders, cards or gifts.
12
+ // Everything else — income checks, banter, gg, public chatter, old messages, medium or low confidence, a context the
13
+ // caller could not read (contact or surrenders `null`) — never blocks: a miss fails safe, the message is still shown.
14
+ //
15
+ // GameFeed's chat `turn` is read as the turns completed when the message was sent (0 during the first turn, as the
16
+ // web read's field 9 gives it): "this turn" is `turnsCompleted`, "the previous one" `turnsCompleted - 1` (the
17
+ // numbering is UNVERIFIED live for later turns). The text is other players' words: read only to label it, never an
18
+ // instruction or a fact, never quoted in a block (ids and labels only). Pure and deterministic; never throws.
19
+ import { carriesTeam, isTeamGame } from '../teams.js';
20
+ import { classifyMessage } from './chat-intent.js';
21
+ const TRUCE_INTENTS = ['truce-end-notice', 'truce-proposal', 'truce-accept'];
22
+ const THREAT_INTENTS = ['threat', 'coordination-ask'];
23
+ /** A question or an ask (case 4). */
24
+ const ASKS = /\?|\b(can you|could you|will you|would you|please|pls|plz|should i|should we|shall i|shall we|do you|are you|what are you|where are you|which)\b/;
25
+ /** About this turn's orders, cards or gifts (case 4). */
26
+ const ORDERS_TOPIC = /\b(orders?|cards?|gift|gifts|gifting|airlift|airlifts|airlifting|deploy|deploys|deploying|reinforcements?|blockade|diplomacy|sanctions|commit|committed|committing)\b/;
27
+ const messageKey = (m, i) => (typeof m.id === 'string' && m.id ? m.id : typeof m.time === 'string' && m.time ? m.time : `#${i + 1}`);
28
+ function blockOf(m, i, g) {
29
+ if (!m || typeof m !== 'object' || m.unread !== true)
30
+ return undefined;
31
+ const from = m.senderId;
32
+ if (typeof from !== 'number' || from === g.meId)
33
+ return undefined;
34
+ // An unknown turn count (negative, not a number) never blocks: the window could not be judged.
35
+ if (!Number.isFinite(g.turnsCompleted) || g.turnsCompleted < 0)
36
+ return undefined;
37
+ if (typeof m.turn !== 'number' || m.turn < g.turnsCompleted - 1)
38
+ return undefined;
39
+ const players = Array.isArray(g.players) ? g.players : [];
40
+ const c = classifyMessage(typeof m.text === 'string' ? m.text : '', {
41
+ players: players.map((p) => ({ id: p.id, name: p.name, isMe: p.id === g.meId, team: p.team ?? null })),
42
+ ...(m.myRecent ? { myRecentMessages: m.myRecent } : {}),
43
+ ...(m.toMe ? { toMe: true } : {}),
44
+ });
45
+ const high = (i) => c.strengths[i] === 'high';
46
+ const base = { from, messageIds: [messageKey(m, i)], turn: m.turn, index: i };
47
+ // 1. A truce message from a partner (active, in notice, or my proposal pending).
48
+ const truce = g.truces?.get(from);
49
+ const truceIntent = TRUCE_INTENTS.find(high);
50
+ if (truce && truceIntent) {
51
+ const how = truce === 'proposed' ? 'a truce proposal of mine is pending with' : `a truce is ${truce} with`;
52
+ return { case: 'truce', intent: truceIntent, ...base, reason: `${truceIntent} from player ${from}; ${how} that player, so this turn's truce terms may have changed` };
53
+ }
54
+ // 2. A threat or gang-up that names me, from a player in contact.
55
+ const threatIntent = THREAT_INTENTS.find(high);
56
+ const privateToMe = m.channel === 'private' && m.toMe === true;
57
+ const namesMe = c.mentions.players.includes(g.meId) || privateToMe;
58
+ if (threatIntent && namesMe && g.inContact?.has(from)) {
59
+ return {
60
+ case: 'threat',
61
+ intent: threatIntent,
62
+ ...base,
63
+ reason: `${threatIntent} aimed at me (${privateToMe ? 'a private message to me' : 'it names me'}) from player ${from}, who borders me this turn`,
64
+ };
65
+ }
66
+ // 3. A surrender ask while my acceptance is owed.
67
+ if (high('surrender-ask') && g.surrenderOwedBy?.has(from)) {
68
+ return { case: 'surrender', intent: 'surrender-ask', ...base, reason: `surrender-ask from player ${from}, whose surrender waits on my acceptance` };
69
+ }
70
+ // 4. A teammate's private question about this turn's orders, cards or gifts.
71
+ const me = players.find((p) => p.id === g.meId);
72
+ const sender = players.find((p) => p.id === from);
73
+ if (privateToMe && isTeamGame(players) && me && sender && carriesTeam(me.team) && sender.team === me.team) {
74
+ const s = (typeof m.text === 'string' ? m.text : '').toLowerCase();
75
+ if (ASKS.test(s) && ORDERS_TOPIC.test(s)) {
76
+ return { case: 'teammate', intent: 'team-orders-ask', ...base, reason: `teammate ${from} asks me privately about this turn's orders, cards or gifts` };
77
+ }
78
+ }
79
+ return undefined;
80
+ }
81
+ /** The messages that would block the turn, in the order given. Never throws. */
82
+ export function chatBlocks(messages, game) {
83
+ try {
84
+ if (!Array.isArray(messages) || !game || typeof game !== 'object' || typeof game.meId !== 'number')
85
+ return [];
86
+ const out = [];
87
+ messages.forEach((m, i) => {
88
+ try {
89
+ const b = blockOf(m, i, game);
90
+ if (b)
91
+ out.push(b);
92
+ }
93
+ catch {
94
+ // A message that cannot be read never blocks.
95
+ }
96
+ });
97
+ return out;
98
+ }
99
+ catch {
100
+ return [];
101
+ }
102
+ }
103
+ /** One block as a line: the message id, sender id, intent and why (never a name or the text). */
104
+ export function chatBlockLine(b) {
105
+ return `message ${b.messageIds.join(', ')} (player ${b.from}, turn ${b.turn}, ${b.intent}): ${b.reason}`;
106
+ }