@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,22 @@
1
+ // #415 task 4: the chat automation gate. Classification, advice and drafts are always on (read-only); an
2
+ // automated reply — a message an agent sends that the owner did not tell it to send — is behind
3
+ // `WARAPP_CHAT_AUTOMATION`, `off` unless it says `on` (owner decision of 2026-11-20; D2 is now "off unless the
4
+ // gate is on"). With the gate on, every send still goes through warapp_send_chat's confirm gate (D1).
5
+ import { readEnvVar } from '@chrischall/mcp-utils';
6
+ export const CHAT_AUTOMATION_ENV = 'WARAPP_CHAT_AUTOMATION';
7
+ /** The gate: `on` only when the variable says `on` (any case, trimmed); unset, `off` and anything else read `off`. */
8
+ export function chatAutomationMode(env = process.env) {
9
+ const v = readEnvVar(CHAT_AUTOMATION_ENV, { env });
10
+ return v !== undefined && v.trim().toLowerCase() === 'on' ? 'on' : 'off';
11
+ }
12
+ /** warapp_send_chat's refusal of an automated send with the gate off. */
13
+ export const AUTOMATED_CHAT_OFF = 'automated chat is off (WARAPP_CHAT_AUTOMATION); the owner sends replies';
14
+ // #415 task 4b: chat can block a turn — a second, independent gate. `WARAPP_CHAT_BLOCKS_TURN`, `off` unless it says
15
+ // `on` (owner request of 2026-11-20: "chat rarely blocks a turn, but can under very certain circumstances. Gate that
16
+ // as well; off by default."). Off: warapp_submit_turn never refuses for chat and its preview says what would block.
17
+ export const CHAT_BLOCKS_TURN_ENV = 'WARAPP_CHAT_BLOCKS_TURN';
18
+ /** The gate: `on` only when the variable says `on` (any case, trimmed); unset, `off` and anything else read `off`. */
19
+ export function chatBlocksTurnMode(env = process.env) {
20
+ const v = readEnvVar(CHAT_BLOCKS_TURN_ENV, { env });
21
+ return v !== undefined && v.trim().toLowerCase() === 'on' ? 'on' : 'off';
22
+ }
package/dist/client.js CHANGED
@@ -214,6 +214,8 @@ export class WarappClient {
214
214
  #env;
215
215
  #cache;
216
216
  #dataDir;
217
+ /** #437: called with every game read (the decision log's seat capture); never fails a read. */
218
+ #gameObservers = [];
217
219
  #api;
218
220
  /** The same client with no retry, for a request that must go out at most once (`noRetry`). */
219
221
  #apiOnce;
@@ -343,8 +345,20 @@ export class WarappClient {
343
345
  // #302: what came instead of a history that does not read, by key name only.
344
346
  if (opts.history)
345
347
  game.feedKeys = safeKeys(Object.keys(body));
348
+ for (const observe of this.#gameObservers) {
349
+ try {
350
+ await observe(game);
351
+ }
352
+ catch {
353
+ // An observer never fails the read.
354
+ }
355
+ }
346
356
  return game;
347
357
  }
358
+ /** #437: call `fn` with every game this client reads (awaited, its failures swallowed). */
359
+ observeGames(fn) {
360
+ this.#gameObservers.push(fn);
361
+ }
348
362
  /** Keep the territories read for a map's distribution modes (#328) on the cached map and in the store. */
349
363
  async keepModeTerritories(mapId, byMode) {
350
364
  await this.#cache.setModeTerritories(mapId, byMode, this.#dir());