@nonz250/ai-rotom 1.4.0 → 2.0.1
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/dist/index.mjs +857 -961
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Field, Generations, Move, Pokemon, calculate, toID } from "@smogon/calc";
|
|
6
6
|
import { randomBytes } from "node:crypto";
|
|
@@ -8,6 +8,74 @@ import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node
|
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import { dirname, join } from "node:path";
|
|
10
10
|
import { parse } from "@pokesol/pokesol-text-parser-ts";
|
|
11
|
+
// ../../shared/src/constants/champions.ts
|
|
12
|
+
/** タイプ一致 (STAB) 補正倍率。てきおうりょく等の特性補正は含まない通常値 */
|
|
13
|
+
const STAB_MULTIPLIER = 1.5;
|
|
14
|
+
// ../../shared/src/schemas/stats.ts
|
|
15
|
+
const statPointValueSchema = z.number({ message: "能力ポイント(SP)は数値で指定してください。" }).int({ message: "能力ポイント(SP)は整数で指定してください。" }).finite().min(0, { message: "能力ポイント(SP)は 0 以上で指定してください。" }).max(32, { message: `能力ポイント(SP)は各ステータス 32 以下です (ポケモンチャンピオンズ仕様)。` });
|
|
16
|
+
/**
|
|
17
|
+
* 能力ポイント(SP) のスキーマ。
|
|
18
|
+
* ポケモンチャンピオンズ仕様: 各ステ 0〜MAX_STAT_POINT_PER_STAT、
|
|
19
|
+
* 合計 0〜MAX_STAT_POINT_TOTAL の範囲。
|
|
20
|
+
* 従来の EV (各 252 / 合計 510) とは別仕様なので AI クライアントが
|
|
21
|
+
* 旧知識で 252 等を渡してきた場合に弾く。
|
|
22
|
+
*/
|
|
23
|
+
const evsSchema = z.object({
|
|
24
|
+
hp: statPointValueSchema.optional(),
|
|
25
|
+
atk: statPointValueSchema.optional(),
|
|
26
|
+
def: statPointValueSchema.optional(),
|
|
27
|
+
spa: statPointValueSchema.optional(),
|
|
28
|
+
spd: statPointValueSchema.optional(),
|
|
29
|
+
spe: statPointValueSchema.optional()
|
|
30
|
+
}).refine((evs) => {
|
|
31
|
+
return Object.values(evs).reduce((sum, v) => sum + (v ?? 0), 0) <= 66;
|
|
32
|
+
}, { message: `能力ポイント(SP)の合計は 66 以下でなければなりません (ポケモンチャンピオンズ仕様)。各ステ 32 上限・合計 66 上限です。従来の努力値(EV)の 252/510 上限ではありません。` });
|
|
33
|
+
const boostValueSchema = z.number().int().finite().min(-6).max(6);
|
|
34
|
+
/**
|
|
35
|
+
* ランク補正 (いかく・ちからをつける等) のスキーマ。
|
|
36
|
+
* 各ステータスは -6〜+6 の整数のみ許可する。
|
|
37
|
+
*/
|
|
38
|
+
const boostsSchema = z.object({
|
|
39
|
+
hp: boostValueSchema.optional(),
|
|
40
|
+
atk: boostValueSchema.optional(),
|
|
41
|
+
def: boostValueSchema.optional(),
|
|
42
|
+
spa: boostValueSchema.optional(),
|
|
43
|
+
spd: boostValueSchema.optional(),
|
|
44
|
+
spe: boostValueSchema.optional()
|
|
45
|
+
});
|
|
46
|
+
/** メモの最大文字数。 */
|
|
47
|
+
const MAX_PARTY_MEMO_LENGTH = 4e3;
|
|
48
|
+
const nameField$1 = z.string().min(1, { message: "名前は 1 文字以上で指定してください。" }).max(100, { message: `名前は 100 文字以下で指定してください。` });
|
|
49
|
+
const optionalNameField = nameField$1.optional();
|
|
50
|
+
/**
|
|
51
|
+
* パーティに所属する 1 匹分の入力スキーマ。
|
|
52
|
+
*/
|
|
53
|
+
const partyMemberSchema = z.object({
|
|
54
|
+
name: nameField$1.describe("ポケモン名 (日本語 or 英語)。"),
|
|
55
|
+
nature: optionalNameField.describe("性格名 (日本語 or 英語)。"),
|
|
56
|
+
ability: optionalNameField.describe("特性名 (日本語 or 英語)。"),
|
|
57
|
+
item: optionalNameField.describe("持ち物名 (日本語 or 英語)。"),
|
|
58
|
+
evs: evsSchema.optional().describe("能力ポイント (SP) の配分。"),
|
|
59
|
+
moves: z.array(nameField$1).max(4, { message: `技は 4 個までです。` }).optional().describe("技リスト (日本語 or 英語、最大 4)。")
|
|
60
|
+
});
|
|
61
|
+
const isoDateTimeField = z.string().refine((value) => !Number.isNaN(Date.parse(value)), { message: "ISO 8601 形式の日時文字列で指定してください。" });
|
|
62
|
+
/**
|
|
63
|
+
* 1 パーティ分の入力スキーマ。
|
|
64
|
+
*/
|
|
65
|
+
const partySchema = z.object({
|
|
66
|
+
name: z.string().min(1, { message: "パーティ名は 1 文字以上で指定してください。" }).max(50, { message: `パーティ名は 50 文字以下で指定してください。` }).describe("パーティの識別子。"),
|
|
67
|
+
memo: z.string().max(MAX_PARTY_MEMO_LENGTH, { message: `メモは ${MAX_PARTY_MEMO_LENGTH} 文字以下で指定してください。` }).optional().describe("自由記述メモ。"),
|
|
68
|
+
members: z.array(partyMemberSchema).min(1, { message: `パーティには 1 匹以上を含めてください。` }).max(6, { message: `パーティには 6 匹までしか含められません。` }).describe("1〜6 匹のメンバー。"),
|
|
69
|
+
createdAt: isoDateTimeField.describe("作成日時 (ISO 8601)。"),
|
|
70
|
+
updatedAt: isoDateTimeField.describe("更新日時 (ISO 8601)。")
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* `~/.ai-rotom/parties.json` 全体のスキーマ。
|
|
74
|
+
*/
|
|
75
|
+
const partiesFileSchema = z.object({
|
|
76
|
+
schemaVersion: z.number().int().positive().describe("パーティファイルの schemaVersion。"),
|
|
77
|
+
parties: z.array(partySchema).describe("登録済みパーティの一覧。")
|
|
78
|
+
});
|
|
11
79
|
// ../../shared/src/utils/name-resolver.ts
|
|
12
80
|
/**
|
|
13
81
|
* データ上の日本語名は全角英数字 (10まんボルト) と半角英数字 (メガリザードンX) が混在しており、
|
|
@@ -38,8 +106,9 @@ var NameResolver = class {
|
|
|
38
106
|
return this.enToJa.has(enName);
|
|
39
107
|
}
|
|
40
108
|
suggestSimilar(jaName, maxResults = 3) {
|
|
41
|
-
const candidates = [];
|
|
42
109
|
const normalizedInput = normalizeJapaneseName(jaName);
|
|
110
|
+
if (normalizedInput.length > 100) return [];
|
|
111
|
+
const candidates = [];
|
|
43
112
|
for (const name of this.jaNames) {
|
|
44
113
|
const distance = levenshteinDistance(normalizedInput, normalizeJapaneseName(name));
|
|
45
114
|
candidates.push({
|
|
@@ -69,9 +138,15 @@ function levenshteinDistance(a, b) {
|
|
|
69
138
|
}
|
|
70
139
|
return matrix[a.length][b.length];
|
|
71
140
|
}
|
|
72
|
-
// ../../shared/src/
|
|
73
|
-
/**
|
|
74
|
-
|
|
141
|
+
// ../../shared/src/errors/user-facing-error.ts
|
|
142
|
+
/**
|
|
143
|
+
* メッセージをそのままツールの呼び出し元に返してよい例外。
|
|
144
|
+
* 呼び出し元が引数を直して呼び直せるように、何が悪いかを日本語で伝える文面だけを載せる。
|
|
145
|
+
* これ以外の例外のメッセージは内部の事情を含みうるため、呼び出し元には返さない。
|
|
146
|
+
*/
|
|
147
|
+
var UserFacingError = class extends Error {
|
|
148
|
+
name = "UserFacingError";
|
|
149
|
+
};
|
|
75
150
|
// ../../shared/src/analysis/type-matchup.ts
|
|
76
151
|
/** 等倍の相性倍率 */
|
|
77
152
|
const NEUTRAL_EFFECTIVENESS = 1;
|
|
@@ -355,80 +430,35 @@ function applyOffensiveTypeOverride(originalMoveType, moveCategory, ability) {
|
|
|
355
430
|
if (overrideType === void 0) return originalMoveType;
|
|
356
431
|
return overrideType;
|
|
357
432
|
}
|
|
358
|
-
// ../../shared/src/schemas/
|
|
359
|
-
const statPointValueSchema = z.number({ message: "能力ポイント(SP)は数値で指定してください。" }).int({ message: "能力ポイント(SP)は整数で指定してください。" }).finite().min(0, { message: "能力ポイント(SP)は 0 以上で指定してください。" }).max(32, { message: `能力ポイント(SP)は各ステータス 32 以下です (ポケモンチャンピオンズ仕様)。` });
|
|
433
|
+
// ../../shared/src/schemas/pokemon-input.ts
|
|
360
434
|
/**
|
|
361
|
-
*
|
|
362
|
-
* ポケモンチャンピオンズ仕様: 各ステ 0〜MAX_STAT_POINT_PER_STAT、
|
|
363
|
-
* 合計 0〜MAX_STAT_POINT_TOTAL の範囲。
|
|
364
|
-
* 従来の EV (各 252 / 合計 510) とは別仕様なので AI クライアントが
|
|
365
|
-
* 旧知識で 252 等を渡してきた場合に弾く。
|
|
435
|
+
* ポケモン名・技名・タイプ名などの名前の入力スキーマ。
|
|
366
436
|
*/
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
atk: statPointValueSchema.optional(),
|
|
370
|
-
def: statPointValueSchema.optional(),
|
|
371
|
-
spa: statPointValueSchema.optional(),
|
|
372
|
-
spd: statPointValueSchema.optional(),
|
|
373
|
-
spe: statPointValueSchema.optional()
|
|
374
|
-
}).refine((evs) => {
|
|
375
|
-
return Object.values(evs).reduce((sum, v) => sum + (v ?? 0), 0) <= 66;
|
|
376
|
-
}, { message: `能力ポイント(SP)の合計は 66 以下でなければなりません (ポケモンチャンピオンズ仕様)。各ステ 32 上限・合計 66 上限です。従来の努力値(EV)の 252/510 上限ではありません。` });
|
|
377
|
-
const boostValueSchema = z.number().int().finite().min(-6).max(6);
|
|
437
|
+
const nameInputSchema = z.string().max(100);
|
|
438
|
+
const moveNameInputSchema = z.string().min(1).max(100);
|
|
378
439
|
/**
|
|
379
|
-
*
|
|
380
|
-
* 各ステータスは -6〜+6 の整数のみ許可する。
|
|
440
|
+
* 1 匹分の技構成の入力スキーマ。
|
|
381
441
|
*/
|
|
382
|
-
const
|
|
383
|
-
hp: boostValueSchema.optional(),
|
|
384
|
-
atk: boostValueSchema.optional(),
|
|
385
|
-
def: boostValueSchema.optional(),
|
|
386
|
-
spa: boostValueSchema.optional(),
|
|
387
|
-
spd: boostValueSchema.optional(),
|
|
388
|
-
spe: boostValueSchema.optional()
|
|
389
|
-
});
|
|
390
|
-
/** メモの最大文字数。 */
|
|
391
|
-
const MAX_PARTY_MEMO_LENGTH = 4e3;
|
|
392
|
-
const nameField$1 = z.string().min(1, { message: "名前は 1 文字以上で指定してください。" }).max(100, { message: `名前は 100 文字以下で指定してください。` });
|
|
393
|
-
const optionalNameField = nameField$1.optional();
|
|
442
|
+
const movesInputSchema = z.array(moveNameInputSchema).max(4, { message: `技は 4 個までです。` });
|
|
394
443
|
/**
|
|
395
|
-
*
|
|
444
|
+
* ポケモン名をキーに技構成を値とする入力スキーマ。
|
|
396
445
|
*/
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
});
|
|
405
|
-
const isoDateTimeField = z.string().refine((value) => !Number.isNaN(Date.parse(value)), { message: "ISO 8601 形式の日時文字列で指定してください。" });
|
|
406
|
-
/**
|
|
407
|
-
* 1 パーティ分の入力スキーマ。
|
|
408
|
-
*/
|
|
409
|
-
const partySchema = z.object({
|
|
410
|
-
name: z.string().min(1, { message: "パーティ名は 1 文字以上で指定してください。" }).max(50, { message: `パーティ名は 50 文字以下で指定してください。` }).describe("パーティの識別子。"),
|
|
411
|
-
memo: z.string().max(MAX_PARTY_MEMO_LENGTH, { message: `メモは ${MAX_PARTY_MEMO_LENGTH} 文字以下で指定してください。` }).optional().describe("自由記述メモ。"),
|
|
412
|
-
members: z.array(partyMemberSchema).min(1, { message: `パーティには 1 匹以上を含めてください。` }).max(6, { message: `パーティには 6 匹までしか含められません。` }).describe("1〜6 匹のメンバー。"),
|
|
413
|
-
createdAt: isoDateTimeField.describe("作成日時 (ISO 8601)。"),
|
|
414
|
-
updatedAt: isoDateTimeField.describe("更新日時 (ISO 8601)。")
|
|
415
|
-
});
|
|
416
|
-
/**
|
|
417
|
-
* `~/.ai-rotom/parties.json` 全体のスキーマ。
|
|
418
|
-
*/
|
|
419
|
-
const partiesFileSchema = z.object({
|
|
420
|
-
schemaVersion: z.number().int().positive().describe("パーティファイルの schemaVersion。"),
|
|
421
|
-
parties: z.array(partySchema).describe("登録済みパーティの一覧。")
|
|
446
|
+
const movesByPokemonSchema = z.record(nameInputSchema, z.array(moveNameInputSchema)).refine((movesByPokemon) => Object.keys(movesByPokemon).length <= 6, { message: `技を指定できるポケモンは 6 匹までです。` }).superRefine((movesByPokemon, ctx) => {
|
|
447
|
+
const exceeded = Object.entries(movesByPokemon).filter(([, moves]) => moves.length > 4).map(([pokemonName]) => pokemonName);
|
|
448
|
+
if (exceeded.length === 0) return;
|
|
449
|
+
ctx.addIssue({
|
|
450
|
+
code: "custom",
|
|
451
|
+
message: `技は 1 体につき 4 つまで指定できます。moves 引数の ${exceeded.join("、")} の技を 4 つ以内にして呼び直してください。`
|
|
452
|
+
});
|
|
422
453
|
});
|
|
423
|
-
// ../../shared/src/schemas/pokemon-input.ts
|
|
424
454
|
const pokemonFields = {
|
|
425
|
-
name:
|
|
426
|
-
nature:
|
|
455
|
+
name: nameInputSchema.describe("ポケモン名(日本語 or 英語)"),
|
|
456
|
+
nature: nameInputSchema.optional().describe("性格名(省略時: まじめ)"),
|
|
427
457
|
evs: evsSchema.optional().describe("能力ポイント(SP)。各ステ 0-32、合計 0-66。省略時は全 0 (無振り)。"),
|
|
428
|
-
ability:
|
|
429
|
-
item:
|
|
458
|
+
ability: nameInputSchema.optional().describe("特性名"),
|
|
459
|
+
item: nameInputSchema.optional().describe("持ち物名"),
|
|
430
460
|
boosts: boostsSchema.optional().describe("ランク補正 (-6〜+6 の整数)。省略時は全 0。いかく・ちからをつける等の変動を表現する。"),
|
|
431
|
-
status:
|
|
461
|
+
status: nameInputSchema.optional().describe("状態異常")
|
|
432
462
|
};
|
|
433
463
|
/**
|
|
434
464
|
* 技構成を使わないツール向けのポケモン入力スキーマ。
|
|
@@ -440,11 +470,11 @@ const pokemonSchema = z.object(pokemonFields);
|
|
|
440
470
|
*/
|
|
441
471
|
const pokemonWithMovesSchema = z.object({
|
|
442
472
|
...pokemonFields,
|
|
443
|
-
moves:
|
|
473
|
+
moves: movesInputSchema.optional().describe("技構成(日本語 or 英語、最大 4)。攻撃側として全技計算するときは指定した技だけを計算する。省略時は習得技すべてで計算する。")
|
|
444
474
|
});
|
|
445
475
|
const conditionsSchema = z.object({
|
|
446
|
-
weather:
|
|
447
|
-
terrain:
|
|
476
|
+
weather: nameInputSchema.optional().describe("天候(Sun, Rain, Sand, Hail, Snow)"),
|
|
477
|
+
terrain: nameInputSchema.optional().describe("フィールド(Electric, Grassy, Misty, Psychic)"),
|
|
448
478
|
battleFormat: z.enum(["singles", "doubles"]).optional().describe("対戦形式(シングル: singles / ダブル: doubles)。省略時は singles。doubles 指定時は全体攻撃技 (じしん/ねっぷう等) の威力が ×0.75 され、壁系の軽減率が約 0.667 倍に変わる。"),
|
|
449
479
|
isReflect: z.boolean().optional().describe("リフレクター"),
|
|
450
480
|
isLightScreen: z.boolean().optional().describe("ひかりのかべ"),
|
|
@@ -461,8 +491,7 @@ function resolveNameWithFallback(resolver, name, label) {
|
|
|
461
491
|
if (englishName !== void 0) return englishName;
|
|
462
492
|
if (resolver.hasEnglishName(name)) return name;
|
|
463
493
|
const suggestions = resolver.suggestSimilar(name);
|
|
464
|
-
|
|
465
|
-
throw new Error(`${label}「${name}」が見つかりません。${suggestionMessage}`);
|
|
494
|
+
throw new UserFacingError(`${label}「${name}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
466
495
|
}
|
|
467
496
|
/**
|
|
468
497
|
* `resolveNameWithFallback` の undefined 許容版。
|
|
@@ -707,7 +736,7 @@ var DamageCalculatorAdapter = class {
|
|
|
707
736
|
const gen = this.getGen();
|
|
708
737
|
const resolved = moves.map((name) => {
|
|
709
738
|
const englishName = resolveNameWithFallback(this.resolvers.move, name, "技");
|
|
710
|
-
if (gen.moves.get(toID(englishName)) === void 0) throw new
|
|
739
|
+
if (gen.moves.get(toID(englishName)) === void 0) throw new UserFacingError(`技「${name}」は計算エンジンが未対応のため計算できません。技構成から外して呼び出してください。`);
|
|
711
740
|
return englishName;
|
|
712
741
|
});
|
|
713
742
|
return [...new Set(resolved)];
|
|
@@ -763,174 +792,18 @@ function summarizeMoveDamages(results, toJapanese) {
|
|
|
763
792
|
return summary;
|
|
764
793
|
});
|
|
765
794
|
}
|
|
766
|
-
// src/
|
|
767
|
-
const
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
## 能力ポイント (SP) について
|
|
780
|
-
|
|
781
|
-
- 従来の「努力値 (EV)」は廃止され、「能力ポイント (SP)」という仕様に変更されました。
|
|
782
|
-
- 各ステータス (hp/atk/def/spa/spd/spe) あたりの上限: 32 SP
|
|
783
|
-
- 全ステータス合計の上限: 66 SP
|
|
784
|
-
- 1 SP = 実数値 +1 で直接加算されます (従来 EV の「4 EV = 実数値 +1」ではありません)。
|
|
785
|
-
- 各ステ 0〜32、合計 0〜66 の範囲内なら振り方は自由です。
|
|
786
|
-
- 従来の 252 EV / 510 EV 合計上限をそのまま渡すとエラーになります。
|
|
787
|
-
|
|
788
|
-
## SP 振りの実践(重要)
|
|
789
|
-
|
|
790
|
-
ポケチャンの SP は **1 単位で振れる**(各ステ 0〜32、合計 0〜66)ため、
|
|
791
|
-
従来作流の「とりあえず最速」「とりあえず HP252」のような **ブッパ一辺倒は最適でないことが多い**。
|
|
792
|
-
AI クライアントは目的駆動で刻む振り方を提案すること。各ステに 32 振り切るより、
|
|
793
|
-
要求を満たす最小限を割り当てて余り SP を別の役割に回す方が、合計 66 SP の制約下では強い。
|
|
794
|
-
|
|
795
|
-
### 火力調整(atk / spa)
|
|
796
|
-
- 「主要対面相手を確定 1 発(or 確定 2 発)で落とす最低限の振り」を calculate_damage_single / calculate_damage_all_moves で逆算する。
|
|
797
|
-
- 余った SP は HP / 素早さ / 別ステに回す。
|
|
798
|
-
|
|
799
|
-
### 耐久調整(hp / def / spd)
|
|
800
|
-
- 「主要対面相手の技を確定耐えする最低限の振り」を analyze_damage_range で逆算する。
|
|
801
|
-
- 物理耐久は hp + def、特殊耐久は hp + spd の組み合わせで効率化。HP のみブッパだと無駄が出やすい。
|
|
802
|
-
|
|
803
|
-
### 素早さ調整(spe)— S 調整振り
|
|
804
|
-
- 「特定ラインを抜く / 同速回避するピンポイント振り」を list_speed_tiers + calculate_stats で逆算する。
|
|
805
|
-
- 例: 準速 100 族(実数値 152)を抜きたいだけなら spe を 32 振り切る必要はなく、必要最小限の SP で抜ける。
|
|
806
|
-
- 同速回避は相手と同じ振りに対し +1 SP 多く振る。
|
|
807
|
-
|
|
808
|
-
### 提案フローのテンプレート
|
|
809
|
-
1. ユーザーに役割(耐久型 / 火力型 / 削り役 / サポート 等)と主要対面相手 2-3 体を確認する。
|
|
810
|
-
2. 火力 / 耐久 / 素早さの要求 SP を、対面相手ごとに計算ツールで逆算する。
|
|
811
|
-
3. 合計 66 SP の制約内で配分案を提示する(複数案あれば併記)。
|
|
812
|
-
4. 余り SP の使い道(HP / 素早さ微調整 / 火力上乗せ)も併記する。
|
|
813
|
-
|
|
814
|
-
「ブッパで雑に最速・HP 全振り」の提案はポケチャンでは型として弱いため、明示的に要求された場合を除き避けること。
|
|
815
|
-
|
|
816
|
-
## その他の固有仕様
|
|
817
|
-
|
|
818
|
-
- 個体値 (IV): 廃止。全ポケモン一律 31 固定として扱われます。
|
|
819
|
-
- 対戦レベル: 50 固定。
|
|
820
|
-
- メガシンカ: 1試合につき1回のみ使用可能。
|
|
821
|
-
- テラスタル: 未対応 (ゲーム側で未実装のため)。
|
|
822
|
-
- 特性の一部は計算エンジンが未対応で、ダメージ計算結果に効果が反映されません。get_ability_info で効果を確認し、必要に応じて結果の解釈時に補正してください。
|
|
823
|
-
- 持ち物の一部も同様に計算エンジンが未対応で、ダメージ計算結果に効果が反映されません (フィールド・接地判定に関わるものは反映されます)。get_item_info で効果を確認してください。
|
|
824
|
-
- メガシンカ後のフォルムと、一部のフォルムは覚える技 (learnset) のデータが未整備です。この場合 get_learnset はエラーになり、get_pokemon_summary の learnableMoves.count は 0、技の逆引き検索 (search_pokemon_by_move 等) では結果に出てきませんが、いずれも「技を覚えない」という意味ではありません。未整備かどうかは get_pokemon_info の learnableMoveCount が null かどうかで判別できるため、技プールを断定せずデータ未整備である旨をユーザーに伝えてください。これらの技プールはベースフォームの learnset を参照してください。
|
|
825
|
-
|
|
826
|
-
## 判断と計算の役割分担
|
|
827
|
-
|
|
828
|
-
- 本サーバーのツールは「判断の根拠となる正確なデータを返す」ことに責務を限定しています。
|
|
829
|
-
「この選出が最適」「この構築が正解」といった最終判断は返しません。
|
|
830
|
-
- 選出・構築・対策の結論は、ツールが返したデータ (タイプ相性・ダメ計・素早さ比較・対面マトリクス等) を元に AI が総合的に導いてください。
|
|
831
|
-
|
|
832
|
-
## ツール利用方針(必須)
|
|
833
|
-
|
|
834
|
-
以下のトピックがユーザー発話に出てきたら、必ず該当ツールを呼んで根拠データを取得してから回答すること。
|
|
835
|
-
ポケチャンは従来作と種族値・技威力・特性効果等で差異が出るため、知識ベースの即答は禁止。
|
|
836
|
-
|
|
837
|
-
### ポケモン検索・情報取得 (「○○ってどんなポケモン?」「○○タイプで素早いポケモンは?」等)
|
|
838
|
-
- 単体の基本情報 (種族値 / タイプ / 特性 / 体重) → get_pokemon_info
|
|
839
|
-
- 単体の総合プロファイル (耐性 / 覚える技 / 実数値) → get_pokemon_summary
|
|
840
|
-
- タイプ・種族値での絞り込み → search_pokemon
|
|
841
|
-
- 技の逆引き (この技を覚えるポケモン) → search_pokemon_by_move
|
|
842
|
-
- 特性の逆引き (この特性を持つポケモン) → search_pokemon_by_ability
|
|
843
|
-
- タイプ相性での逆引き (○○タイプを半減/無効化する等) → search_pokemon_by_type_effectiveness
|
|
844
|
-
- 覚える技一覧 → get_learnset
|
|
845
|
-
|
|
846
|
-
### 技・攻撃まわり (「○○の威力は?」「電気タイプで威力高い技は?」「攻撃範囲は?」等)
|
|
847
|
-
- 技の威力 / タイプ / 効果 / PP → get_move_info
|
|
848
|
-
- ある技を覚えるポケモン一覧 → search_pokemon_by_move
|
|
849
|
-
- 個体 / パーティの攻撃範囲 → get_pokemon_summary / analyze_party_coverage
|
|
850
|
-
- ダメージ計算 → calculate_damage_single (1 対 1 単発) / calculate_damage_all_moves (1 対 1 全技) / calculate_damage_party_matchup (6v6)
|
|
851
|
-
- 確定数 / 乱数 / 耐久要求の逆算 → analyze_damage_range
|
|
852
|
-
|
|
853
|
-
### 素早さ (S ライン) (「○○の素早さは?」「○○より早いポケモンは?」「S○○族は?」等)
|
|
854
|
-
- 実数値計算 → calculate_stats
|
|
855
|
-
- 素早さライン一覧・スカーフ込み比較 → list_speed_tiers
|
|
856
|
-
- 対面での先後判定 (素早さ比較込み) → analyze_matchup
|
|
857
|
-
|
|
858
|
-
### 対策候補 (「○○の対策は?」「○○に勝てるポケモンは?」等)
|
|
859
|
-
- 相手の弱点タイプを get_pokemon_summary の defenses で確認する
|
|
860
|
-
- 弱点タイプの攻撃技を覚えるポケモンを search_pokemon_by_type_effectiveness で検索する。タイプは 1 回に 1 つしか指定できないので、弱点が複数あればタイプごとに呼ぶ。相手の主力技のタイプを半減以下で受けるポケモンも同じツールで探せる
|
|
861
|
-
- 候補ごとに analyze_matchup を呼び、双方向のダメ計・素早さ・先制技を取得する。相手の技構成がわかっていれば moves を指定する
|
|
862
|
-
- どの候補を検討するか、受けて倒すのか上から倒すのかといった判断は AI が行う
|
|
863
|
-
|
|
864
|
-
### その他の事実確認 (「○○の特性効果は?」「○○の効果は?」「ねっぷう撃たれたら?」等)
|
|
865
|
-
- 特性効果 → get_ability_info
|
|
866
|
-
- 持ち物効果 → get_item_info
|
|
867
|
-
- 性格補正 → get_nature_info
|
|
868
|
-
- タイプ相性 → get_type_info
|
|
869
|
-
- 天候 / 状態異常 / フィールド / 壁 → get_condition_info
|
|
870
|
-
|
|
871
|
-
## 計算・分析系ツールでの ability / item 指定
|
|
872
|
-
|
|
873
|
-
- 計算・対面分析系ツール (calculate_damage_single / calculate_damage_all_moves / calculate_damage_party_matchup / analyze_damage_range / analyze_matchup / analyze_selection) を呼ぶ前に、攻撃側・防御側の ability / item を確認してから指定すること。
|
|
874
|
-
- 省略時の挙動: ability は通常特性 (pokemon.json の abilities[0]) が自動設定され、item は持ち物なし扱いとなる。そのためメガシンカ・こだわり系・半減きのみ・ちからのハチマキ 等が反映されず、実戦想定の build と乖離した結果になる。
|
|
875
|
-
- 正確な計算のためには ability / item を明示的に指定することを強く推奨する。
|
|
876
|
-
- 一方で、育成データ (evs・nature) が不明な場合は省略してよい (デフォルト値で計算)。
|
|
877
|
-
|
|
878
|
-
## パーティデータの扱い
|
|
879
|
-
|
|
880
|
-
- セッション開始時 (初回ユーザー発話への応答前) に必ず list_parties を呼び、保存済みパーティの名前一覧を把握すること。
|
|
881
|
-
- ユーザーが「メインパ」「ドラゴン軸」等の保存名に言及したら load_party で詳細を取得し、分析ツールに渡すこと。
|
|
882
|
-
- ユーザーが新規構築を説明した際は「保存しますか」と確認し、同意があれば save_party を呼ぶこと。
|
|
883
|
-
- パーティの削除依頼は delete_party を使うこと。
|
|
884
|
-
- 起動時にパーティ詳細まで自動読み込みしないこと (トークン消費を抑えるため、詳細は都度 load_party で取得する)。
|
|
885
|
-
|
|
886
|
-
## パーティ登録の対話スタイル
|
|
887
|
-
|
|
888
|
-
ユーザーが「パーティを保存したい」「構築を覚えて」等と依頼した場合:
|
|
889
|
-
|
|
890
|
-
### テキスト一括投入の場合 (ケース A)
|
|
891
|
-
|
|
892
|
-
- ユーザーが Showdown 風 or ポケソルテキストを貼り付けた → import_party_from_text を呼ぶ (原文をそのまま渡す)。
|
|
893
|
-
- ユーザーがゲーム内画面のスクショを添付した → 画像から build を読み取り、下記の対話ケース (B) と同じ手順でポケソルテキストに整理してから import_party_from_text を呼ぶ。
|
|
894
|
-
|
|
895
|
-
### 対話で埋める場合 (ケース B)
|
|
896
|
-
|
|
897
|
-
- ユーザーがテキストもスクショも提供しない → AI が段階的に質問する。
|
|
898
|
-
- 1 匹ずつ以下の順で聞く (ユーザーが知っている情報から埋める):
|
|
899
|
-
1. ポケモン名 (日本語 or 英語)
|
|
900
|
-
2. 性格 (候補を 4-5 個提示: いじっぱり / ようき / ひかえめ / おくびょう / ずぶとい など)
|
|
901
|
-
3. 特性 (該当ポケモンの候補を提示)
|
|
902
|
-
4. もちもの (省略可能、候補があれば提示)
|
|
903
|
-
5. 技 4 つ
|
|
904
|
-
6. SP 配分 (省略時は無振り 0、指定あれば各 0〜32 / 合計 0〜66 で受け付け)
|
|
905
|
-
|
|
906
|
-
### 整理ステップ (重要)
|
|
907
|
-
|
|
908
|
-
- 対話で情報が揃ったら、必ずポケソルテキスト形式にまとめて表示し、ユーザーに確認を取ること:
|
|
909
|
-
|
|
910
|
-
例:
|
|
911
|
-
ガブリアス @ こだわりスカーフ
|
|
912
|
-
特性: さめはだ
|
|
913
|
-
能力補正: いじっぱり
|
|
914
|
-
170(2)-200(32)-115(0)-90(0)-100(0)-167(32)
|
|
915
|
-
じしん / ドラゴンクロー / つのドリル / いわなだれ
|
|
916
|
-
|
|
917
|
-
- 実数値が不明な場合は calculate_stats を呼んで補完する (パーサー仕様上、実数値行は省略可能だが、ユーザー確認用に含めることを推奨)。
|
|
918
|
-
- 複数匹の場合は空行区切りで並べる。
|
|
919
|
-
- ユーザー確認後 import_party_from_text(text, name, memo) を呼ぶ。
|
|
920
|
-
- パーサーがエラーを返した場合は、原因を提示してユーザーに修正を確認する。
|
|
921
|
-
|
|
922
|
-
### 質問の書き方ルール
|
|
923
|
-
|
|
924
|
-
- 質問は短く、候補があれば列挙する (「性格はどうしますか? いじっぱり / ようき / ひかえめ」のような形式)。
|
|
925
|
-
- 一度に 1 項目だけ聞く (複数同時の質問は避ける)。
|
|
926
|
-
- ユーザーが「後で決める」と言った項目はデフォルト値で埋める (性格=まじめ、特性=基本特性、SP=無振り 等)。
|
|
927
|
-
- 不明な項目は tool 呼び出しで確認する (例: 覚える技 → get_learnset)。
|
|
928
|
-
|
|
929
|
-
### 絶対に守ること
|
|
930
|
-
|
|
931
|
-
- 対話で得た情報を JSON 化して save_party を直接呼ばない (ハルシネーションリスク軽減のため必ずポケソルテキスト経由)。
|
|
932
|
-
- ユーザー確認なしに save / import を実行しない。
|
|
933
|
-
`.trim();
|
|
795
|
+
// src/moves-requirement.ts
|
|
796
|
+
const MOVES_OPTIONAL = { requireMoves: false };
|
|
797
|
+
/**
|
|
798
|
+
* 技構成が必須の環境で、moves を指定していない攻撃側があればエラーにする。
|
|
799
|
+
* 習得技すべてを計算すると、実行環境の処理時間の上限を超えるため。
|
|
800
|
+
*/
|
|
801
|
+
function assertMovesSpecified(requirement, targets) {
|
|
802
|
+
if (!requirement.requireMoves) return;
|
|
803
|
+
const missing = targets.filter((target) => (target.moves?.length ?? 0) === 0);
|
|
804
|
+
if (missing.length === 0) return;
|
|
805
|
+
throw new UserFacingError(`このサーバーは 1 回の処理時間に上限があるため、技構成の指定が必要です。${missing.map((target) => `${target.field} (${target.name})`).join("、")} の moves に技構成を指定して呼び直してください。技は 4 つまで指定できます。技構成が分からない場合は get_learnset で覚える技を確認して選んでください。`);
|
|
806
|
+
}
|
|
934
807
|
// ../../data/champions/abilities.json
|
|
935
808
|
var abilities_default = [
|
|
936
809
|
{
|
|
@@ -4532,7 +4405,7 @@ var moves_default = [
|
|
|
4532
4405
|
"basePower": 60,
|
|
4533
4406
|
"accuracy": 100,
|
|
4534
4407
|
"pp": 12,
|
|
4535
|
-
"priority":
|
|
4408
|
+
"priority": -4,
|
|
4536
4409
|
"target": "normal",
|
|
4537
4410
|
"flags": [
|
|
4538
4411
|
"contact",
|
|
@@ -4623,7 +4496,7 @@ var moves_default = [
|
|
|
4623
4496
|
"basePower": 120,
|
|
4624
4497
|
"accuracy": 100,
|
|
4625
4498
|
"pp": 8,
|
|
4626
|
-
"priority":
|
|
4499
|
+
"priority": -3,
|
|
4627
4500
|
"target": "normal",
|
|
4628
4501
|
"flags": [
|
|
4629
4502
|
"bullet",
|
|
@@ -5328,7 +5201,7 @@ var moves_default = [
|
|
|
5328
5201
|
"basePower": 60,
|
|
5329
5202
|
"accuracy": 90,
|
|
5330
5203
|
"pp": 12,
|
|
5331
|
-
"priority":
|
|
5204
|
+
"priority": -6,
|
|
5332
5205
|
"target": "normal",
|
|
5333
5206
|
"flags": [
|
|
5334
5207
|
"contact",
|
|
@@ -5597,7 +5470,7 @@ var moves_default = [
|
|
|
5597
5470
|
"basePower": 0,
|
|
5598
5471
|
"accuracy": 100,
|
|
5599
5472
|
"pp": 20,
|
|
5600
|
-
"priority":
|
|
5473
|
+
"priority": -5,
|
|
5601
5474
|
"target": "scripted",
|
|
5602
5475
|
"flags": [
|
|
5603
5476
|
"contact",
|
|
@@ -6195,7 +6068,7 @@ var moves_default = [
|
|
|
6195
6068
|
"basePower": 60,
|
|
6196
6069
|
"accuracy": 90,
|
|
6197
6070
|
"pp": 12,
|
|
6198
|
-
"priority":
|
|
6071
|
+
"priority": -6,
|
|
6199
6072
|
"target": "normal",
|
|
6200
6073
|
"flags": [
|
|
6201
6074
|
"contact",
|
|
@@ -7316,7 +7189,7 @@ var moves_default = [
|
|
|
7316
7189
|
"basePower": 150,
|
|
7317
7190
|
"accuracy": 100,
|
|
7318
7191
|
"pp": 20,
|
|
7319
|
-
"priority":
|
|
7192
|
+
"priority": -3,
|
|
7320
7193
|
"target": "normal",
|
|
7321
7194
|
"flags": [
|
|
7322
7195
|
"contact",
|
|
@@ -9330,7 +9203,7 @@ var moves_default = [
|
|
|
9330
9203
|
"basePower": 0,
|
|
9331
9204
|
"accuracy": 100,
|
|
9332
9205
|
"pp": 20,
|
|
9333
|
-
"priority":
|
|
9206
|
+
"priority": -5,
|
|
9334
9207
|
"target": "scripted",
|
|
9335
9208
|
"flags": [
|
|
9336
9209
|
"failmefirst",
|
|
@@ -10718,7 +10591,7 @@ var moves_default = [
|
|
|
10718
10591
|
"basePower": 0,
|
|
10719
10592
|
"accuracy": true,
|
|
10720
10593
|
"pp": 20,
|
|
10721
|
-
"priority":
|
|
10594
|
+
"priority": -6,
|
|
10722
10595
|
"target": "normal",
|
|
10723
10596
|
"flags": [
|
|
10724
10597
|
"allyanim",
|
|
@@ -13064,7 +12937,7 @@ var moves_default = [
|
|
|
13064
12937
|
"basePower": 0,
|
|
13065
12938
|
"accuracy": true,
|
|
13066
12939
|
"pp": 8,
|
|
13067
|
-
"priority":
|
|
12940
|
+
"priority": -7,
|
|
13068
12941
|
"target": "all",
|
|
13069
12942
|
"flags": ["metronome", "mirror"],
|
|
13070
12943
|
"desc": "For 5 turns, the Speed of every Pokemon is recalculated for the purposes of determining turn order. During the effect, each Pokemon's Speed is considered to be (10000 - its normal Speed), and if this value is greater than 8191, 8192 is subtracted from it. If this move is used during the effect, the effect ends.",
|
|
@@ -13431,7 +13304,7 @@ var moves_default = [
|
|
|
13431
13304
|
"basePower": 0,
|
|
13432
13305
|
"accuracy": true,
|
|
13433
13306
|
"pp": 20,
|
|
13434
|
-
"priority":
|
|
13307
|
+
"priority": -6,
|
|
13435
13308
|
"target": "normal",
|
|
13436
13309
|
"flags": [
|
|
13437
13310
|
"allyanim",
|
|
@@ -38174,12 +38047,16 @@ function toTextResponse(value) {
|
|
|
38174
38047
|
text: JSON.stringify(value)
|
|
38175
38048
|
});
|
|
38176
38049
|
}
|
|
38050
|
+
/** UserFacingError 以外の例外のときに、元の文面の代わりに返す文面。 */
|
|
38051
|
+
const UNEXPECTED_ERROR_MESSAGE = "ツールの実行中に予期しないエラーが発生しました。";
|
|
38177
38052
|
/**
|
|
38178
38053
|
* エラー応答 (isError: true) を組み立てるヘルパー。
|
|
38179
38054
|
* エラー時はノイズになるため hint は付けない (仕様)。
|
|
38055
|
+
* 元の文面を返すのは UserFacingError だけにする。それ以外の例外の文面には
|
|
38056
|
+
* ライブラリ内部の事情が含まれうるため、固定の文面に置き換える。
|
|
38180
38057
|
*/
|
|
38181
38058
|
function toErrorResponse(error) {
|
|
38182
|
-
const message = error instanceof
|
|
38059
|
+
const message = error instanceof UserFacingError ? error.message : UNEXPECTED_ERROR_MESSAGE;
|
|
38183
38060
|
return {
|
|
38184
38061
|
content: [{
|
|
38185
38062
|
type: "text",
|
|
@@ -38191,7 +38068,7 @@ function toErrorResponse(error) {
|
|
|
38191
38068
|
// src/tools/info/ability-info.ts
|
|
38192
38069
|
const TOOL_NAME$19 = "get_ability_info";
|
|
38193
38070
|
const TOOL_DESCRIPTION$19 = "ポケモンの特性の詳細情報(効果説明)を取得する。ポケモンチャンピオンズで使える特性のみ返す。対戦でポケモンの特性を理解したいときに使用する。";
|
|
38194
|
-
const inputSchema$16 = { name:
|
|
38071
|
+
const inputSchema$16 = { name: nameInputSchema.describe("特性名(日本語 or 英語)") };
|
|
38195
38072
|
/**
|
|
38196
38073
|
* 特性名を英語に解決する。日本語名・英語名どちらでも受け付ける。
|
|
38197
38074
|
*/
|
|
@@ -38200,15 +38077,14 @@ function resolveAbilityNameEn$1(input) {
|
|
|
38200
38077
|
if (fromJa !== void 0) return fromJa;
|
|
38201
38078
|
if (abilityNameResolver.hasEnglishName(input)) return input;
|
|
38202
38079
|
const suggestions = abilityNameResolver.suggestSimilar(input);
|
|
38203
|
-
|
|
38204
|
-
throw new Error(`特性「${input}」が見つかりません。${suggestionMessage}`);
|
|
38080
|
+
throw new UserFacingError(`特性「${input}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
38205
38081
|
}
|
|
38206
38082
|
function registerAbilityInfoTool(server) {
|
|
38207
38083
|
server.tool(TOOL_NAME$19, TOOL_DESCRIPTION$19, inputSchema$16, async (args) => {
|
|
38208
38084
|
try {
|
|
38209
38085
|
const abilityId = toDataId(resolveAbilityNameEn$1(args.name));
|
|
38210
38086
|
const entry = abilitiesById.get(abilityId);
|
|
38211
|
-
if (entry === void 0) throw new
|
|
38087
|
+
if (entry === void 0) throw new UserFacingError(`特性「${args.name}」はチャンピオンズでは使用できません。`);
|
|
38212
38088
|
const output = {
|
|
38213
38089
|
name: entry.name,
|
|
38214
38090
|
nameJa: entry.nameJa,
|
|
@@ -38220,14 +38096,7 @@ function registerAbilityInfoTool(server) {
|
|
|
38220
38096
|
text: JSON.stringify(output)
|
|
38221
38097
|
});
|
|
38222
38098
|
} catch (error) {
|
|
38223
|
-
|
|
38224
|
-
return {
|
|
38225
|
-
content: [{
|
|
38226
|
-
type: "text",
|
|
38227
|
-
text: JSON.stringify({ error: message })
|
|
38228
|
-
}],
|
|
38229
|
-
isError: true
|
|
38230
|
-
};
|
|
38099
|
+
return toErrorResponse(error);
|
|
38231
38100
|
}
|
|
38232
38101
|
});
|
|
38233
38102
|
}
|
|
@@ -38244,8 +38113,8 @@ const STATUS_CATEGORY$2 = "Status";
|
|
|
38244
38113
|
const TOOL_NAME$18 = "analyze_party_coverage";
|
|
38245
38114
|
const TOOL_DESCRIPTION$18 = "パーティの攻撃カバレッジを分析する。各防御タイプ(18種)に対して、パーティのどの技が最も効果的かを算出し、抜群を取れないタイプを洗い出す。 `uncoveredTypes` は『抜群(>1 倍)を取れる技が 1 つも無い防御タイプ』を列挙する(等倍 1 倍も含む)。抜群倍率の内訳は `coverage[].maxMultiplier` を参照。 実在する複合タイプ(データ内に 1 匹以上存在する 2 タイプ組合せ)に対するカバレッジは `dualTypeCoverage` を参照。抜群を取れない複合タイプ数は `dualTypeUncoveredCount`。 攻撃側のタイプ変換系特性(Pixilate 等)は単一/複合カバレッジ双方に反映される。 ポケモンチャンピオンズ対応。";
|
|
38246
38115
|
const inputSchema$15 = {
|
|
38247
|
-
myParty: z.array(pokemonSchema).describe("自分のパーティ(moves 未指定時は learnset 内の全攻撃技を候補にする)"),
|
|
38248
|
-
moves:
|
|
38116
|
+
myParty: z.array(pokemonSchema).min(1).max(6).describe("自分のパーティ(moves 未指定時は learnset 内の全攻撃技を候補にする)"),
|
|
38117
|
+
moves: movesByPokemonSchema.optional().describe("ポケモン名(日本語 or 英語)をキーに技名配列を値とする map。省略時は learnset から全攻撃技を候補にする。")
|
|
38249
38118
|
};
|
|
38250
38119
|
/**
|
|
38251
38120
|
* 技名を英語名に解決する。日本語名・英語名どちらでも受け付ける。
|
|
@@ -38260,8 +38129,7 @@ function resolveMoveEnglishName(name) {
|
|
|
38260
38129
|
if (fromJa !== void 0) return fromJa;
|
|
38261
38130
|
if (moveNameResolver.hasEnglishName(name)) return name;
|
|
38262
38131
|
const suggestions = moveNameResolver.suggestSimilar(name);
|
|
38263
|
-
|
|
38264
|
-
throw new Error(`技「${name}」が見つかりません。${suggestionMessage}`);
|
|
38132
|
+
throw new UserFacingError(`技「${name}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
38265
38133
|
}
|
|
38266
38134
|
/**
|
|
38267
38135
|
* 1 メンバー分の「覚えている攻撃技 ID」を取得する。
|
|
@@ -38307,11 +38175,10 @@ function resolvePokemonEntry$3(name) {
|
|
|
38307
38175
|
const englishName = pokemonNameResolver.toEnglish(name) ?? (pokemonNameResolver.hasEnglishName(name) ? name : null);
|
|
38308
38176
|
if (englishName === null) {
|
|
38309
38177
|
const suggestions = pokemonNameResolver.suggestSimilar(name);
|
|
38310
|
-
|
|
38311
|
-
throw new Error(`ポケモン「${name}」が見つかりません。${suggestionMessage}`);
|
|
38178
|
+
throw new UserFacingError(`ポケモン「${name}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
38312
38179
|
}
|
|
38313
38180
|
const entry = pokemonById.get(toDataId(englishName));
|
|
38314
|
-
if (entry === void 0) throw new
|
|
38181
|
+
if (entry === void 0) throw new UserFacingError(`ポケモン「${name}」のデータが見つかりません。`);
|
|
38315
38182
|
return entry;
|
|
38316
38183
|
}
|
|
38317
38184
|
/**
|
|
@@ -38503,32 +38370,23 @@ function registerPartyCoverageTool(server) {
|
|
|
38503
38370
|
text: JSON.stringify(output)
|
|
38504
38371
|
});
|
|
38505
38372
|
} catch (error) {
|
|
38506
|
-
|
|
38507
|
-
return {
|
|
38508
|
-
content: [{
|
|
38509
|
-
type: "text",
|
|
38510
|
-
text: JSON.stringify({ error: message })
|
|
38511
|
-
}],
|
|
38512
|
-
isError: true
|
|
38513
|
-
};
|
|
38373
|
+
return toErrorResponse(error);
|
|
38514
38374
|
}
|
|
38515
38375
|
});
|
|
38516
38376
|
}
|
|
38517
38377
|
// src/tools/analysis/compare-parties.ts
|
|
38518
38378
|
const CHAMPIONS_GEN_NUM$7 = 0;
|
|
38519
|
-
/** 対戦に組めるパーティメンバーの上限 (ポケモンチャンピオンズ仕様) */
|
|
38520
|
-
const MAX_PARTY_SIZE = 6;
|
|
38521
38379
|
/** 性格未指定時の既定 (無補正性格) */
|
|
38522
38380
|
const DEFAULT_NATURE_EN$1 = "Serious";
|
|
38523
38381
|
const TOOL_NAME$17 = "compare_parties";
|
|
38524
38382
|
const TOOL_DESCRIPTION$17 = "2 つのパーティ (A / B) の統計差分を比較する。メンバー差分・タイプ分布・弱点/耐性/カバレッジ集合・素早さ分布・種族値合計の構造化データを 1 コールで返す。 パーティ改修案の比較や入れ替え検討に使用する。優劣判定は行わず、差分データのみを返す (解釈は AI 側の責務)。 moves は指定できないため、カバレッジ差分は learnset 全攻撃技ベースで評価される。ポケモンチャンピオンズ対応。";
|
|
38525
38383
|
const labelsSchema = z.object({
|
|
38526
|
-
partyA: z.string().optional(),
|
|
38527
|
-
partyB: z.string().optional()
|
|
38384
|
+
partyA: z.string().max(50).optional(),
|
|
38385
|
+
partyB: z.string().max(50).optional()
|
|
38528
38386
|
}).optional().describe("表示用ラベル (例: { partyA: '現行', partyB: '改修案' })");
|
|
38529
38387
|
const inputSchema$14 = {
|
|
38530
|
-
partyA: z.array(pokemonSchema).min(1).max(
|
|
38531
|
-
partyB: z.array(pokemonSchema).min(1).max(
|
|
38388
|
+
partyA: z.array(pokemonSchema).min(1).max(6).describe("比較対象のパーティ A"),
|
|
38389
|
+
partyB: z.array(pokemonSchema).min(1).max(6).describe("比較対象のパーティ B"),
|
|
38532
38390
|
labels: labelsSchema
|
|
38533
38391
|
};
|
|
38534
38392
|
/**
|
|
@@ -38539,11 +38397,10 @@ function resolvePokemonEntry$2(name) {
|
|
|
38539
38397
|
const englishName = pokemonNameResolver.toEnglish(name) ?? (pokemonNameResolver.hasEnglishName(name) ? name : null);
|
|
38540
38398
|
if (englishName === null) {
|
|
38541
38399
|
const suggestions = pokemonNameResolver.suggestSimilar(name);
|
|
38542
|
-
|
|
38543
|
-
throw new Error(`ポケモン「${name}」が見つかりません。${suggestionMessage}`);
|
|
38400
|
+
throw new UserFacingError(`ポケモン「${name}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
38544
38401
|
}
|
|
38545
38402
|
const entry = pokemonById.get(toDataId(englishName));
|
|
38546
|
-
if (entry === void 0) throw new
|
|
38403
|
+
if (entry === void 0) throw new UserFacingError(`ポケモン「${name}」のデータが見つかりません。`);
|
|
38547
38404
|
return entry;
|
|
38548
38405
|
}
|
|
38549
38406
|
/**
|
|
@@ -38555,8 +38412,7 @@ function resolveNatureName$1(nature) {
|
|
|
38555
38412
|
if (englishName !== void 0) return englishName;
|
|
38556
38413
|
if (natureNameResolver.hasEnglishName(nature)) return nature;
|
|
38557
38414
|
const suggestions = natureNameResolver.suggestSimilar(nature);
|
|
38558
|
-
|
|
38559
|
-
throw new Error(`性格「${nature}」が見つかりません。${suggestionMessage}`);
|
|
38415
|
+
throw new UserFacingError(`性格「${nature}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
38560
38416
|
}
|
|
38561
38417
|
/**
|
|
38562
38418
|
* pokemon.json のエントリから @smogon/calc 用 overrides を組み立てる。
|
|
@@ -38732,14 +38588,7 @@ function registerComparePartiesTool(server) {
|
|
|
38732
38588
|
text: JSON.stringify(output)
|
|
38733
38589
|
});
|
|
38734
38590
|
} catch (error) {
|
|
38735
|
-
|
|
38736
|
-
return {
|
|
38737
|
-
content: [{
|
|
38738
|
-
type: "text",
|
|
38739
|
-
text: JSON.stringify({ error: message })
|
|
38740
|
-
}],
|
|
38741
|
-
isError: true
|
|
38742
|
-
};
|
|
38591
|
+
return toErrorResponse(error);
|
|
38743
38592
|
}
|
|
38744
38593
|
});
|
|
38745
38594
|
}
|
|
@@ -38754,7 +38603,7 @@ const CATEGORY_VALUES = [
|
|
|
38754
38603
|
];
|
|
38755
38604
|
const inputSchema$13 = {
|
|
38756
38605
|
category: z.enum(CATEGORY_VALUES).optional().describe("絞り込むカテゴリ(weather: 天候 / terrain: フィールド / status: 状態異常 / sideCondition: サイド効果)。省略時は全カテゴリ。"),
|
|
38757
|
-
name:
|
|
38606
|
+
name: nameInputSchema.optional().describe("絞り込む条件名(日本語 or 英語)。省略時は全件。")
|
|
38758
38607
|
};
|
|
38759
38608
|
/**
|
|
38760
38609
|
* 指定された name に合致するエントリだけを返す。
|
|
@@ -38783,14 +38632,7 @@ function registerConditionInfoTool(server) {
|
|
|
38783
38632
|
text: JSON.stringify(output)
|
|
38784
38633
|
});
|
|
38785
38634
|
} catch (error) {
|
|
38786
|
-
|
|
38787
|
-
return {
|
|
38788
|
-
content: [{
|
|
38789
|
-
type: "text",
|
|
38790
|
-
text: JSON.stringify({ error: message })
|
|
38791
|
-
}],
|
|
38792
|
-
isError: true
|
|
38793
|
-
};
|
|
38635
|
+
return toErrorResponse(error);
|
|
38794
38636
|
}
|
|
38795
38637
|
});
|
|
38796
38638
|
}
|
|
@@ -38806,7 +38648,7 @@ const damageCalculator = new DamageCalculatorAdapter({
|
|
|
38806
38648
|
const damageCalcInputSchema = {
|
|
38807
38649
|
attacker: pokemonSchema.describe("攻撃側ポケモン"),
|
|
38808
38650
|
defender: pokemonSchema.describe("防御側ポケモン"),
|
|
38809
|
-
moveName:
|
|
38651
|
+
moveName: nameInputSchema.describe("技名(日本語 or 英語)"),
|
|
38810
38652
|
conditions: conditionsSchema.optional().describe("バトル条件")
|
|
38811
38653
|
};
|
|
38812
38654
|
const SINGLE_TOOL_NAME = "calculate_damage_single";
|
|
@@ -38821,8 +38663,8 @@ const allMovesInputSchema = {
|
|
|
38821
38663
|
const PARTY_MATCHUP_TOOL_NAME = "calculate_damage_party_matchup";
|
|
38822
38664
|
const PARTY_MATCHUP_TOOL_DESCRIPTION = "パーティ対パーティの全組み合わせダメージ計算を行う。6vs6の全対面での火力関係を一覧する。ポケモン対戦の選出判断やパーティ構築の検討に使用する。正確な計算のため各ポケモンの ability / item の指定を推奨(省略時は通常特性・持ち物なし扱い)。";
|
|
38823
38665
|
const partyMatchupInputSchema = {
|
|
38824
|
-
myParty: z.array(pokemonWithMovesSchema).describe("自分のパーティ"),
|
|
38825
|
-
opponentParty: z.array(pokemonSchema).describe("相手のパーティ"),
|
|
38666
|
+
myParty: z.array(pokemonWithMovesSchema).min(1).max(6).describe("自分のパーティ"),
|
|
38667
|
+
opponentParty: z.array(pokemonSchema).min(1).max(6).describe("相手のパーティ"),
|
|
38826
38668
|
conditions: conditionsSchema.optional().describe("バトル条件")
|
|
38827
38669
|
};
|
|
38828
38670
|
/** ダメージを与えられる技がない対面の最大ダメージ割合。 */
|
|
@@ -38848,7 +38690,7 @@ function extractBestMove(results, defenderNameEn, moveResolver) {
|
|
|
38848
38690
|
koChance: best.koChance
|
|
38849
38691
|
};
|
|
38850
38692
|
}
|
|
38851
|
-
function registerDamageCalculationTools(server) {
|
|
38693
|
+
function registerDamageCalculationTools(server, movesRequirement = MOVES_OPTIONAL) {
|
|
38852
38694
|
server.tool(SINGLE_TOOL_NAME, SINGLE_TOOL_DESCRIPTION, damageCalcInputSchema, async (args) => {
|
|
38853
38695
|
try {
|
|
38854
38696
|
const result = damageCalculator.calculate({
|
|
@@ -38867,6 +38709,11 @@ function registerDamageCalculationTools(server) {
|
|
|
38867
38709
|
});
|
|
38868
38710
|
server.tool(ALL_MOVES_TOOL_NAME, ALL_MOVES_TOOL_DESCRIPTION, allMovesInputSchema, async (args) => {
|
|
38869
38711
|
try {
|
|
38712
|
+
assertMovesSpecified(movesRequirement, [{
|
|
38713
|
+
field: "attacker",
|
|
38714
|
+
name: args.attacker.name,
|
|
38715
|
+
moves: args.attacker.moves
|
|
38716
|
+
}]);
|
|
38870
38717
|
const results = damageCalculator.calculateAllMoves({
|
|
38871
38718
|
attacker: args.attacker,
|
|
38872
38719
|
defender: args.defender,
|
|
@@ -38889,6 +38736,11 @@ function registerDamageCalculationTools(server) {
|
|
|
38889
38736
|
});
|
|
38890
38737
|
server.tool(PARTY_MATCHUP_TOOL_NAME, PARTY_MATCHUP_TOOL_DESCRIPTION, partyMatchupInputSchema, async (args) => {
|
|
38891
38738
|
try {
|
|
38739
|
+
assertMovesSpecified(movesRequirement, args.myParty.map((member, index) => ({
|
|
38740
|
+
field: `myParty[${index}]`,
|
|
38741
|
+
name: member.name,
|
|
38742
|
+
moves: member.moves
|
|
38743
|
+
})));
|
|
38892
38744
|
const output = {
|
|
38893
38745
|
myParty: [],
|
|
38894
38746
|
opponentParty: [],
|
|
@@ -38937,7 +38789,7 @@ const TOOL_DESCRIPTION$15 = "ダメージ計算を逆引きして、防御側を
|
|
|
38937
38789
|
const inputSchema$12 = {
|
|
38938
38790
|
attacker: pokemonSchema.describe("攻撃側ポケモン"),
|
|
38939
38791
|
defender: pokemonSchema.describe("防御側ポケモン"),
|
|
38940
|
-
moveName:
|
|
38792
|
+
moveName: nameInputSchema.describe("技名(日本語 or 英語)"),
|
|
38941
38793
|
conditions: conditionsSchema.optional().describe("バトル条件")
|
|
38942
38794
|
};
|
|
38943
38795
|
/**
|
|
@@ -39072,10 +38924,10 @@ function registerDamageRangeTool(server) {
|
|
|
39072
38924
|
if (moveEn === null) {
|
|
39073
38925
|
const suggestions = moveNameResolver.suggestSimilar(args.moveName);
|
|
39074
38926
|
const suggestionMessage = suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : "";
|
|
39075
|
-
throw new
|
|
38927
|
+
throw new UserFacingError(`技「${args.moveName}」が見つかりません。${suggestionMessage}`);
|
|
39076
38928
|
}
|
|
39077
38929
|
const moveEntry = movesById.get(toDataId(moveEn));
|
|
39078
|
-
if (moveEntry === void 0) throw new
|
|
38930
|
+
if (moveEntry === void 0) throw new UserFacingError(`技「${args.moveName}」はチャンピオンズでは使用できません。`);
|
|
39079
38931
|
const { pokemon: defObj } = damageCalculator.createPokemonObject(args.defender);
|
|
39080
38932
|
const defenderMaxHp = defObj.maxHP();
|
|
39081
38933
|
let baseResult = null;
|
|
@@ -39123,292 +38975,15 @@ function registerDamageRangeTool(server) {
|
|
|
39123
38975
|
type: "text",
|
|
39124
38976
|
text: JSON.stringify(output)
|
|
39125
38977
|
});
|
|
39126
|
-
} catch (error) {
|
|
39127
|
-
const message = error instanceof Error ? error.message : "不明なエラーが発生しました";
|
|
39128
|
-
return {
|
|
39129
|
-
content: [{
|
|
39130
|
-
type: "text",
|
|
39131
|
-
text: JSON.stringify({ error: message })
|
|
39132
|
-
}],
|
|
39133
|
-
isError: true
|
|
39134
|
-
};
|
|
39135
|
-
}
|
|
39136
|
-
});
|
|
39137
|
-
}
|
|
39138
|
-
// src/party-store.ts
|
|
39139
|
-
/** ai-rotom の永続化用ディレクトリ名 (ホーム直下)。 */
|
|
39140
|
-
const AI_ROTOM_DIR_NAME = ".ai-rotom";
|
|
39141
|
-
/** パーティ永続化ファイル名。 */
|
|
39142
|
-
const PARTIES_FILE_NAME = "parties.json";
|
|
39143
|
-
/** atomic write 用の一時ファイル拡張子。 */
|
|
39144
|
-
const TEMP_FILE_EXT = ".tmp";
|
|
39145
|
-
/** JSON.stringify の indent。 */
|
|
39146
|
-
const JSON_INDENT = 2;
|
|
39147
|
-
/** 一時ファイル名用のランダムサフィックスバイト数。 */
|
|
39148
|
-
const TEMP_SUFFIX_BYTES = 8;
|
|
39149
|
-
/**
|
|
39150
|
-
* 永続化ファイル (`~/.ai-rotom/parties.json`) の絶対パスを返す。
|
|
39151
|
-
* ホームディレクトリが解決できない場合はエラーを投げる。
|
|
39152
|
-
*/
|
|
39153
|
-
function resolvePartiesFilePath() {
|
|
39154
|
-
const home = homedir();
|
|
39155
|
-
if (home === "" || home === void 0 || home === null) throw new Error("ホームディレクトリが解決できませんでした。$HOME 環境変数を確認してください。");
|
|
39156
|
-
return join(home, AI_ROTOM_DIR_NAME, PARTIES_FILE_NAME);
|
|
39157
|
-
}
|
|
39158
|
-
/**
|
|
39159
|
-
* 永続化ファイルの読み込み結果。
|
|
39160
|
-
* 存在しない場合は空の PartiesFile を返す。
|
|
39161
|
-
* 破損・権限・schemaVersion 不整合の場合はエラーを投げる。
|
|
39162
|
-
*/
|
|
39163
|
-
function loadPartiesFile(filePath = resolvePartiesFilePath()) {
|
|
39164
|
-
let raw;
|
|
39165
|
-
try {
|
|
39166
|
-
raw = readFileSync(filePath, { encoding: "utf-8" });
|
|
39167
|
-
} catch (error) {
|
|
39168
|
-
if (isNodeErrnoException(error) && error.code === "ENOENT") return {
|
|
39169
|
-
schemaVersion: 1,
|
|
39170
|
-
parties: []
|
|
39171
|
-
};
|
|
39172
|
-
throw wrapIoError("パーティファイルの読み込みに失敗しました", error);
|
|
39173
|
-
}
|
|
39174
|
-
let parsed;
|
|
39175
|
-
try {
|
|
39176
|
-
parsed = JSON.parse(raw);
|
|
39177
|
-
} catch (error) {
|
|
39178
|
-
const cause = error instanceof Error ? error.message : String(error);
|
|
39179
|
-
throw new Error(`パーティファイル (${filePath}) の JSON パースに失敗しました: ${cause}`);
|
|
39180
|
-
}
|
|
39181
|
-
const result = partiesFileSchema.safeParse(parsed);
|
|
39182
|
-
if (!result.success) {
|
|
39183
|
-
const issues = result.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ");
|
|
39184
|
-
throw new Error(`パーティファイル (${filePath}) のスキーマ検証に失敗しました: ${issues}`);
|
|
39185
|
-
}
|
|
39186
|
-
if (result.data.schemaVersion !== 1) throw new Error(`未対応の schemaVersion (${result.data.schemaVersion}) です。現行は 1 です。`);
|
|
39187
|
-
return result.data;
|
|
39188
|
-
}
|
|
39189
|
-
/**
|
|
39190
|
-
* 永続化ファイルを atomic に書き込む。
|
|
39191
|
-
* 親ディレクトリが存在しない場合は作成する。
|
|
39192
|
-
* 一時ファイル → rename で置き換えるため、途中失敗でも元ファイルは壊れない。
|
|
39193
|
-
*/
|
|
39194
|
-
function savePartiesFile(data, filePath = resolvePartiesFilePath()) {
|
|
39195
|
-
const validated = partiesFileSchema.parse(data);
|
|
39196
|
-
const dir = dirname(filePath);
|
|
39197
|
-
try {
|
|
39198
|
-
mkdirSync(dir, { recursive: true });
|
|
39199
|
-
} catch (error) {
|
|
39200
|
-
throw wrapIoError(`パーティ保存ディレクトリ (${dir}) の作成に失敗しました`, error);
|
|
39201
|
-
}
|
|
39202
|
-
const tempPath = `${filePath}.${randomBytes(TEMP_SUFFIX_BYTES).toString("hex")}${TEMP_FILE_EXT}`;
|
|
39203
|
-
const serialized = JSON.stringify(validated, null, JSON_INDENT);
|
|
39204
|
-
try {
|
|
39205
|
-
writeFileSync(tempPath, serialized, {
|
|
39206
|
-
encoding: "utf-8",
|
|
39207
|
-
mode: 384
|
|
39208
|
-
});
|
|
39209
|
-
renameSync(tempPath, filePath);
|
|
39210
|
-
} catch (error) {
|
|
39211
|
-
try {
|
|
39212
|
-
rmSync(tempPath, { force: true });
|
|
39213
|
-
} catch {}
|
|
39214
|
-
throw wrapIoError(`パーティファイル (${filePath}) の保存に失敗しました`, error);
|
|
39215
|
-
}
|
|
39216
|
-
}
|
|
39217
|
-
function isNodeErrnoException(value) {
|
|
39218
|
-
return value instanceof Error && typeof value.code === "string";
|
|
39219
|
-
}
|
|
39220
|
-
function wrapIoError(prefix, error) {
|
|
39221
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
39222
|
-
const code = isNodeErrnoException(error) && error.code !== void 0 ? ` [${error.code}]` : "";
|
|
39223
|
-
return /* @__PURE__ */ new Error(`${prefix}${code}: ${message}`);
|
|
39224
|
-
}
|
|
39225
|
-
// src/party-text.ts
|
|
39226
|
-
/** ポケソルテキストで性格を省略した場合のデフォルト。 */
|
|
39227
|
-
const DEFAULT_NATURE_NAME = "まじめ";
|
|
39228
|
-
/**
|
|
39229
|
-
* ポケソルテキストを空行区切りで個別ブロックに分割する。
|
|
39230
|
-
* 改行 (LF / CRLF) のどちらにも対応する。
|
|
39231
|
-
* 空白のみのブロックは除外する。
|
|
39232
|
-
*/
|
|
39233
|
-
function splitPokesolTextBlocks(text) {
|
|
39234
|
-
return text.replace(/\r\n/g, "\n").split(/\n\s*\n/).map((block) => block.trim()).filter((block) => block.length > 0);
|
|
39235
|
-
}
|
|
39236
|
-
/**
|
|
39237
|
-
* パーサー出力 (`PokesolTextParseReult`) を `PartyMember` に変換する。
|
|
39238
|
-
* - `abilityNames[1..]` (括弧内のメガ前特性) が存在すれば最も元の状態 (末尾) を
|
|
39239
|
-
* `ability` として保存 (通常状態の特性が基本。メガ進化時の特性変化は計算側の責務)
|
|
39240
|
-
* - `natureName` が null の場合は `DEFAULT_NATURE_NAME` で補完
|
|
39241
|
-
* - `terastalName` が存在する場合はポケチャン未対応のため無視
|
|
39242
|
-
* - `moveNames` が空配列の場合は `moves` フィールド自体を省く
|
|
39243
|
-
*
|
|
39244
|
-
* 補完・無視を行った場合はブロック番号付きの warnings を返す。
|
|
39245
|
-
*/
|
|
39246
|
-
function mapPokesolResultToPartyMember(result, blockNumber) {
|
|
39247
|
-
const warnings = [];
|
|
39248
|
-
if (result.pokemonName === null || result.pokemonName === "") throw new Error(`ブロック ${blockNumber}: ポケモン名が読み取れませんでした。`);
|
|
39249
|
-
const member = { name: result.pokemonName };
|
|
39250
|
-
if (result.itemName !== null) member.item = result.itemName;
|
|
39251
|
-
const { ability, ignoredAbilities } = selectAbility(result.abilityNames);
|
|
39252
|
-
if (ability !== void 0) {
|
|
39253
|
-
member.ability = ability;
|
|
39254
|
-
if (ignoredAbilities.length > 0) {
|
|
39255
|
-
const ignored = ignoredAbilities.map((name) => `「${name}」`).join("");
|
|
39256
|
-
warnings.push(`ブロック ${blockNumber}: メガ進化特性${ignored}は無視し、メガ前特性「${ability}」を ability として保存しました。`);
|
|
39257
|
-
}
|
|
39258
|
-
}
|
|
39259
|
-
if (result.natureName !== null) member.nature = result.natureName;
|
|
39260
|
-
else {
|
|
39261
|
-
member.nature = DEFAULT_NATURE_NAME;
|
|
39262
|
-
warnings.push(`ブロック ${blockNumber}: 性格が省略されていたためデフォルト「${DEFAULT_NATURE_NAME}」を補完しました。`);
|
|
39263
|
-
}
|
|
39264
|
-
if (result.terastalName !== null && result.terastalName !== "") warnings.push(`ブロック ${blockNumber}: テラスタイプ「${result.terastalName}」はポケモンチャンピオンズ未対応のため無視しました。`);
|
|
39265
|
-
const evs = buildEvsFromResult(result.evs);
|
|
39266
|
-
if (evs !== void 0) member.evs = evs;
|
|
39267
|
-
if (result.moveNames.length > 0) member.moves = [...result.moveNames];
|
|
39268
|
-
else warnings.push(`ブロック ${blockNumber}: 技行が省略されていたため moves を空で登録しました。`);
|
|
39269
|
-
return {
|
|
39270
|
-
member,
|
|
39271
|
-
warnings
|
|
39272
|
-
};
|
|
39273
|
-
}
|
|
39274
|
-
/**
|
|
39275
|
-
* パーサー出力の `abilityNames` から `PartyMember.ability` に保存する特性を選ぶ。
|
|
39276
|
-
* `abilityNames` は `[現在の特性, ...括弧内の以前の特性]` の順で、
|
|
39277
|
-
* 特性名が省略された位置 (`特性: (さめはだ)` の先頭など) は null になる。
|
|
39278
|
-
*
|
|
39279
|
-
* - 括弧内に特性があれば、最も元の状態である末尾の特性を採用する
|
|
39280
|
-
* - 括弧内が全て空なら現在の特性を採用する
|
|
39281
|
-
* - 採用しなかった特性 (重複を除く) は ignoredAbilities として返す
|
|
39282
|
-
*/
|
|
39283
|
-
function selectAbility(abilityNames) {
|
|
39284
|
-
const names = abilityNames.filter((name) => name !== null);
|
|
39285
|
-
const [currentAbility, ...previousAbilities] = abilityNames;
|
|
39286
|
-
const ability = previousAbilities.filter((name) => name !== null).at(-1) ?? currentAbility ?? void 0;
|
|
39287
|
-
return {
|
|
39288
|
-
ability,
|
|
39289
|
-
ignoredAbilities: [...new Set(names)].filter((name) => name !== ability)
|
|
39290
|
-
};
|
|
39291
|
-
}
|
|
39292
|
-
/**
|
|
39293
|
-
* パーサー出力の SP (努力値フィールド) を `EvsInput` に変換する。
|
|
39294
|
-
* 全て 0 の場合は undefined を返し、`PartyMember.evs` を省く。
|
|
39295
|
-
*/
|
|
39296
|
-
function buildEvsFromResult(parserEvs) {
|
|
39297
|
-
const mapped = {
|
|
39298
|
-
hp: parserEvs.hp,
|
|
39299
|
-
atk: parserEvs.attack,
|
|
39300
|
-
def: parserEvs.defense,
|
|
39301
|
-
spa: parserEvs.specialAttack,
|
|
39302
|
-
spd: parserEvs.specialDefense,
|
|
39303
|
-
spe: parserEvs.speed
|
|
39304
|
-
};
|
|
39305
|
-
return Object.values(mapped).some((value) => value !== void 0 && value !== 0) ? mapped : void 0;
|
|
39306
|
-
}
|
|
39307
|
-
// src/tools/party/import-party-from-text.ts
|
|
39308
|
-
const TOOL_NAME$14 = "import_party_from_text";
|
|
39309
|
-
const TOOL_DESCRIPTION$14 = "ポケソルテキスト (Showdown 風に 1 匹あたり 3〜6 行・複数匹は空行区切り) からパーティを一括取り込みして保存する (upsert)。各メンバーはポケモン名 / 特性 / 性格 / 技 / 持ち物をポケチャン内の既知データと照合する。エラーがある場合は部分保存せず全体を失敗させる。";
|
|
39310
|
-
/** ポケソルテキスト入力の最大文字数 (6 匹 × 数百文字 + メモ想定)。 */
|
|
39311
|
-
const MAX_POKESOL_TEXT_LENGTH = 8e3;
|
|
39312
|
-
const defaultNowProvider$1 = () => /* @__PURE__ */ new Date();
|
|
39313
|
-
const defaultStoreIO$1 = {
|
|
39314
|
-
load: () => loadPartiesFile(),
|
|
39315
|
-
save: (data) => savePartiesFile(data)
|
|
39316
|
-
};
|
|
39317
|
-
const inputSchema$11 = {
|
|
39318
|
-
text: z.string().min(1, { message: "ポケソルテキストは 1 文字以上で指定してください。" }).max(MAX_POKESOL_TEXT_LENGTH, { message: `ポケソルテキストは ${MAX_POKESOL_TEXT_LENGTH} 文字以下で指定してください。` }).describe("ポケソルテキスト。1 匹あたり 3〜6 行 (ポケモン名[@持ち物] / テラスタイプ行 省略可 / 特性 / 能力補正 / 実数値(SP) 省略可 / 技 省略可)。複数匹は空行で区切る。"),
|
|
39319
|
-
name: z.string().min(1, { message: "パーティ名は 1 文字以上で指定してください。" }).max(50, { message: `パーティ名は 50 文字以下で指定してください。` }).describe("保存名 (識別子。同名は上書き)。"),
|
|
39320
|
-
memo: z.string().max(MAX_PARTY_MEMO_LENGTH, { message: `メモは ${MAX_PARTY_MEMO_LENGTH} 文字以下で指定してください。` }).optional().describe("構築メモ (自由記述)。")
|
|
39321
|
-
};
|
|
39322
|
-
/**
|
|
39323
|
-
* NameResolver の既知名 (日英どちらでも) として存在するかを判定する。
|
|
39324
|
-
* 未知の場合は類似候補付きのメッセージを投げる。
|
|
39325
|
-
*/
|
|
39326
|
-
function assertKnownName(resolver, name, label, blockNumber) {
|
|
39327
|
-
if (resolver.hasJapaneseName(name) || resolver.hasEnglishName(name)) return;
|
|
39328
|
-
const suggestions = resolver.suggestSimilar(name, 3);
|
|
39329
|
-
const suggestionMessage = suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : "";
|
|
39330
|
-
throw new Error(`ブロック ${blockNumber}: ${label}「${name}」が見つかりません。${suggestionMessage}`);
|
|
39331
|
-
}
|
|
39332
|
-
/**
|
|
39333
|
-
* PartyMember の各名前フィールドを NameResolver で検証する。
|
|
39334
|
-
* 未知名があれば該当ブロックのエラーとして throw。
|
|
39335
|
-
*/
|
|
39336
|
-
function validateMemberNames(member, blockNumber) {
|
|
39337
|
-
assertKnownName(pokemonNameResolver, member.name, "ポケモン名", blockNumber);
|
|
39338
|
-
if (member.nature !== void 0) assertKnownName(natureNameResolver, member.nature, "性格", blockNumber);
|
|
39339
|
-
if (member.ability !== void 0) assertKnownName(abilityNameResolver, member.ability, "特性", blockNumber);
|
|
39340
|
-
if (member.item !== void 0) assertKnownName(itemNameResolver, member.item, "持ち物", blockNumber);
|
|
39341
|
-
if (member.moves !== void 0) for (const move of member.moves) assertKnownName(moveNameResolver, move, "技", blockNumber);
|
|
39342
|
-
}
|
|
39343
|
-
/**
|
|
39344
|
-
* 本ツールの全処理 (split → parse → map → validate → persist) を実行する。
|
|
39345
|
-
* テストから直接呼び出せるようエクスポートする。
|
|
39346
|
-
*/
|
|
39347
|
-
function runImportPartyFromText(input, deps = {}) {
|
|
39348
|
-
const storeIO = deps.storeIO ?? defaultStoreIO$1;
|
|
39349
|
-
const now = deps.now ?? defaultNowProvider$1;
|
|
39350
|
-
const blocks = splitPokesolTextBlocks(input.text);
|
|
39351
|
-
if (blocks.length < 1) throw new Error(`パーティには 1 匹以上を含めてください (検出: ${blocks.length} 匹)。`);
|
|
39352
|
-
if (blocks.length > 6) throw new Error(`パーティには 6 匹までしか含められません (検出: ${blocks.length} 匹)。`);
|
|
39353
|
-
const warnings = [];
|
|
39354
|
-
const members = [];
|
|
39355
|
-
blocks.forEach((block, index) => {
|
|
39356
|
-
const blockNumber = index + 1;
|
|
39357
|
-
let parsed;
|
|
39358
|
-
try {
|
|
39359
|
-
parsed = parse(block);
|
|
39360
|
-
} catch (error) {
|
|
39361
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
39362
|
-
throw new Error(`ブロック ${blockNumber} のパースに失敗しました: ${reason}`);
|
|
39363
|
-
}
|
|
39364
|
-
const mapped = mapPokesolResultToPartyMember(parsed, blockNumber);
|
|
39365
|
-
validateMemberNames(mapped.member, blockNumber);
|
|
39366
|
-
members.push(mapped.member);
|
|
39367
|
-
warnings.push(...mapped.warnings);
|
|
39368
|
-
});
|
|
39369
|
-
const file = storeIO.load();
|
|
39370
|
-
const existingIndex = file.parties.findIndex((p) => p.name === input.name);
|
|
39371
|
-
const nowIso = now().toISOString();
|
|
39372
|
-
const createdAt = existingIndex >= 0 ? file.parties[existingIndex].createdAt : nowIso;
|
|
39373
|
-
const party = {
|
|
39374
|
-
name: input.name,
|
|
39375
|
-
members,
|
|
39376
|
-
createdAt,
|
|
39377
|
-
updatedAt: nowIso
|
|
39378
|
-
};
|
|
39379
|
-
if (input.memo !== void 0) party.memo = input.memo;
|
|
39380
|
-
partySchema.parse(party);
|
|
39381
|
-
const nextParties = [...file.parties];
|
|
39382
|
-
if (existingIndex >= 0) nextParties[existingIndex] = party;
|
|
39383
|
-
else nextParties.push(party);
|
|
39384
|
-
storeIO.save({
|
|
39385
|
-
schemaVersion: 1,
|
|
39386
|
-
parties: nextParties
|
|
39387
|
-
});
|
|
39388
|
-
return {
|
|
39389
|
-
saved: true,
|
|
39390
|
-
party,
|
|
39391
|
-
warnings,
|
|
39392
|
-
filePath: resolvePartiesFilePath(),
|
|
39393
|
-
overwrote: existingIndex >= 0
|
|
39394
|
-
};
|
|
39395
|
-
}
|
|
39396
|
-
/**
|
|
39397
|
-
* import_party_from_text ツールをサーバーに登録する。
|
|
39398
|
-
*/
|
|
39399
|
-
function registerImportPartyFromTextTool(server, deps = {}) {
|
|
39400
|
-
server.tool(TOOL_NAME$14, TOOL_DESCRIPTION$14, inputSchema$11, async (args) => {
|
|
39401
|
-
try {
|
|
39402
|
-
return toTextResponse(runImportPartyFromText(args, deps));
|
|
39403
38978
|
} catch (error) {
|
|
39404
38979
|
return toErrorResponse(error);
|
|
39405
38980
|
}
|
|
39406
38981
|
});
|
|
39407
38982
|
}
|
|
39408
38983
|
// src/tools/info/item-info.ts
|
|
39409
|
-
const TOOL_NAME$
|
|
39410
|
-
const TOOL_DESCRIPTION$
|
|
39411
|
-
const inputSchema$
|
|
38984
|
+
const TOOL_NAME$14 = "get_item_info";
|
|
38985
|
+
const TOOL_DESCRIPTION$14 = "ポケモンの持ち物(アイテム)の詳細情報(効果説明、メガストーン情報)を取得する。ポケモンチャンピオンズで使える持ち物のみ返す。パーティ構築で持ち物を選ぶ際に使用する。";
|
|
38986
|
+
const inputSchema$11 = { name: nameInputSchema.describe("持ち物名(日本語 or 英語)") };
|
|
39412
38987
|
/**
|
|
39413
38988
|
* 持ち物名を英語に解決する。日本語名・英語名どちらでも受け付ける。
|
|
39414
38989
|
*/
|
|
@@ -39417,15 +38992,14 @@ function resolveItemNameEn(input) {
|
|
|
39417
38992
|
if (fromJa !== void 0) return fromJa;
|
|
39418
38993
|
if (itemNameResolver.hasEnglishName(input)) return input;
|
|
39419
38994
|
const suggestions = itemNameResolver.suggestSimilar(input);
|
|
39420
|
-
|
|
39421
|
-
throw new Error(`持ち物「${input}」が見つかりません。${suggestionMessage}`);
|
|
38995
|
+
throw new UserFacingError(`持ち物「${input}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
39422
38996
|
}
|
|
39423
38997
|
function registerItemInfoTool(server) {
|
|
39424
|
-
server.tool(TOOL_NAME$
|
|
38998
|
+
server.tool(TOOL_NAME$14, TOOL_DESCRIPTION$14, inputSchema$11, async (args) => {
|
|
39425
38999
|
try {
|
|
39426
39000
|
const itemId = toDataId(resolveItemNameEn(args.name));
|
|
39427
39001
|
const entry = itemsById.get(itemId);
|
|
39428
|
-
if (entry === void 0) throw new
|
|
39002
|
+
if (entry === void 0) throw new UserFacingError(`持ち物「${args.name}」はチャンピオンズでは使用できません。`);
|
|
39429
39003
|
const isMegaStone = entry.megaStone !== null;
|
|
39430
39004
|
const output = {
|
|
39431
39005
|
name: entry.name,
|
|
@@ -39441,21 +39015,14 @@ function registerItemInfoTool(server) {
|
|
|
39441
39015
|
text: JSON.stringify(output)
|
|
39442
39016
|
});
|
|
39443
39017
|
} catch (error) {
|
|
39444
|
-
|
|
39445
|
-
return {
|
|
39446
|
-
content: [{
|
|
39447
|
-
type: "text",
|
|
39448
|
-
text: JSON.stringify({ error: message })
|
|
39449
|
-
}],
|
|
39450
|
-
isError: true
|
|
39451
|
-
};
|
|
39018
|
+
return toErrorResponse(error);
|
|
39452
39019
|
}
|
|
39453
39020
|
});
|
|
39454
39021
|
}
|
|
39455
39022
|
// src/tools/info/learnset.ts
|
|
39456
|
-
const TOOL_NAME$
|
|
39457
|
-
const TOOL_DESCRIPTION$
|
|
39458
|
-
const inputSchema$
|
|
39023
|
+
const TOOL_NAME$13 = "get_learnset";
|
|
39024
|
+
const TOOL_DESCRIPTION$13 = "ポケモンチャンピオンズで特定のポケモンが覚える技の一覧を取得する。「○○は何を覚える?」のようにポケモン名と覚える技が話題に出たら、知識ベースで即答せず、まずこのツールを呼んでデータを引くこと(チャンピオンズ固有の技プール変更=没収技等が反映される)。パーティ構築や技構成の検討に使用する。";
|
|
39025
|
+
const inputSchema$10 = { name: nameInputSchema.describe("ポケモン名(日本語 or 英語)") };
|
|
39459
39026
|
/**
|
|
39460
39027
|
* ポケモン名を英語に解決する。日本語名・英語名どちらでも受け付ける。
|
|
39461
39028
|
*/
|
|
@@ -39464,8 +39031,7 @@ function resolvePokemonNameEn(input) {
|
|
|
39464
39031
|
if (fromJa !== void 0) return fromJa;
|
|
39465
39032
|
if (pokemonNameResolver.hasEnglishName(input)) return input;
|
|
39466
39033
|
const suggestions = pokemonNameResolver.suggestSimilar(input);
|
|
39467
|
-
|
|
39468
|
-
throw new Error(`ポケモン「${input}」が見つかりません。${suggestionMessage}`);
|
|
39034
|
+
throw new UserFacingError(`ポケモン「${input}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
39469
39035
|
}
|
|
39470
39036
|
/**
|
|
39471
39037
|
* 技 ID から出力用の英語名・日本語名ペアを組み立てる。
|
|
@@ -39483,12 +39049,12 @@ function buildLearnsetMoveEntry(moveId) {
|
|
|
39483
39049
|
};
|
|
39484
39050
|
}
|
|
39485
39051
|
function registerLearnsetTool(server) {
|
|
39486
|
-
server.tool(TOOL_NAME$
|
|
39052
|
+
server.tool(TOOL_NAME$13, TOOL_DESCRIPTION$13, inputSchema$10, async (args) => {
|
|
39487
39053
|
try {
|
|
39488
39054
|
const englishName = resolvePokemonNameEn(args.name);
|
|
39489
39055
|
const pokemonId = toDataId(englishName);
|
|
39490
39056
|
const moveIds = championsLearnsets[pokemonId];
|
|
39491
|
-
if (moveIds === void 0) throw new
|
|
39057
|
+
if (moveIds === void 0) throw new UserFacingError(`ポケモン「${args.name}」のチャンピオンズ向け learnset データが見つかりません。`);
|
|
39492
39058
|
const output = {
|
|
39493
39059
|
pokemon: englishName,
|
|
39494
39060
|
pokemonJa: pokemonNameResolver.toJapanese(englishName) ?? null,
|
|
@@ -39499,14 +39065,7 @@ function registerLearnsetTool(server) {
|
|
|
39499
39065
|
text: JSON.stringify(output)
|
|
39500
39066
|
});
|
|
39501
39067
|
} catch (error) {
|
|
39502
|
-
|
|
39503
|
-
return {
|
|
39504
|
-
content: [{
|
|
39505
|
-
type: "text",
|
|
39506
|
-
text: JSON.stringify({ error: message })
|
|
39507
|
-
}],
|
|
39508
|
-
isError: true
|
|
39509
|
-
};
|
|
39068
|
+
return toErrorResponse(error);
|
|
39510
39069
|
}
|
|
39511
39070
|
});
|
|
39512
39071
|
}
|
|
@@ -39520,8 +39079,8 @@ function candidateMoveIds(resolvedName, moves) {
|
|
|
39520
39079
|
return [...learnsetProvider.getMoveIds(resolvedName)];
|
|
39521
39080
|
}
|
|
39522
39081
|
// src/tools/analysis/matchup.ts
|
|
39523
|
-
const TOOL_NAME$
|
|
39524
|
-
const TOOL_DESCRIPTION$
|
|
39082
|
+
const TOOL_NAME$12 = "analyze_matchup";
|
|
39083
|
+
const TOOL_DESCRIPTION$12 = "ポケモン2体の対面を分析する。双方向のダメージ計算と素早さ比較を行い、どちらが有利かを判断するためのデータを提供する。ポケモン対戦の対面判断に使用する。技ごとの結果はタイプ・相性・ダメージ割合・確定数の要約で、乱数の内訳は含まない。計算条件の説明文は最大打点の技にだけ付く。1 技の詳しい結果は calculate_damage_single で確認する。pokemon1Faster は静的な素早さ実数値のみの比較のため、素早さ負けでも先制技で逆転できる判断は pokemon{1,2}PriorityMoves を併用すること。正確な計算のため双方の ability / item の指定を推奨(省略時は通常特性・持ち物なし扱い)。";
|
|
39525
39084
|
const matchupInputSchema = {
|
|
39526
39085
|
pokemon1: pokemonWithMovesSchema.describe("ポケモン1"),
|
|
39527
39086
|
pokemon2: pokemonWithMovesSchema.describe("ポケモン2"),
|
|
@@ -39554,9 +39113,14 @@ function maxTypeMultiplier$1(attackerTypes, defenderTypes, gen) {
|
|
|
39554
39113
|
}
|
|
39555
39114
|
return max;
|
|
39556
39115
|
}
|
|
39557
|
-
function registerMatchupTool(server) {
|
|
39558
|
-
server.tool(TOOL_NAME$
|
|
39116
|
+
function registerMatchupTool(server, movesRequirement = MOVES_OPTIONAL) {
|
|
39117
|
+
server.tool(TOOL_NAME$12, TOOL_DESCRIPTION$12, matchupInputSchema, async (args) => {
|
|
39559
39118
|
try {
|
|
39119
|
+
assertMovesSpecified(movesRequirement, [{
|
|
39120
|
+
field: "pokemon1",
|
|
39121
|
+
name: args.pokemon1.name,
|
|
39122
|
+
moves: args.pokemon1.moves
|
|
39123
|
+
}]);
|
|
39560
39124
|
const { pokemon: p1, resolvedName: name1 } = damageCalculator.createPokemonObject(args.pokemon1);
|
|
39561
39125
|
const { pokemon: p2, resolvedName: name2 } = damageCalculator.createPokemonObject(args.pokemon2);
|
|
39562
39126
|
const nameJa1 = pokemonNameResolver.toJapanese(name1) ?? name1;
|
|
@@ -39599,21 +39163,14 @@ function registerMatchupTool(server) {
|
|
|
39599
39163
|
text: JSON.stringify(output)
|
|
39600
39164
|
});
|
|
39601
39165
|
} catch (error) {
|
|
39602
|
-
|
|
39603
|
-
return {
|
|
39604
|
-
content: [{
|
|
39605
|
-
type: "text",
|
|
39606
|
-
text: JSON.stringify({ error: message })
|
|
39607
|
-
}],
|
|
39608
|
-
isError: true
|
|
39609
|
-
};
|
|
39166
|
+
return toErrorResponse(error);
|
|
39610
39167
|
}
|
|
39611
39168
|
});
|
|
39612
39169
|
}
|
|
39613
39170
|
// src/tools/info/move-info.ts
|
|
39614
|
-
const TOOL_NAME$
|
|
39615
|
-
const TOOL_DESCRIPTION$
|
|
39616
|
-
const inputSchema$
|
|
39171
|
+
const TOOL_NAME$11 = "get_move_info";
|
|
39172
|
+
const TOOL_DESCRIPTION$11 = "ポケモンの技の詳細情報(タイプ・威力・命中率・分類・優先度・効果説明)を取得する。対戦で使う技の仕様を確認したいときに使用する。ポケモンチャンピオンズ対応。";
|
|
39173
|
+
const inputSchema$9 = { name: nameInputSchema.describe("技名(日本語 or 英語)") };
|
|
39617
39174
|
/**
|
|
39618
39175
|
* 技名を英語に解決する。日本語名・英語名どちらでも受け付ける。
|
|
39619
39176
|
* 名前変換辞書には登録されているがチャンピオンズで使えない技の場合はエラー。
|
|
@@ -39623,8 +39180,7 @@ function resolveMoveNameEn$1(input) {
|
|
|
39623
39180
|
if (fromJa !== void 0) return fromJa;
|
|
39624
39181
|
if (moveNameResolver.hasEnglishName(input)) return input;
|
|
39625
39182
|
const suggestions = moveNameResolver.suggestSimilar(input);
|
|
39626
|
-
|
|
39627
|
-
throw new Error(`技「${input}」が見つかりません。${suggestionMessage}`);
|
|
39183
|
+
throw new UserFacingError(`技「${input}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
39628
39184
|
}
|
|
39629
39185
|
/**
|
|
39630
39186
|
* 変化技(Status)の威力は 0 だが、ユーザー側では null の方が意図が明確なので変換する。
|
|
@@ -39634,11 +39190,11 @@ function normalizeBasePower(category, basePower) {
|
|
|
39634
39190
|
return basePower;
|
|
39635
39191
|
}
|
|
39636
39192
|
function registerMoveInfoTool(server) {
|
|
39637
|
-
server.tool(TOOL_NAME$
|
|
39193
|
+
server.tool(TOOL_NAME$11, TOOL_DESCRIPTION$11, inputSchema$9, async (args) => {
|
|
39638
39194
|
try {
|
|
39639
39195
|
const moveId = toDataId(resolveMoveNameEn$1(args.name));
|
|
39640
39196
|
const entry = movesById.get(moveId);
|
|
39641
|
-
if (entry === void 0) throw new
|
|
39197
|
+
if (entry === void 0) throw new UserFacingError(`技「${args.name}」はチャンピオンズでは使用できません。`);
|
|
39642
39198
|
const output = {
|
|
39643
39199
|
name: entry.name,
|
|
39644
39200
|
nameJa: entry.nameJa,
|
|
@@ -39659,21 +39215,14 @@ function registerMoveInfoTool(server) {
|
|
|
39659
39215
|
text: JSON.stringify(output)
|
|
39660
39216
|
});
|
|
39661
39217
|
} catch (error) {
|
|
39662
|
-
|
|
39663
|
-
return {
|
|
39664
|
-
content: [{
|
|
39665
|
-
type: "text",
|
|
39666
|
-
text: JSON.stringify({ error: message })
|
|
39667
|
-
}],
|
|
39668
|
-
isError: true
|
|
39669
|
-
};
|
|
39218
|
+
return toErrorResponse(error);
|
|
39670
39219
|
}
|
|
39671
39220
|
});
|
|
39672
39221
|
}
|
|
39673
39222
|
// src/tools/info/nature-info.ts
|
|
39674
|
-
const TOOL_NAME$
|
|
39675
|
-
const TOOL_DESCRIPTION$
|
|
39676
|
-
const inputSchema$
|
|
39223
|
+
const TOOL_NAME$10 = "get_nature_info";
|
|
39224
|
+
const TOOL_DESCRIPTION$10 = "ポケモンの性格の詳細情報(上昇ステ・下降ステ)を取得する。育成方針の検討や性格選びに使用する。plus/minus が null の性格は無補正。ポケモンチャンピオンズ対応。";
|
|
39225
|
+
const inputSchema$8 = { name: nameInputSchema.describe("性格名(日本語 or 英語、例: 'ひかえめ'、'Modest')") };
|
|
39677
39226
|
/**
|
|
39678
39227
|
* 性格名を英語に解決する。日本語名・英語名どちらでも受け付ける。
|
|
39679
39228
|
*/
|
|
@@ -39682,15 +39231,14 @@ function resolveNatureNameEn(input) {
|
|
|
39682
39231
|
if (fromJa !== void 0) return fromJa;
|
|
39683
39232
|
if (natureNameResolver.hasEnglishName(input)) return input;
|
|
39684
39233
|
const suggestions = natureNameResolver.suggestSimilar(input);
|
|
39685
|
-
|
|
39686
|
-
throw new Error(`性格「${input}」が見つかりません。${suggestionMessage}`);
|
|
39234
|
+
throw new UserFacingError(`性格「${input}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
39687
39235
|
}
|
|
39688
39236
|
function registerNatureInfoTool(server) {
|
|
39689
|
-
server.tool(TOOL_NAME$
|
|
39237
|
+
server.tool(TOOL_NAME$10, TOOL_DESCRIPTION$10, inputSchema$8, async (args) => {
|
|
39690
39238
|
try {
|
|
39691
39239
|
const englishName = resolveNatureNameEn(args.name);
|
|
39692
39240
|
const entry = naturesById.get(toDataId(englishName));
|
|
39693
|
-
if (entry === void 0) throw new
|
|
39241
|
+
if (entry === void 0) throw new UserFacingError(`性格「${args.name}」はチャンピオンズでは使用できません。`);
|
|
39694
39242
|
const output = {
|
|
39695
39243
|
name: entry.name,
|
|
39696
39244
|
nameJa: entry.nameJa,
|
|
@@ -39702,22 +39250,15 @@ function registerNatureInfoTool(server) {
|
|
|
39702
39250
|
text: JSON.stringify(output)
|
|
39703
39251
|
});
|
|
39704
39252
|
} catch (error) {
|
|
39705
|
-
|
|
39706
|
-
return {
|
|
39707
|
-
content: [{
|
|
39708
|
-
type: "text",
|
|
39709
|
-
text: JSON.stringify({ error: message })
|
|
39710
|
-
}],
|
|
39711
|
-
isError: true
|
|
39712
|
-
};
|
|
39253
|
+
return toErrorResponse(error);
|
|
39713
39254
|
}
|
|
39714
39255
|
});
|
|
39715
39256
|
}
|
|
39716
39257
|
// src/tools/analysis/party-analysis.ts
|
|
39717
39258
|
const CHAMPIONS_GEN_NUM$6 = 0;
|
|
39718
|
-
const TOOL_NAME$
|
|
39719
|
-
const TOOL_DESCRIPTION$
|
|
39720
|
-
const partyAnalysisInputSchema = { party: z.array(pokemonSchema).describe("パーティメンバー") };
|
|
39259
|
+
const TOOL_NAME$9 = "analyze_party_weakness";
|
|
39260
|
+
const TOOL_DESCRIPTION$9 = "パーティ各メンバーのタイプ相性データを集計する。どのタイプが何匹の弱点か(teamWeaknesses)、どのタイプに抜群を取れないか(uncoveredTypes)を返す。致命性の判断は AI が文脈で行う前提。ポケモンチャンピオンズ対応。";
|
|
39261
|
+
const partyAnalysisInputSchema = { party: z.array(pokemonSchema).min(1).max(6).describe("パーティメンバー") };
|
|
39721
39262
|
/** ???タイプは計算対象から除外するためのマーカー */
|
|
39722
39263
|
const UNKNOWN_TYPE_NAME = "???";
|
|
39723
39264
|
/**
|
|
@@ -39728,8 +39269,7 @@ function resolvePokemonName$2(name) {
|
|
|
39728
39269
|
if (englishName !== void 0) return englishName;
|
|
39729
39270
|
if (pokemonNameResolver.hasEnglishName(name)) return name;
|
|
39730
39271
|
const suggestions = pokemonNameResolver.suggestSimilar(name);
|
|
39731
|
-
|
|
39732
|
-
throw new Error(`ポケモン「${name}」が見つかりません。${suggestionMessage}`);
|
|
39272
|
+
throw new UserFacingError(`ポケモン「${name}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
39733
39273
|
}
|
|
39734
39274
|
/**
|
|
39735
39275
|
* 日本語・英語のどちらの名前でも英語名に解決する。
|
|
@@ -39763,7 +39303,7 @@ function findUncoveredTypes(memberTypes, gen) {
|
|
|
39763
39303
|
return uncovered;
|
|
39764
39304
|
}
|
|
39765
39305
|
function registerPartyAnalysisTool(server) {
|
|
39766
|
-
server.tool(TOOL_NAME$
|
|
39306
|
+
server.tool(TOOL_NAME$9, TOOL_DESCRIPTION$9, partyAnalysisInputSchema, async (args) => {
|
|
39767
39307
|
try {
|
|
39768
39308
|
const gen = Generations.get(CHAMPIONS_GEN_NUM$6);
|
|
39769
39309
|
const members = [];
|
|
@@ -39772,7 +39312,7 @@ function registerPartyAnalysisTool(server) {
|
|
|
39772
39312
|
for (const member of args.party) {
|
|
39773
39313
|
const nameEn = resolvePokemonName$2(member.name);
|
|
39774
39314
|
const entry = pokemonById.get(toDataId(nameEn));
|
|
39775
|
-
if (entry === void 0) throw new
|
|
39315
|
+
if (entry === void 0) throw new UserFacingError(`ポケモン「${member.name}」のデータが見つかりません。`);
|
|
39776
39316
|
const nameJa = entry.nameJa ?? entry.name;
|
|
39777
39317
|
const types = [...entry.types];
|
|
39778
39318
|
memberTypesList.push(types);
|
|
@@ -39803,124 +39343,6 @@ function registerPartyAnalysisTool(server) {
|
|
|
39803
39343
|
type: "text",
|
|
39804
39344
|
text: JSON.stringify(output)
|
|
39805
39345
|
});
|
|
39806
|
-
} catch (error) {
|
|
39807
|
-
const message = error instanceof Error ? error.message : "不明なエラーが発生しました";
|
|
39808
|
-
return {
|
|
39809
|
-
content: [{
|
|
39810
|
-
type: "text",
|
|
39811
|
-
text: JSON.stringify({ error: message })
|
|
39812
|
-
}],
|
|
39813
|
-
isError: true
|
|
39814
|
-
};
|
|
39815
|
-
}
|
|
39816
|
-
});
|
|
39817
|
-
}
|
|
39818
|
-
// src/tools/party/party-tools.ts
|
|
39819
|
-
const SAVE_TOOL_NAME = "save_party";
|
|
39820
|
-
const SAVE_TOOL_DESCRIPTION = "パーティを保存する (upsert)。同名のパーティが既に存在する場合は上書きされる。createdAt は新規時のみ現在時刻が記録され、同名上書きの場合は保持される。updatedAt は毎回現在時刻に更新される。";
|
|
39821
|
-
const LOAD_TOOL_NAME = "load_party";
|
|
39822
|
-
const LOAD_TOOL_DESCRIPTION = "保存済みパーティを name 指定で 1 件取得する。存在しない場合はエラーを返す。";
|
|
39823
|
-
const LIST_TOOL_NAME = "list_parties";
|
|
39824
|
-
const LIST_TOOL_DESCRIPTION = "保存済みパーティの一覧 (サマリ) を返す。各要素は { name, memo, updatedAt, memberCount } のみで、メンバー詳細は含まない。詳細は load_party を使用する。";
|
|
39825
|
-
const DELETE_TOOL_NAME = "delete_party";
|
|
39826
|
-
const DELETE_TOOL_DESCRIPTION = "保存済みパーティを name 指定で削除する。存在しない場合はエラーを返す。";
|
|
39827
|
-
const defaultNowProvider = () => /* @__PURE__ */ new Date();
|
|
39828
|
-
const defaultStoreIO = {
|
|
39829
|
-
load: () => loadPartiesFile(),
|
|
39830
|
-
save: (data) => savePartiesFile(data)
|
|
39831
|
-
};
|
|
39832
|
-
const nameField = z.string().min(1, { message: "名前は 1 文字以上で指定してください。" }).max(100, { message: `名前は 100 文字以下で指定してください。` });
|
|
39833
|
-
const partyMemberInputSchema = z.object({
|
|
39834
|
-
name: nameField.describe("ポケモン名 (日本語 or 英語)。"),
|
|
39835
|
-
nature: nameField.optional().describe("性格名 (日本語 or 英語)。"),
|
|
39836
|
-
ability: nameField.optional().describe("特性名 (日本語 or 英語)。"),
|
|
39837
|
-
item: nameField.optional().describe("持ち物名 (日本語 or 英語)。"),
|
|
39838
|
-
evs: evsSchema.optional().describe("能力ポイント (SP) 配分。"),
|
|
39839
|
-
moves: z.array(nameField).max(4, { message: `技は 4 個までです。` }).optional().describe("技リスト (最大 4)。")
|
|
39840
|
-
}).describe("パーティメンバー 1 匹分のビルド情報。");
|
|
39841
|
-
const partyNameField = z.string().min(1, { message: "パーティ名は 1 文字以上で指定してください。" }).max(50, { message: `パーティ名は 50 文字以下で指定してください。` });
|
|
39842
|
-
const saveInputSchema = {
|
|
39843
|
-
name: partyNameField.describe("パーティの識別子 (同名は上書き)。"),
|
|
39844
|
-
memo: z.string().max(MAX_PARTY_MEMO_LENGTH, { message: `メモは ${MAX_PARTY_MEMO_LENGTH} 文字以下で指定してください。` }).optional().describe("自由記述メモ。"),
|
|
39845
|
-
members: z.array(partyMemberInputSchema).min(1, { message: `パーティには 1 匹以上を含めてください。` }).max(6, { message: `パーティには 6 匹までしか含められません。` }).describe("1〜6 匹のメンバー。")
|
|
39846
|
-
};
|
|
39847
|
-
const loadInputSchema = { name: partyNameField.describe("取得するパーティ名。") };
|
|
39848
|
-
const deleteInputSchema = { name: partyNameField.describe("削除するパーティ名。") };
|
|
39849
|
-
const listInputSchema = {};
|
|
39850
|
-
function toSummary(party) {
|
|
39851
|
-
const summary = {
|
|
39852
|
-
name: party.name,
|
|
39853
|
-
updatedAt: party.updatedAt,
|
|
39854
|
-
memberCount: party.members.length
|
|
39855
|
-
};
|
|
39856
|
-
if (party.memo !== void 0) summary.memo = party.memo;
|
|
39857
|
-
return summary;
|
|
39858
|
-
}
|
|
39859
|
-
/**
|
|
39860
|
-
* パーティ永続化 4 ツールをサーバーに登録する。
|
|
39861
|
-
* deps は主にテスト用。本番は省略してデフォルト (ファイル I/O + 現在時刻) を使う。
|
|
39862
|
-
*/
|
|
39863
|
-
function registerPartyTools(server, deps = {}) {
|
|
39864
|
-
const storeIO = deps.storeIO ?? defaultStoreIO;
|
|
39865
|
-
const now = deps.now ?? defaultNowProvider;
|
|
39866
|
-
server.tool(SAVE_TOOL_NAME, SAVE_TOOL_DESCRIPTION, saveInputSchema, async (args) => {
|
|
39867
|
-
try {
|
|
39868
|
-
const file = storeIO.load();
|
|
39869
|
-
const nowIso = now().toISOString();
|
|
39870
|
-
const existingIndex = file.parties.findIndex((p) => p.name === args.name);
|
|
39871
|
-
const createdAt = existingIndex >= 0 ? file.parties[existingIndex].createdAt : nowIso;
|
|
39872
|
-
const party = {
|
|
39873
|
-
name: args.name,
|
|
39874
|
-
members: args.members,
|
|
39875
|
-
createdAt,
|
|
39876
|
-
updatedAt: nowIso
|
|
39877
|
-
};
|
|
39878
|
-
if (args.memo !== void 0) party.memo = args.memo;
|
|
39879
|
-
if (existingIndex >= 0) file.parties[existingIndex] = party;
|
|
39880
|
-
else file.parties.push(party);
|
|
39881
|
-
storeIO.save({
|
|
39882
|
-
schemaVersion: 1,
|
|
39883
|
-
parties: file.parties
|
|
39884
|
-
});
|
|
39885
|
-
return toTextResponse({
|
|
39886
|
-
saved: true,
|
|
39887
|
-
overwrote: existingIndex >= 0,
|
|
39888
|
-
party,
|
|
39889
|
-
filePath: resolvePartiesFilePath()
|
|
39890
|
-
});
|
|
39891
|
-
} catch (error) {
|
|
39892
|
-
return toErrorResponse(error);
|
|
39893
|
-
}
|
|
39894
|
-
});
|
|
39895
|
-
server.tool(LOAD_TOOL_NAME, LOAD_TOOL_DESCRIPTION, loadInputSchema, async (args) => {
|
|
39896
|
-
try {
|
|
39897
|
-
const party = storeIO.load().parties.find((p) => p.name === args.name);
|
|
39898
|
-
if (party === void 0) throw new Error(`パーティ「${args.name}」が見つかりません。list_parties で一覧を確認してください。`);
|
|
39899
|
-
return toTextResponse({ party });
|
|
39900
|
-
} catch (error) {
|
|
39901
|
-
return toErrorResponse(error);
|
|
39902
|
-
}
|
|
39903
|
-
});
|
|
39904
|
-
server.tool(LIST_TOOL_NAME, LIST_TOOL_DESCRIPTION, listInputSchema, async () => {
|
|
39905
|
-
try {
|
|
39906
|
-
return toTextResponse({ parties: storeIO.load().parties.map(toSummary) });
|
|
39907
|
-
} catch (error) {
|
|
39908
|
-
return toErrorResponse(error);
|
|
39909
|
-
}
|
|
39910
|
-
});
|
|
39911
|
-
server.tool(DELETE_TOOL_NAME, DELETE_TOOL_DESCRIPTION, deleteInputSchema, async (args) => {
|
|
39912
|
-
try {
|
|
39913
|
-
const file = storeIO.load();
|
|
39914
|
-
const nextParties = file.parties.filter((p) => p.name !== args.name);
|
|
39915
|
-
if (nextParties.length === file.parties.length) throw new Error(`パーティ「${args.name}」が見つかりません。`);
|
|
39916
|
-
storeIO.save({
|
|
39917
|
-
schemaVersion: 1,
|
|
39918
|
-
parties: nextParties
|
|
39919
|
-
});
|
|
39920
|
-
return toTextResponse({
|
|
39921
|
-
deleted: true,
|
|
39922
|
-
name: args.name
|
|
39923
|
-
});
|
|
39924
39346
|
} catch (error) {
|
|
39925
39347
|
return toErrorResponse(error);
|
|
39926
39348
|
}
|
|
@@ -39977,8 +39399,7 @@ function resolvePokemonName$1(name) {
|
|
|
39977
39399
|
if (englishName !== void 0) return englishName;
|
|
39978
39400
|
if (pokemonNameResolver.hasEnglishName(name)) return name;
|
|
39979
39401
|
const suggestions = pokemonNameResolver.suggestSimilar(name);
|
|
39980
|
-
|
|
39981
|
-
throw new Error(`ポケモン「${name}」が見つかりません。${suggestionMessage}`);
|
|
39402
|
+
throw new UserFacingError(`ポケモン「${name}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
39982
39403
|
}
|
|
39983
39404
|
/**
|
|
39984
39405
|
* 種族値の合計を計算する。
|
|
@@ -40015,35 +39436,22 @@ function buildPokemonInfoResult(entry) {
|
|
|
40015
39436
|
return result;
|
|
40016
39437
|
}
|
|
40017
39438
|
function registerPokemonInfoTools(server) {
|
|
40018
|
-
server.tool(GET_POKEMON_INFO_TOOL_NAME, GET_POKEMON_INFO_DESCRIPTION, { name:
|
|
39439
|
+
server.tool(GET_POKEMON_INFO_TOOL_NAME, GET_POKEMON_INFO_DESCRIPTION, { name: nameInputSchema.describe("ポケモン名(日本語 or 英語)") }, async (args) => {
|
|
40019
39440
|
try {
|
|
40020
39441
|
const englishName = resolvePokemonName$1(args.name);
|
|
40021
39442
|
const entry = pokemonById.get(toDataId(englishName));
|
|
40022
|
-
if (entry === void 0)
|
|
40023
|
-
content: [{
|
|
40024
|
-
type: "text",
|
|
40025
|
-
text: JSON.stringify({ error: `ポケモン「${args.name}」のデータが見つかりません。` })
|
|
40026
|
-
}],
|
|
40027
|
-
isError: true
|
|
40028
|
-
};
|
|
39443
|
+
if (entry === void 0) throw new UserFacingError(`ポケモン「${args.name}」のデータが見つかりません。`);
|
|
40029
39444
|
const result = buildPokemonInfoResult(entry);
|
|
40030
39445
|
return withHint({
|
|
40031
39446
|
type: "text",
|
|
40032
39447
|
text: JSON.stringify(result)
|
|
40033
39448
|
});
|
|
40034
39449
|
} catch (error) {
|
|
40035
|
-
|
|
40036
|
-
return {
|
|
40037
|
-
content: [{
|
|
40038
|
-
type: "text",
|
|
40039
|
-
text: JSON.stringify({ error: message })
|
|
40040
|
-
}],
|
|
40041
|
-
isError: true
|
|
40042
|
-
};
|
|
39450
|
+
return toErrorResponse(error);
|
|
40043
39451
|
}
|
|
40044
39452
|
});
|
|
40045
39453
|
server.tool(SEARCH_POKEMON_TOOL_NAME, SEARCH_POKEMON_DESCRIPTION, {
|
|
40046
|
-
type:
|
|
39454
|
+
type: nameInputSchema.optional().describe("タイプで絞り込み(例: 'ほのお'、'Fire')"),
|
|
40047
39455
|
minStat: z.object({
|
|
40048
39456
|
hp: z.number().optional(),
|
|
40049
39457
|
atk: z.number().optional(),
|
|
@@ -40059,13 +39467,7 @@ function registerPokemonInfoTools(server) {
|
|
|
40059
39467
|
let typeFilterEn;
|
|
40060
39468
|
if (args.type !== void 0) {
|
|
40061
39469
|
typeFilterEn = resolveTypeName(args.type);
|
|
40062
|
-
if (typeFilterEn === void 0)
|
|
40063
|
-
content: [{
|
|
40064
|
-
type: "text",
|
|
40065
|
-
text: JSON.stringify({ error: `タイプ「${args.type}」が見つかりません。` })
|
|
40066
|
-
}],
|
|
40067
|
-
isError: true
|
|
40068
|
-
};
|
|
39470
|
+
if (typeFilterEn === void 0) throw new UserFacingError(`タイプ「${args.type}」が見つかりません。`);
|
|
40069
39471
|
}
|
|
40070
39472
|
const results = [];
|
|
40071
39473
|
for (const entry of championsPokemon) {
|
|
@@ -40088,14 +39490,7 @@ function registerPokemonInfoTools(server) {
|
|
|
40088
39490
|
text: JSON.stringify(results)
|
|
40089
39491
|
});
|
|
40090
39492
|
} catch (error) {
|
|
40091
|
-
|
|
40092
|
-
return {
|
|
40093
|
-
content: [{
|
|
40094
|
-
type: "text",
|
|
40095
|
-
text: JSON.stringify({ error: message })
|
|
40096
|
-
}],
|
|
40097
|
-
isError: true
|
|
40098
|
-
};
|
|
39493
|
+
return toErrorResponse(error);
|
|
40099
39494
|
}
|
|
40100
39495
|
});
|
|
40101
39496
|
}
|
|
@@ -40109,9 +39504,9 @@ const WEAKNESS_MIN = 1;
|
|
|
40109
39504
|
const IMMUNITY_MULTIPLIER$1 = 0;
|
|
40110
39505
|
/** Status 技の category 値 */
|
|
40111
39506
|
const STATUS_CATEGORY$1 = "Status";
|
|
40112
|
-
const TOOL_NAME$
|
|
40113
|
-
const TOOL_DESCRIPTION$
|
|
40114
|
-
const inputSchema$
|
|
39507
|
+
const TOOL_NAME$8 = "get_pokemon_summary";
|
|
39508
|
+
const TOOL_DESCRIPTION$8 = "ポケモンの総合プロファイル(基本情報・防御相性・覚える技の集計・実数値)を一度に取得する。ユーザー発話にポケモン名が出てきて詳細な分析や役割評価が必要な場合は、知識ベースで即答せず、まずこのツールを呼んでデータを引くこと。対戦での役割把握や初期分析に使用する。ポケモンチャンピオンズ対応。";
|
|
39509
|
+
const inputSchema$7 = { name: nameInputSchema.describe("ポケモン名(日本語 or 英語)") };
|
|
40115
39510
|
/**
|
|
40116
39511
|
* ポケモン名を pokemon.json のエントリに解決する。
|
|
40117
39512
|
*/
|
|
@@ -40119,11 +39514,10 @@ function resolvePokemonEntry$1(name) {
|
|
|
40119
39514
|
const englishName = pokemonNameResolver.toEnglish(name) ?? (pokemonNameResolver.hasEnglishName(name) ? name : null);
|
|
40120
39515
|
if (englishName === null) {
|
|
40121
39516
|
const suggestions = pokemonNameResolver.suggestSimilar(name);
|
|
40122
|
-
|
|
40123
|
-
throw new Error(`ポケモン「${name}」が見つかりません。${suggestionMessage}`);
|
|
39517
|
+
throw new UserFacingError(`ポケモン「${name}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
40124
39518
|
}
|
|
40125
39519
|
const entry = pokemonById.get(toDataId(englishName));
|
|
40126
|
-
if (entry === void 0) throw new
|
|
39520
|
+
if (entry === void 0) throw new UserFacingError(`ポケモン「${name}」のデータが見つかりません。`);
|
|
40127
39521
|
return entry;
|
|
40128
39522
|
}
|
|
40129
39523
|
/**
|
|
@@ -40273,7 +39667,7 @@ function buildBasicProfile(entry, typeJaMap) {
|
|
|
40273
39667
|
};
|
|
40274
39668
|
}
|
|
40275
39669
|
function registerPokemonSummaryTool(server) {
|
|
40276
|
-
server.tool(TOOL_NAME$
|
|
39670
|
+
server.tool(TOOL_NAME$8, TOOL_DESCRIPTION$8, inputSchema$7, async (args) => {
|
|
40277
39671
|
try {
|
|
40278
39672
|
const entry = resolvePokemonEntry$1(args.name);
|
|
40279
39673
|
const gen = Generations.get(CHAMPIONS_GEN_NUM$5);
|
|
@@ -40289,21 +39683,14 @@ function registerPokemonSummaryTool(server) {
|
|
|
40289
39683
|
text: JSON.stringify(output)
|
|
40290
39684
|
});
|
|
40291
39685
|
} catch (error) {
|
|
40292
|
-
|
|
40293
|
-
return {
|
|
40294
|
-
content: [{
|
|
40295
|
-
type: "text",
|
|
40296
|
-
text: JSON.stringify({ error: message })
|
|
40297
|
-
}],
|
|
40298
|
-
isError: true
|
|
40299
|
-
};
|
|
39686
|
+
return toErrorResponse(error);
|
|
40300
39687
|
}
|
|
40301
39688
|
});
|
|
40302
39689
|
}
|
|
40303
39690
|
// src/tools/search/search-by-ability.ts
|
|
40304
|
-
const TOOL_NAME$
|
|
40305
|
-
const TOOL_DESCRIPTION$
|
|
40306
|
-
const inputSchema$
|
|
39691
|
+
const TOOL_NAME$7 = "search_pokemon_by_ability";
|
|
39692
|
+
const TOOL_DESCRIPTION$7 = "特定の特性を持つポケモンを逆引き検索する。いかく・もうか等の特性を持つポケモンを絞り込みたい場合に使用する。ポケモンチャンピオンズ対応。";
|
|
39693
|
+
const inputSchema$6 = { abilityName: nameInputSchema.describe("特性名(日本語 or 英語)") };
|
|
40307
39694
|
/**
|
|
40308
39695
|
* 特性名を英語に解決する。日本語名・英語名どちらも受け付ける。
|
|
40309
39696
|
*/
|
|
@@ -40312,15 +39699,14 @@ function resolveAbilityNameEn(input) {
|
|
|
40312
39699
|
if (fromJa !== void 0) return fromJa;
|
|
40313
39700
|
if (abilityNameResolver.hasEnglishName(input)) return input;
|
|
40314
39701
|
const suggestions = abilityNameResolver.suggestSimilar(input);
|
|
40315
|
-
|
|
40316
|
-
throw new Error(`特性「${input}」が見つかりません。${suggestionMessage}`);
|
|
39702
|
+
throw new UserFacingError(`特性「${input}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
40317
39703
|
}
|
|
40318
39704
|
function registerSearchByAbilityTool(server) {
|
|
40319
|
-
server.tool(TOOL_NAME$
|
|
39705
|
+
server.tool(TOOL_NAME$7, TOOL_DESCRIPTION$7, inputSchema$6, async (args) => {
|
|
40320
39706
|
try {
|
|
40321
39707
|
const abilityId = toDataId(resolveAbilityNameEn(args.abilityName));
|
|
40322
39708
|
const abilityEntry = abilitiesById.get(abilityId);
|
|
40323
|
-
if (abilityEntry === void 0) throw new
|
|
39709
|
+
if (abilityEntry === void 0) throw new UserFacingError(`特性「${args.abilityName}」はチャンピオンズでは使用できません。`);
|
|
40324
39710
|
const matchedPokemon = [];
|
|
40325
39711
|
for (const entry of championsPokemon) {
|
|
40326
39712
|
if (!entry.abilities.includes(abilityEntry.name)) continue;
|
|
@@ -40347,21 +39733,14 @@ function registerSearchByAbilityTool(server) {
|
|
|
40347
39733
|
text: JSON.stringify(output)
|
|
40348
39734
|
});
|
|
40349
39735
|
} catch (error) {
|
|
40350
|
-
|
|
40351
|
-
return {
|
|
40352
|
-
content: [{
|
|
40353
|
-
type: "text",
|
|
40354
|
-
text: JSON.stringify({ error: message })
|
|
40355
|
-
}],
|
|
40356
|
-
isError: true
|
|
40357
|
-
};
|
|
39736
|
+
return toErrorResponse(error);
|
|
40358
39737
|
}
|
|
40359
39738
|
});
|
|
40360
39739
|
}
|
|
40361
39740
|
// src/tools/search/search-by-move.ts
|
|
40362
|
-
const TOOL_NAME$
|
|
40363
|
-
const TOOL_DESCRIPTION$
|
|
40364
|
-
const inputSchema$
|
|
39741
|
+
const TOOL_NAME$6 = "search_pokemon_by_move";
|
|
39742
|
+
const TOOL_DESCRIPTION$6 = "特定の技を覚えるポケモンを逆引き検索する。ステルスロックなど特定の技を覚えさせたい場合の候補ポケモン探しに使用する。ポケモンチャンピオンズ対応。";
|
|
39743
|
+
const inputSchema$5 = { moveName: nameInputSchema.describe("技名(日本語 or 英語)") };
|
|
40365
39744
|
/**
|
|
40366
39745
|
* 技名を英語に解決する。日本語名・英語名どちらも受け付ける。
|
|
40367
39746
|
* 名前辞書に存在してもチャンピオンズで使用できない技は movesById が undefined を返すのでエラー。
|
|
@@ -40371,15 +39750,14 @@ function resolveMoveNameEn(input) {
|
|
|
40371
39750
|
if (fromJa !== void 0) return fromJa;
|
|
40372
39751
|
if (moveNameResolver.hasEnglishName(input)) return input;
|
|
40373
39752
|
const suggestions = moveNameResolver.suggestSimilar(input);
|
|
40374
|
-
|
|
40375
|
-
throw new Error(`技「${input}」が見つかりません。${suggestionMessage}`);
|
|
39753
|
+
throw new UserFacingError(`技「${input}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
40376
39754
|
}
|
|
40377
39755
|
function registerSearchByMoveTool(server) {
|
|
40378
|
-
server.tool(TOOL_NAME$
|
|
39756
|
+
server.tool(TOOL_NAME$6, TOOL_DESCRIPTION$6, inputSchema$5, async (args) => {
|
|
40379
39757
|
try {
|
|
40380
39758
|
const moveId = toDataId(resolveMoveNameEn(args.moveName));
|
|
40381
39759
|
const moveEntry = movesById.get(moveId);
|
|
40382
|
-
if (moveEntry === void 0) throw new
|
|
39760
|
+
if (moveEntry === void 0) throw new UserFacingError(`技「${args.moveName}」はチャンピオンズでは使用できません。`);
|
|
40383
39761
|
const matchedPokemon = [];
|
|
40384
39762
|
for (const [pokemonId, moveIds] of Object.entries(championsLearnsets)) {
|
|
40385
39763
|
if (!moveIds.includes(moveId)) continue;
|
|
@@ -40409,14 +39787,7 @@ function registerSearchByMoveTool(server) {
|
|
|
40409
39787
|
text: JSON.stringify(output)
|
|
40410
39788
|
});
|
|
40411
39789
|
} catch (error) {
|
|
40412
|
-
|
|
40413
|
-
return {
|
|
40414
|
-
content: [{
|
|
40415
|
-
type: "text",
|
|
40416
|
-
text: JSON.stringify({ error: message })
|
|
40417
|
-
}],
|
|
40418
|
-
isError: true
|
|
40419
|
-
};
|
|
39790
|
+
return toErrorResponse(error);
|
|
40420
39791
|
}
|
|
40421
39792
|
});
|
|
40422
39793
|
}
|
|
@@ -40430,13 +39801,13 @@ const WEAKNESS_THRESHOLD = 2;
|
|
|
40430
39801
|
const IMMUNITY_MULTIPLIER = 0;
|
|
40431
39802
|
/** ステータス技を示す category 値 */
|
|
40432
39803
|
const STATUS_CATEGORY = "Status";
|
|
40433
|
-
const TOOL_NAME$
|
|
40434
|
-
const TOOL_DESCRIPTION$
|
|
40435
|
-
const inputSchema$
|
|
40436
|
-
resistsType:
|
|
40437
|
-
immuneToType:
|
|
40438
|
-
weakToType:
|
|
40439
|
-
hasAttackingType:
|
|
39804
|
+
const TOOL_NAME$5 = "search_pokemon_by_type_effectiveness";
|
|
39805
|
+
const TOOL_DESCRIPTION$5 = "タイプ相性条件でポケモンを逆引き検索する。指定タイプを半減/無効/弱点で受けるポケモンや、指定タイプの攻撃技を覚えるポケモンを絞り込める。複数条件の AND 指定が可能。対策ポケモン探しやパーティ構築に使用する。ポケモンチャンピオンズ対応。";
|
|
39806
|
+
const inputSchema$4 = {
|
|
39807
|
+
resistsType: nameInputSchema.optional().describe("指定タイプの攻撃を 0.5 倍以下で受けるポケモン(半減・無効含む)"),
|
|
39808
|
+
immuneToType: nameInputSchema.optional().describe("指定タイプの攻撃を無効化するポケモン(0 倍)"),
|
|
39809
|
+
weakToType: nameInputSchema.optional().describe("指定タイプの攻撃で 2 倍以上のダメージを受けるポケモン(4 倍含む)"),
|
|
39810
|
+
hasAttackingType: nameInputSchema.optional().describe("指定タイプの攻撃技を 1 つ以上覚えるポケモン")
|
|
40440
39811
|
};
|
|
40441
39812
|
/**
|
|
40442
39813
|
* タイプ名(日本語 or 英語)を英語名に解決する。
|
|
@@ -40446,7 +39817,7 @@ function resolveTypeNameEn$1(input) {
|
|
|
40446
39817
|
for (const entry of championsTypes) if (entry.nameJa === input) return entry.name;
|
|
40447
39818
|
const normalized = input.toLowerCase();
|
|
40448
39819
|
for (const entry of championsTypes) if (entry.id === normalized) return entry.name;
|
|
40449
|
-
throw new
|
|
39820
|
+
throw new UserFacingError(`タイプ「${input}」が見つかりません。`);
|
|
40450
39821
|
}
|
|
40451
39822
|
/**
|
|
40452
39823
|
* 攻撃タイプ名 → 防御側タイプ配列への複合倍率を算出する。
|
|
@@ -40471,9 +39842,9 @@ function hasAttackingMoveOfType(pokemonId, attackTypeEn) {
|
|
|
40471
39842
|
return false;
|
|
40472
39843
|
}
|
|
40473
39844
|
function registerSearchByTypeEffectivenessTool(server) {
|
|
40474
|
-
server.tool(TOOL_NAME$
|
|
39845
|
+
server.tool(TOOL_NAME$5, TOOL_DESCRIPTION$5, inputSchema$4, async (args) => {
|
|
40475
39846
|
try {
|
|
40476
|
-
if (!(args.resistsType !== void 0 || args.immuneToType !== void 0 || args.weakToType !== void 0 || args.hasAttackingType !== void 0)) throw new
|
|
39847
|
+
if (!(args.resistsType !== void 0 || args.immuneToType !== void 0 || args.weakToType !== void 0 || args.hasAttackingType !== void 0)) throw new UserFacingError("少なくとも 1 つの条件 (resistsType / immuneToType / weakToType / hasAttackingType) を指定してください。");
|
|
40477
39848
|
const gen = Generations.get(CHAMPIONS_GEN_NUM$4);
|
|
40478
39849
|
const resistsTypeEn = args.resistsType !== void 0 ? resolveTypeNameEn$1(args.resistsType) : null;
|
|
40479
39850
|
const immuneToTypeEn = args.immuneToType !== void 0 ? resolveTypeNameEn$1(args.immuneToType) : null;
|
|
@@ -40524,26 +39895,19 @@ function registerSearchByTypeEffectivenessTool(server) {
|
|
|
40524
39895
|
})
|
|
40525
39896
|
});
|
|
40526
39897
|
} catch (error) {
|
|
40527
|
-
|
|
40528
|
-
return {
|
|
40529
|
-
content: [{
|
|
40530
|
-
type: "text",
|
|
40531
|
-
text: JSON.stringify({ error: message })
|
|
40532
|
-
}],
|
|
40533
|
-
isError: true
|
|
40534
|
-
};
|
|
39898
|
+
return toErrorResponse(error);
|
|
40535
39899
|
}
|
|
40536
39900
|
});
|
|
40537
39901
|
}
|
|
40538
39902
|
// src/tools/analysis/selection-analysis.ts
|
|
40539
39903
|
const CHAMPIONS_GEN_NUM$3 = 0;
|
|
40540
|
-
const TOOL_NAME$
|
|
40541
|
-
const TOOL_DESCRIPTION$
|
|
40542
|
-
const inputSchema$
|
|
40543
|
-
myParty: z.array(pokemonWithMovesSchema).describe("自分のパーティ"),
|
|
40544
|
-
opponentParty: z.array(pokemonSchema).describe("相手のパーティ"),
|
|
39904
|
+
const TOOL_NAME$4 = "analyze_selection";
|
|
39905
|
+
const TOOL_DESCRIPTION$4 = "6v6 パーティ間の全対面(最大 36 エントリ)について、タイプ相性・素早さ比較・最大ダメージ見積もりをマトリクスで返す。選出判断は本ツールが返すデータを元に AI が総合的に行う前提で、ツール側では推奨やスコアリングは行わない。ポケモンチャンピオンズ対応。正確な計算のため各ポケモンの ability / item の指定を推奨(省略時は通常特性・持ち物なし扱い)。";
|
|
39906
|
+
const inputSchema$3 = {
|
|
39907
|
+
myParty: z.array(pokemonWithMovesSchema).min(1).max(6).describe("自分のパーティ"),
|
|
39908
|
+
opponentParty: z.array(pokemonSchema).min(1).max(6).describe("相手のパーティ"),
|
|
40545
39909
|
battleFormat: z.enum(["singles", "doubles"]).describe("対戦形式(シングル: singles / ダブル: doubles)"),
|
|
40546
|
-
moves:
|
|
39910
|
+
moves: movesByPokemonSchema.optional().describe("ポケモン名(日本語 or 英語)ごとに候補技を指定する。指定がなければ myParty 各メンバーの moves、それもなければ習得技すべてで計算する。")
|
|
40547
39911
|
};
|
|
40548
39912
|
/**
|
|
40549
39913
|
* 2つのポケモンタイプ配列から、攻撃側→防御側の最大抜群倍率を算出する。
|
|
@@ -40588,7 +39952,7 @@ function resolveMovesMap(moves) {
|
|
|
40588
39952
|
if (moves === void 0) return result;
|
|
40589
39953
|
for (const [pokemonName, moveList] of Object.entries(moves)) {
|
|
40590
39954
|
const englishName = pokemonNameResolver.toEnglish(pokemonName) ?? (pokemonNameResolver.hasEnglishName(pokemonName) ? pokemonName : null);
|
|
40591
|
-
if (englishName === null) throw new
|
|
39955
|
+
if (englishName === null) throw new UserFacingError(`moves に指定したポケモン「${pokemonName}」が見つかりません。`);
|
|
40592
39956
|
const id = toDataId(englishName);
|
|
40593
39957
|
result.set(id, damageCalculator.resolveMoveNames(moveList));
|
|
40594
39958
|
}
|
|
@@ -40625,8 +39989,8 @@ function calculateDamageForMatchup(damageCalculator, attacker, defender, attacke
|
|
|
40625
39989
|
conditions
|
|
40626
39990
|
});
|
|
40627
39991
|
}
|
|
40628
|
-
function registerSelectionAnalysisTool(server) {
|
|
40629
|
-
server.tool(TOOL_NAME$
|
|
39992
|
+
function registerSelectionAnalysisTool(server, movesRequirement = MOVES_OPTIONAL) {
|
|
39993
|
+
server.tool(TOOL_NAME$4, TOOL_DESCRIPTION$4, inputSchema$3, async (args) => {
|
|
40630
39994
|
try {
|
|
40631
39995
|
const gen = Generations.get(CHAMPIONS_GEN_NUM$3);
|
|
40632
39996
|
const movesMap = resolveMovesMap(args.moves);
|
|
@@ -40663,6 +40027,11 @@ function registerSelectionAnalysisTool(server) {
|
|
|
40663
40027
|
};
|
|
40664
40028
|
}
|
|
40665
40029
|
const myMembers = args.myParty.map((input) => buildMemberContext(input, movesMap));
|
|
40030
|
+
assertMovesSpecified(movesRequirement, myMembers.map((member, index) => ({
|
|
40031
|
+
field: `myParty[${index}]`,
|
|
40032
|
+
name: member.input.name,
|
|
40033
|
+
moves: explicitMovesFor(member.entryId, movesMap) ?? member.input.moves
|
|
40034
|
+
})));
|
|
40666
40035
|
const oppMembers = args.opponentParty.map((input) => buildMemberContext(input, /* @__PURE__ */ new Map()));
|
|
40667
40036
|
const matrix = [];
|
|
40668
40037
|
for (const mine of myMembers) for (const opp of oppMembers) {
|
|
@@ -40697,14 +40066,7 @@ function registerSelectionAnalysisTool(server) {
|
|
|
40697
40066
|
text: JSON.stringify(output)
|
|
40698
40067
|
});
|
|
40699
40068
|
} catch (error) {
|
|
40700
|
-
|
|
40701
|
-
return {
|
|
40702
|
-
content: [{
|
|
40703
|
-
type: "text",
|
|
40704
|
-
text: JSON.stringify({ error: message })
|
|
40705
|
-
}],
|
|
40706
|
-
isError: true
|
|
40707
|
-
};
|
|
40069
|
+
return toErrorResponse(error);
|
|
40708
40070
|
}
|
|
40709
40071
|
});
|
|
40710
40072
|
}
|
|
@@ -40716,14 +40078,14 @@ const NEUTRAL_NATURE_EN = "Serious";
|
|
|
40716
40078
|
const JOLLY_NATURE_EN = "Jolly";
|
|
40717
40079
|
/** around 指定時に参照する実数値の許容幅(±N) */
|
|
40718
40080
|
const AROUND_WINDOW = 10;
|
|
40719
|
-
const TOOL_NAME$
|
|
40720
|
-
const TOOL_DESCRIPTION$
|
|
40081
|
+
const TOOL_NAME$3 = "list_speed_tiers";
|
|
40082
|
+
const TOOL_DESCRIPTION$3 = "素早さの実数値ライン一覧を取得する。各エントリには finalSpeed(無振り無補正)・withNeutralMax(準速=無補正性格で素早さに 32 SP 振り切り)・withJollyMax(最速=補正性格で素早さに 32 SP 振り切り)の 3 列をデフォルトで含めて返す。S ライン比較や対面の先後判定では準速・最速の双方を必ずユーザーに提示すること(最速だけ示すと準速個体を取りこぼす)。さらに「○○族を抜くために spe を何 SP 振れば良いか」のような S 調整振りの提案にも本ツールを起点にすること。ポケチャンは 1 SP 単位で振れるため、ブッパ (spe 32 SP 振り切り) 一択ではなく、必要なラインを抜く最小 SP を逆算して残りを別ステに回すのが基本。around で指定ポケモン付近、range で実数値範囲を指定できる。省略時は全ポケモンを返す。ポケモンチャンピオンズ仕様(Lv50・IV31・SP 0〜32)で計算。";
|
|
40721
40083
|
const rangeSchema = z.object({
|
|
40722
40084
|
min: z.number().optional(),
|
|
40723
40085
|
max: z.number().optional()
|
|
40724
40086
|
}).optional().describe("実数値 (finalSpeed) の範囲フィルタ");
|
|
40725
|
-
const inputSchema$
|
|
40726
|
-
around:
|
|
40087
|
+
const inputSchema$2 = {
|
|
40088
|
+
around: nameInputSchema.optional().describe(`指定ポケモン付近(±${AROUND_WINDOW})の素早さラインのみを返す。`),
|
|
40727
40089
|
range: rangeSchema
|
|
40728
40090
|
};
|
|
40729
40091
|
/**
|
|
@@ -40752,15 +40114,14 @@ function resolvePokemonEntry(name) {
|
|
|
40752
40114
|
const englishName = pokemonNameResolver.toEnglish(name) ?? (pokemonNameResolver.hasEnglishName(name) ? name : null);
|
|
40753
40115
|
if (englishName === null) {
|
|
40754
40116
|
const suggestions = pokemonNameResolver.suggestSimilar(name);
|
|
40755
|
-
|
|
40756
|
-
throw new Error(`ポケモン「${name}」が見つかりません。${suggestionMessage}`);
|
|
40117
|
+
throw new UserFacingError(`ポケモン「${name}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
40757
40118
|
}
|
|
40758
40119
|
const entry = pokemonById.get(toDataId(englishName));
|
|
40759
|
-
if (entry === void 0) throw new
|
|
40120
|
+
if (entry === void 0) throw new UserFacingError(`ポケモン「${name}」のデータが見つかりません。`);
|
|
40760
40121
|
return entry;
|
|
40761
40122
|
}
|
|
40762
40123
|
function registerSpeedTiersTool(server) {
|
|
40763
|
-
server.tool(TOOL_NAME$
|
|
40124
|
+
server.tool(TOOL_NAME$3, TOOL_DESCRIPTION$3, inputSchema$2, async (args) => {
|
|
40764
40125
|
try {
|
|
40765
40126
|
const gen = Generations.get(CHAMPIONS_GEN_NUM$2);
|
|
40766
40127
|
let filtered = championsPokemon.map((entry) => {
|
|
@@ -40797,25 +40158,18 @@ function registerSpeedTiersTool(server) {
|
|
|
40797
40158
|
text: JSON.stringify({ entries: filtered })
|
|
40798
40159
|
});
|
|
40799
40160
|
} catch (error) {
|
|
40800
|
-
|
|
40801
|
-
return {
|
|
40802
|
-
content: [{
|
|
40803
|
-
type: "text",
|
|
40804
|
-
text: JSON.stringify({ error: message })
|
|
40805
|
-
}],
|
|
40806
|
-
isError: true
|
|
40807
|
-
};
|
|
40161
|
+
return toErrorResponse(error);
|
|
40808
40162
|
}
|
|
40809
40163
|
});
|
|
40810
40164
|
}
|
|
40811
40165
|
// src/tools/calc/stats-calculation.ts
|
|
40812
40166
|
const CHAMPIONS_GEN_NUM$1 = 0;
|
|
40813
40167
|
const DEFAULT_NATURE_EN = "Serious";
|
|
40814
|
-
const TOOL_NAME$
|
|
40815
|
-
const TOOL_DESCRIPTION$
|
|
40168
|
+
const TOOL_NAME$2 = "calculate_stats";
|
|
40169
|
+
const TOOL_DESCRIPTION$2 = "ポケモンの実数値を計算する。種族値・性格・能力ポイントから各ステータスの実数値を算出する。育成方針の検討や調整ラインの確認に使用する。SP 振りを提案するときは、ブッパ (各ステ 32 振り切り) を勧めるのではなく、本ツールで実数値を試算しつつ目的駆動で刻むこと(ポケチャンは 1 SP 単位で振れる / 合計上限は 66 SP / 火力調整・耐久調整・S 調整のいずれも最小限の SP で要求を満たすのが基本)。ポケモンチャンピオンズの計算式に対応。";
|
|
40816
40170
|
const statsCalcInputSchema = {
|
|
40817
|
-
name:
|
|
40818
|
-
nature:
|
|
40171
|
+
name: nameInputSchema.describe("ポケモン名(日本語 or 英語)"),
|
|
40172
|
+
nature: nameInputSchema.optional().describe("性格名(省略時: まじめ)"),
|
|
40819
40173
|
evs: evsSchema.optional().describe("能力ポイント(SP)。各ステ 0-32、合計 0-66。省略時は全 0 (無振り)。")
|
|
40820
40174
|
};
|
|
40821
40175
|
/**
|
|
@@ -40826,8 +40180,7 @@ function resolvePokemonName(name) {
|
|
|
40826
40180
|
if (englishName !== void 0) return englishName;
|
|
40827
40181
|
if (pokemonNameResolver.hasEnglishName(name)) return name;
|
|
40828
40182
|
const suggestions = pokemonNameResolver.suggestSimilar(name);
|
|
40829
|
-
|
|
40830
|
-
throw new Error(`ポケモン「${name}」が見つかりません。${suggestionMessage}`);
|
|
40183
|
+
throw new UserFacingError(`ポケモン「${name}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
40831
40184
|
}
|
|
40832
40185
|
/**
|
|
40833
40186
|
* 性格名を英語に解決する。
|
|
@@ -40838,16 +40191,15 @@ function resolveNatureName(nature) {
|
|
|
40838
40191
|
if (englishName !== void 0) return englishName;
|
|
40839
40192
|
if (natureNameResolver.hasEnglishName(nature)) return nature;
|
|
40840
40193
|
const suggestions = natureNameResolver.suggestSimilar(nature);
|
|
40841
|
-
|
|
40842
|
-
throw new Error(`性格「${nature}」が見つかりません。${suggestionMessage}`);
|
|
40194
|
+
throw new UserFacingError(`性格「${nature}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
40843
40195
|
}
|
|
40844
40196
|
function registerStatsCalculationTool(server) {
|
|
40845
|
-
server.tool(TOOL_NAME$
|
|
40197
|
+
server.tool(TOOL_NAME$2, TOOL_DESCRIPTION$2, statsCalcInputSchema, async (args) => {
|
|
40846
40198
|
try {
|
|
40847
40199
|
const gen = Generations.get(CHAMPIONS_GEN_NUM$1);
|
|
40848
40200
|
const nameEn = resolvePokemonName(args.name);
|
|
40849
40201
|
const entry = pokemonById.get(toDataId(nameEn));
|
|
40850
|
-
if (entry === void 0) throw new
|
|
40202
|
+
if (entry === void 0) throw new UserFacingError(`ポケモン「${args.name}」のデータが見つかりません。`);
|
|
40851
40203
|
const natureEn = resolveNatureName(args.nature);
|
|
40852
40204
|
const nameJa = entry.nameJa ?? entry.name;
|
|
40853
40205
|
const natureJa = natureNameResolver.toJapanese(natureEn) ?? natureEn;
|
|
@@ -40893,22 +40245,15 @@ function registerStatsCalculationTool(server) {
|
|
|
40893
40245
|
text: JSON.stringify(output)
|
|
40894
40246
|
});
|
|
40895
40247
|
} catch (error) {
|
|
40896
|
-
|
|
40897
|
-
return {
|
|
40898
|
-
content: [{
|
|
40899
|
-
type: "text",
|
|
40900
|
-
text: JSON.stringify({ error: message })
|
|
40901
|
-
}],
|
|
40902
|
-
isError: true
|
|
40903
|
-
};
|
|
40248
|
+
return toErrorResponse(error);
|
|
40904
40249
|
}
|
|
40905
40250
|
});
|
|
40906
40251
|
}
|
|
40907
40252
|
// src/tools/info/type-info.ts
|
|
40908
40253
|
const CHAMPIONS_GEN_NUM = 0;
|
|
40909
|
-
const TOOL_NAME = "get_type_info";
|
|
40910
|
-
const TOOL_DESCRIPTION = "ポケモンのタイプの相性情報(攻撃時・防御時の倍率)を取得する。対戦でタイプ相性を確認したいときに使用する。ポケモンチャンピオンズ対応。";
|
|
40911
|
-
const inputSchema = { type:
|
|
40254
|
+
const TOOL_NAME$1 = "get_type_info";
|
|
40255
|
+
const TOOL_DESCRIPTION$1 = "ポケモンのタイプの相性情報(攻撃時・防御時の倍率)を取得する。対戦でタイプ相性を確認したいときに使用する。ポケモンチャンピオンズ対応。";
|
|
40256
|
+
const inputSchema$1 = { type: nameInputSchema.describe("タイプ名(日本語 or 英語、例: 'ほのお'、'Fire')") };
|
|
40912
40257
|
/**
|
|
40913
40258
|
* タイプ名を英語に解決する。日本語名・英語名どちらでも受け付ける。
|
|
40914
40259
|
* 見つからない場合はエラーをスローする。
|
|
@@ -40918,14 +40263,14 @@ function resolveTypeNameEn(input) {
|
|
|
40918
40263
|
const normalized = input.toLowerCase();
|
|
40919
40264
|
const entry = typesById.get(normalized);
|
|
40920
40265
|
if (entry !== void 0) return entry.name;
|
|
40921
|
-
throw new
|
|
40266
|
+
throw new UserFacingError(`タイプ「${input}」が見つかりません。`);
|
|
40922
40267
|
}
|
|
40923
40268
|
function registerTypeInfoTool(server) {
|
|
40924
|
-
server.tool(TOOL_NAME, TOOL_DESCRIPTION, inputSchema, async (args) => {
|
|
40269
|
+
server.tool(TOOL_NAME$1, TOOL_DESCRIPTION$1, inputSchema$1, async (args) => {
|
|
40925
40270
|
try {
|
|
40926
40271
|
const englishName = resolveTypeNameEn(args.type);
|
|
40927
40272
|
const typeEntry = typesById.get(englishName.toLowerCase());
|
|
40928
|
-
if (typeEntry === void 0) throw new
|
|
40273
|
+
if (typeEntry === void 0) throw new UserFacingError(`タイプ「${args.type}」のデータが見つかりません。`);
|
|
40929
40274
|
const gen = Generations.get(CHAMPIONS_GEN_NUM);
|
|
40930
40275
|
const attackingTypeName = englishName;
|
|
40931
40276
|
const attackingEffectiveness = {};
|
|
@@ -40955,50 +40300,601 @@ function registerTypeInfoTool(server) {
|
|
|
40955
40300
|
text: JSON.stringify(output)
|
|
40956
40301
|
});
|
|
40957
40302
|
} catch (error) {
|
|
40958
|
-
|
|
40959
|
-
return {
|
|
40960
|
-
content: [{
|
|
40961
|
-
type: "text",
|
|
40962
|
-
text: JSON.stringify({ error: message })
|
|
40963
|
-
}],
|
|
40964
|
-
isError: true
|
|
40965
|
-
};
|
|
40303
|
+
return toErrorResponse(error);
|
|
40966
40304
|
}
|
|
40967
40305
|
});
|
|
40968
40306
|
}
|
|
40969
|
-
// src/server.ts
|
|
40307
|
+
// src/core-server.ts
|
|
40970
40308
|
const SERVER_NAME = "ai-rotom";
|
|
40971
|
-
const SERVER_VERSION = "
|
|
40972
|
-
|
|
40309
|
+
const SERVER_VERSION = "2.0.1";
|
|
40310
|
+
/**
|
|
40311
|
+
* 1 回のツール呼び出しで受け付ける引数の要素数 (配列の要素とオブジェクトのメンバーの合計) の上限。
|
|
40312
|
+
*/
|
|
40313
|
+
const MAX_TOOL_INPUT_ELEMENTS = 1e3;
|
|
40314
|
+
/**
|
|
40315
|
+
* パーティ保存系を除くツールを登録した MCP サーバーを作る。
|
|
40316
|
+
* 保存系はファイルに書き込むので、ファイルを持たない実行環境でも読み込めるよう、ここから import しない。
|
|
40317
|
+
*/
|
|
40318
|
+
function createCoreServer(instructions, movesRequirement = MOVES_OPTIONAL) {
|
|
40973
40319
|
const server = new McpServer({
|
|
40974
40320
|
name: SERVER_NAME,
|
|
40975
40321
|
version: SERVER_VERSION
|
|
40976
|
-
}, {
|
|
40322
|
+
}, {
|
|
40323
|
+
instructions,
|
|
40324
|
+
maxToolInputElements: MAX_TOOL_INPUT_ELEMENTS
|
|
40325
|
+
});
|
|
40977
40326
|
registerAbilityInfoTool(server);
|
|
40978
40327
|
registerComparePartiesTool(server);
|
|
40979
40328
|
registerConditionInfoTool(server);
|
|
40980
|
-
registerDamageCalculationTools(server);
|
|
40329
|
+
registerDamageCalculationTools(server, movesRequirement);
|
|
40981
40330
|
registerDamageRangeTool(server);
|
|
40982
|
-
registerImportPartyFromTextTool(server);
|
|
40983
40331
|
registerItemInfoTool(server);
|
|
40984
40332
|
registerLearnsetTool(server);
|
|
40985
|
-
registerMatchupTool(server);
|
|
40333
|
+
registerMatchupTool(server, movesRequirement);
|
|
40986
40334
|
registerMoveInfoTool(server);
|
|
40987
40335
|
registerNatureInfoTool(server);
|
|
40988
40336
|
registerPartyAnalysisTool(server);
|
|
40989
40337
|
registerPartyCoverageTool(server);
|
|
40990
|
-
registerPartyTools(server);
|
|
40991
40338
|
registerPokemonInfoTools(server);
|
|
40992
40339
|
registerPokemonSummaryTool(server);
|
|
40993
40340
|
registerSearchByAbilityTool(server);
|
|
40994
40341
|
registerSearchByMoveTool(server);
|
|
40995
40342
|
registerSearchByTypeEffectivenessTool(server);
|
|
40996
|
-
registerSelectionAnalysisTool(server);
|
|
40343
|
+
registerSelectionAnalysisTool(server, movesRequirement);
|
|
40997
40344
|
registerSpeedTiersTool(server);
|
|
40998
40345
|
registerStatsCalculationTool(server);
|
|
40999
40346
|
registerTypeInfoTool(server);
|
|
41000
40347
|
return server;
|
|
41001
40348
|
}
|
|
40349
|
+
const SERVER_INSTRUCTIONS = `${`
|
|
40350
|
+
ai-rotom はポケモンチャンピオンズ (Pokemon Champions) の対戦アドバイザー MCP サーバーです。
|
|
40351
|
+
|
|
40352
|
+
## セッションスコープ(重要)
|
|
40353
|
+
|
|
40354
|
+
- このセッション内でポケモン関連の話題が出た場合は、すべてポケモンチャンピオンズ (Pokemon Champions) の仕様として扱ってください。
|
|
40355
|
+
- 従来作 (SV / 剣盾 / USUM / BDSP / LA 等) の仕様・技威力・特性効果・種族値・タイプ相性などを前提にしないでください。
|
|
40356
|
+
- ポケモン名・技名・特性・持ち物・タイプ・素早さ等の固有名詞や数値がユーザー発話に出た時点で、まず本サーバーのツールを呼んで事実を取得してから回答すること。記憶や推測で即答しない (下の「ツール利用方針(必須)」を参照)。
|
|
40357
|
+
- ポケチャン固有仕様で不明な点は推測で埋めず、ユーザーに確認してください。
|
|
40358
|
+
|
|
40359
|
+
以降は、従来作と差異が出やすい代表的な固有仕様です。
|
|
40360
|
+
|
|
40361
|
+
## 能力ポイント (SP) について
|
|
40362
|
+
|
|
40363
|
+
- 従来の「努力値 (EV)」は廃止され、「能力ポイント (SP)」という仕様に変更されました。
|
|
40364
|
+
- 各ステータス (hp/atk/def/spa/spd/spe) あたりの上限: 32 SP
|
|
40365
|
+
- 全ステータス合計の上限: 66 SP
|
|
40366
|
+
- 1 SP = 実数値 +1 で直接加算されます (従来 EV の「4 EV = 実数値 +1」ではありません)。
|
|
40367
|
+
- 各ステ 0〜32、合計 0〜66 の範囲内なら振り方は自由です。
|
|
40368
|
+
- 従来の 252 EV / 510 EV 合計上限をそのまま渡すとエラーになります。
|
|
40369
|
+
|
|
40370
|
+
## SP 振りの実践(重要)
|
|
40371
|
+
|
|
40372
|
+
ポケチャンの SP は **1 単位で振れる**(各ステ 0〜32、合計 0〜66)ため、
|
|
40373
|
+
従来作流の「とりあえず最速」「とりあえず HP252」のような **ブッパ一辺倒は最適でないことが多い**。
|
|
40374
|
+
AI クライアントは目的駆動で刻む振り方を提案すること。各ステに 32 振り切るより、
|
|
40375
|
+
要求を満たす最小限を割り当てて余り SP を別の役割に回す方が、合計 66 SP の制約下では強い。
|
|
40376
|
+
|
|
40377
|
+
### 火力調整(atk / spa)
|
|
40378
|
+
- 「主要対面相手を確定 1 発(or 確定 2 発)で落とす最低限の振り」を calculate_damage_single / calculate_damage_all_moves で逆算する。
|
|
40379
|
+
- 余った SP は HP / 素早さ / 別ステに回す。
|
|
40380
|
+
|
|
40381
|
+
### 耐久調整(hp / def / spd)
|
|
40382
|
+
- 「主要対面相手の技を確定耐えする最低限の振り」を analyze_damage_range で逆算する。
|
|
40383
|
+
- 物理耐久は hp + def、特殊耐久は hp + spd の組み合わせで効率化。HP のみブッパだと無駄が出やすい。
|
|
40384
|
+
|
|
40385
|
+
### 素早さ調整(spe)— S 調整振り
|
|
40386
|
+
- 「特定ラインを抜く / 同速回避するピンポイント振り」を list_speed_tiers + calculate_stats で逆算する。
|
|
40387
|
+
- 例: 準速 100 族(実数値 152)を抜きたいだけなら spe を 32 振り切る必要はなく、必要最小限の SP で抜ける。
|
|
40388
|
+
- 同速回避は相手と同じ振りに対し +1 SP 多く振る。
|
|
40389
|
+
|
|
40390
|
+
### 提案フローのテンプレート
|
|
40391
|
+
1. ユーザーに役割(耐久型 / 火力型 / 削り役 / サポート 等)と主要対面相手 2-3 体を確認する。
|
|
40392
|
+
2. 火力 / 耐久 / 素早さの要求 SP を、対面相手ごとに計算ツールで逆算する。
|
|
40393
|
+
3. 合計 66 SP の制約内で配分案を提示する(複数案あれば併記)。
|
|
40394
|
+
4. 余り SP の使い道(HP / 素早さ微調整 / 火力上乗せ)も併記する。
|
|
40395
|
+
|
|
40396
|
+
「ブッパで雑に最速・HP 全振り」の提案はポケチャンでは型として弱いため、明示的に要求された場合を除き避けること。
|
|
40397
|
+
|
|
40398
|
+
## その他の固有仕様
|
|
40399
|
+
|
|
40400
|
+
- 個体値 (IV): 廃止。全ポケモン一律 31 固定として扱われます。
|
|
40401
|
+
- 対戦レベル: 50 固定。
|
|
40402
|
+
- メガシンカ: 1試合につき1回のみ使用可能。
|
|
40403
|
+
- テラスタル: 未対応 (ゲーム側で未実装のため)。
|
|
40404
|
+
- 特性の一部は計算エンジンが未対応で、ダメージ計算結果に効果が反映されません。get_ability_info で効果を確認し、必要に応じて結果の解釈時に補正してください。
|
|
40405
|
+
- 持ち物の一部も同様に計算エンジンが未対応で、ダメージ計算結果に効果が反映されません (フィールド・接地判定に関わるものは反映されます)。get_item_info で効果を確認してください。
|
|
40406
|
+
- メガシンカ後のフォルムと、一部のフォルムは覚える技 (learnset) のデータが未整備です。この場合 get_learnset はエラーになり、get_pokemon_summary の learnableMoves.count は 0、技の逆引き検索 (search_pokemon_by_move 等) では結果に出てきませんが、いずれも「技を覚えない」という意味ではありません。未整備かどうかは get_pokemon_info の learnableMoveCount が null かどうかで判別できるため、技プールを断定せずデータ未整備である旨をユーザーに伝えてください。これらの技プールはベースフォームの learnset を参照してください。
|
|
40407
|
+
|
|
40408
|
+
## 判断と計算の役割分担
|
|
40409
|
+
|
|
40410
|
+
- 本サーバーのツールは「判断の根拠となる正確なデータを返す」ことに責務を限定しています。
|
|
40411
|
+
「この選出が最適」「この構築が正解」といった最終判断は返しません。
|
|
40412
|
+
- 選出・構築・対策の結論は、ツールが返したデータ (タイプ相性・ダメ計・素早さ比較・対面マトリクス等) を元に AI が総合的に導いてください。
|
|
40413
|
+
|
|
40414
|
+
## ツール利用方針(必須)
|
|
40415
|
+
|
|
40416
|
+
以下のトピックがユーザー発話に出てきたら、必ず該当ツールを呼んで根拠データを取得してから回答すること。
|
|
40417
|
+
ポケチャンは従来作と種族値・技威力・特性効果等で差異が出るため、知識ベースの即答は禁止。
|
|
40418
|
+
|
|
40419
|
+
### ポケモン検索・情報取得 (「○○ってどんなポケモン?」「○○タイプで素早いポケモンは?」等)
|
|
40420
|
+
- 単体の基本情報 (種族値 / タイプ / 特性 / 体重) → get_pokemon_info
|
|
40421
|
+
- 単体の総合プロファイル (耐性 / 覚える技 / 実数値) → get_pokemon_summary
|
|
40422
|
+
- タイプ・種族値での絞り込み → search_pokemon
|
|
40423
|
+
- 技の逆引き (この技を覚えるポケモン) → search_pokemon_by_move
|
|
40424
|
+
- 特性の逆引き (この特性を持つポケモン) → search_pokemon_by_ability
|
|
40425
|
+
- タイプ相性での逆引き (○○タイプを半減/無効化する等) → search_pokemon_by_type_effectiveness
|
|
40426
|
+
- 覚える技一覧 → get_learnset
|
|
40427
|
+
|
|
40428
|
+
### 技・攻撃まわり (「○○の威力は?」「電気タイプで威力高い技は?」「攻撃範囲は?」等)
|
|
40429
|
+
- 技の威力 / タイプ / 効果 / PP → get_move_info
|
|
40430
|
+
- ある技を覚えるポケモン一覧 → search_pokemon_by_move
|
|
40431
|
+
- 個体 / パーティの攻撃範囲 → get_pokemon_summary / analyze_party_coverage
|
|
40432
|
+
- ダメージ計算 → calculate_damage_single (1 対 1 単発) / calculate_damage_all_moves (1 対 1 全技) / calculate_damage_party_matchup (6v6)
|
|
40433
|
+
- 確定数 / 乱数 / 耐久要求の逆算 → analyze_damage_range
|
|
40434
|
+
|
|
40435
|
+
### 素早さ (S ライン) (「○○の素早さは?」「○○より早いポケモンは?」「S○○族は?」等)
|
|
40436
|
+
- 実数値計算 → calculate_stats
|
|
40437
|
+
- 素早さライン一覧・スカーフ込み比較 → list_speed_tiers
|
|
40438
|
+
- 対面での先後判定 (素早さ比較込み) → analyze_matchup
|
|
40439
|
+
|
|
40440
|
+
### 対策候補 (「○○の対策は?」「○○に勝てるポケモンは?」等)
|
|
40441
|
+
- 相手の弱点タイプを get_pokemon_summary の defenses で確認する
|
|
40442
|
+
- 弱点タイプの攻撃技を覚えるポケモンを search_pokemon_by_type_effectiveness で検索する。タイプは 1 回に 1 つしか指定できないので、弱点が複数あればタイプごとに呼ぶ。相手の主力技のタイプを半減以下で受けるポケモンも同じツールで探せる
|
|
40443
|
+
- 候補ごとに analyze_matchup を呼び、双方向のダメ計・素早さ・先制技を取得する。相手の技構成がわかっていれば moves を指定する
|
|
40444
|
+
- どの候補を検討するか、受けて倒すのか上から倒すのかといった判断は AI が行う
|
|
40445
|
+
|
|
40446
|
+
### その他の事実確認 (「○○の特性効果は?」「○○の効果は?」「ねっぷう撃たれたら?」等)
|
|
40447
|
+
- 特性効果 → get_ability_info
|
|
40448
|
+
- 持ち物効果 → get_item_info
|
|
40449
|
+
- 性格補正 → get_nature_info
|
|
40450
|
+
- タイプ相性 → get_type_info
|
|
40451
|
+
- 天候 / 状態異常 / フィールド / 壁 → get_condition_info
|
|
40452
|
+
|
|
40453
|
+
## 計算・分析系ツールでの ability / item 指定
|
|
40454
|
+
|
|
40455
|
+
- 計算・対面分析系ツール (calculate_damage_single / calculate_damage_all_moves / calculate_damage_party_matchup / analyze_damage_range / analyze_matchup / analyze_selection) を呼ぶ前に、攻撃側・防御側の ability / item を確認してから指定すること。
|
|
40456
|
+
- 省略時の挙動: ability は通常特性 (pokemon.json の abilities[0]) が自動設定され、item は持ち物なし扱いとなる。そのためメガシンカ・こだわり系・半減きのみ・ちからのハチマキ 等が反映されず、実戦想定の build と乖離した結果になる。
|
|
40457
|
+
- 正確な計算のためには ability / item を明示的に指定することを強く推奨する。
|
|
40458
|
+
- 一方で、育成データ (evs・nature) が不明な場合は省略してよい (デフォルト値で計算)。
|
|
40459
|
+
`.trim()}\n\n${`
|
|
40460
|
+
## パーティデータの扱い
|
|
40461
|
+
|
|
40462
|
+
- セッション開始時 (初回ユーザー発話への応答前) に必ず list_parties を呼び、保存済みパーティの名前一覧を把握すること。
|
|
40463
|
+
- ユーザーが「メインパ」「ドラゴン軸」等の保存名に言及したら load_party で詳細を取得し、分析ツールに渡すこと。
|
|
40464
|
+
- ユーザーが新規構築を説明した際は「保存しますか」と確認し、同意があれば save_party を呼ぶこと。
|
|
40465
|
+
- パーティの削除依頼は delete_party を使うこと。
|
|
40466
|
+
- 起動時にパーティ詳細まで自動読み込みしないこと (トークン消費を抑えるため、詳細は都度 load_party で取得する)。
|
|
40467
|
+
|
|
40468
|
+
## パーティ登録の対話スタイル
|
|
40469
|
+
|
|
40470
|
+
ユーザーが「パーティを保存したい」「構築を覚えて」等と依頼した場合:
|
|
40471
|
+
|
|
40472
|
+
### テキスト一括投入の場合 (ケース A)
|
|
40473
|
+
|
|
40474
|
+
- ユーザーが Showdown 風 or ポケソルテキストを貼り付けた → import_party_from_text を呼ぶ (原文をそのまま渡す)。
|
|
40475
|
+
- ユーザーがゲーム内画面のスクショを添付した → 画像から build を読み取り、下記の対話ケース (B) と同じ手順でポケソルテキストに整理してから import_party_from_text を呼ぶ。
|
|
40476
|
+
|
|
40477
|
+
### 対話で埋める場合 (ケース B)
|
|
40478
|
+
|
|
40479
|
+
- ユーザーがテキストもスクショも提供しない → AI が段階的に質問する。
|
|
40480
|
+
- 1 匹ずつ以下の順で聞く (ユーザーが知っている情報から埋める):
|
|
40481
|
+
1. ポケモン名 (日本語 or 英語)
|
|
40482
|
+
2. 性格 (候補を 4-5 個提示: いじっぱり / ようき / ひかえめ / おくびょう / ずぶとい など)
|
|
40483
|
+
3. 特性 (該当ポケモンの候補を提示)
|
|
40484
|
+
4. もちもの (省略可能、候補があれば提示)
|
|
40485
|
+
5. 技 4 つ
|
|
40486
|
+
6. SP 配分 (省略時は無振り 0、指定あれば各 0〜32 / 合計 0〜66 で受け付け)
|
|
40487
|
+
|
|
40488
|
+
### 整理ステップ (重要)
|
|
40489
|
+
|
|
40490
|
+
- 対話で情報が揃ったら、必ずポケソルテキスト形式にまとめて表示し、ユーザーに確認を取ること:
|
|
40491
|
+
|
|
40492
|
+
例:
|
|
40493
|
+
ガブリアス @ こだわりスカーフ
|
|
40494
|
+
特性: さめはだ
|
|
40495
|
+
能力補正: いじっぱり
|
|
40496
|
+
170(2)-200(32)-115(0)-90(0)-100(0)-167(32)
|
|
40497
|
+
じしん / ドラゴンクロー / つのドリル / いわなだれ
|
|
40498
|
+
|
|
40499
|
+
- 実数値が不明な場合は calculate_stats を呼んで補完する (パーサー仕様上、実数値行は省略可能だが、ユーザー確認用に含めることを推奨)。
|
|
40500
|
+
- 複数匹の場合は空行区切りで並べる。
|
|
40501
|
+
- ユーザー確認後 import_party_from_text(text, name, memo) を呼ぶ。
|
|
40502
|
+
- パーサーがエラーを返した場合は、原因を提示してユーザーに修正を確認する。
|
|
40503
|
+
|
|
40504
|
+
### 質問の書き方ルール
|
|
40505
|
+
|
|
40506
|
+
- 質問は短く、候補があれば列挙する (「性格はどうしますか? いじっぱり / ようき / ひかえめ」のような形式)。
|
|
40507
|
+
- 一度に 1 項目だけ聞く (複数同時の質問は避ける)。
|
|
40508
|
+
- ユーザーが「後で決める」と言った項目はデフォルト値で埋める (性格=まじめ、特性=基本特性、SP=無振り 等)。
|
|
40509
|
+
- 不明な項目は tool 呼び出しで確認する (例: 覚える技 → get_learnset)。
|
|
40510
|
+
|
|
40511
|
+
### 絶対に守ること
|
|
40512
|
+
|
|
40513
|
+
- 対話で得た情報を JSON 化して save_party を直接呼ばない (ハルシネーションリスク軽減のため必ずポケソルテキスト経由)。
|
|
40514
|
+
- ユーザー確認なしに save / import を実行しない。
|
|
40515
|
+
`.trim()}`;
|
|
40516
|
+
// src/party-store.ts
|
|
40517
|
+
/** ai-rotom の永続化用ディレクトリ名 (ホーム直下)。 */
|
|
40518
|
+
const AI_ROTOM_DIR_NAME = ".ai-rotom";
|
|
40519
|
+
/** パーティ永続化ファイル名。 */
|
|
40520
|
+
const PARTIES_FILE_NAME = "parties.json";
|
|
40521
|
+
/** atomic write 用の一時ファイル拡張子。 */
|
|
40522
|
+
const TEMP_FILE_EXT = ".tmp";
|
|
40523
|
+
/** JSON.stringify の indent。 */
|
|
40524
|
+
const JSON_INDENT = 2;
|
|
40525
|
+
/** 一時ファイル名用のランダムサフィックスバイト数。 */
|
|
40526
|
+
const TEMP_SUFFIX_BYTES = 8;
|
|
40527
|
+
/**
|
|
40528
|
+
* 永続化ファイル (`~/.ai-rotom/parties.json`) の絶対パスを返す。
|
|
40529
|
+
* ホームディレクトリが解決できない場合はエラーを投げる。
|
|
40530
|
+
*/
|
|
40531
|
+
function resolvePartiesFilePath() {
|
|
40532
|
+
const home = homedir();
|
|
40533
|
+
if (home === "" || home === void 0 || home === null) throw new UserFacingError("ホームディレクトリが解決できませんでした。$HOME 環境変数を確認してください。");
|
|
40534
|
+
return join(home, AI_ROTOM_DIR_NAME, PARTIES_FILE_NAME);
|
|
40535
|
+
}
|
|
40536
|
+
/**
|
|
40537
|
+
* 永続化ファイルの読み込み結果。
|
|
40538
|
+
* 存在しない場合は空の PartiesFile を返す。
|
|
40539
|
+
* 破損・権限・schemaVersion 不整合の場合はエラーを投げる。
|
|
40540
|
+
*/
|
|
40541
|
+
function loadPartiesFile(filePath = resolvePartiesFilePath()) {
|
|
40542
|
+
let raw;
|
|
40543
|
+
try {
|
|
40544
|
+
raw = readFileSync(filePath, { encoding: "utf-8" });
|
|
40545
|
+
} catch (error) {
|
|
40546
|
+
if (isNodeErrnoException(error) && error.code === "ENOENT") return {
|
|
40547
|
+
schemaVersion: 1,
|
|
40548
|
+
parties: []
|
|
40549
|
+
};
|
|
40550
|
+
throw wrapIoError("パーティファイルの読み込みに失敗しました", error);
|
|
40551
|
+
}
|
|
40552
|
+
let parsed;
|
|
40553
|
+
try {
|
|
40554
|
+
parsed = JSON.parse(raw);
|
|
40555
|
+
} catch (error) {
|
|
40556
|
+
throw new UserFacingError(`パーティファイル (${filePath}) の JSON パースに失敗しました: ${error instanceof Error ? error.message : String(error)}`);
|
|
40557
|
+
}
|
|
40558
|
+
const result = partiesFileSchema.safeParse(parsed);
|
|
40559
|
+
if (!result.success) throw new UserFacingError(`パーティファイル (${filePath}) のスキーマ検証に失敗しました: ${result.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ")}`);
|
|
40560
|
+
if (result.data.schemaVersion !== 1) throw new UserFacingError(`未対応の schemaVersion (${result.data.schemaVersion}) です。現行は 1 です。`);
|
|
40561
|
+
return result.data;
|
|
40562
|
+
}
|
|
40563
|
+
/**
|
|
40564
|
+
* 永続化ファイルを atomic に書き込む。
|
|
40565
|
+
* 親ディレクトリが存在しない場合は作成する。
|
|
40566
|
+
* 一時ファイル → rename で置き換えるため、途中失敗でも元ファイルは壊れない。
|
|
40567
|
+
*/
|
|
40568
|
+
function savePartiesFile(data, filePath = resolvePartiesFilePath()) {
|
|
40569
|
+
const validated = partiesFileSchema.parse(data);
|
|
40570
|
+
const dir = dirname(filePath);
|
|
40571
|
+
try {
|
|
40572
|
+
mkdirSync(dir, { recursive: true });
|
|
40573
|
+
} catch (error) {
|
|
40574
|
+
throw wrapIoError(`パーティ保存ディレクトリ (${dir}) の作成に失敗しました`, error);
|
|
40575
|
+
}
|
|
40576
|
+
const tempPath = `${filePath}.${randomBytes(TEMP_SUFFIX_BYTES).toString("hex")}${TEMP_FILE_EXT}`;
|
|
40577
|
+
const serialized = JSON.stringify(validated, null, JSON_INDENT);
|
|
40578
|
+
try {
|
|
40579
|
+
writeFileSync(tempPath, serialized, {
|
|
40580
|
+
encoding: "utf-8",
|
|
40581
|
+
mode: 384
|
|
40582
|
+
});
|
|
40583
|
+
renameSync(tempPath, filePath);
|
|
40584
|
+
} catch (error) {
|
|
40585
|
+
try {
|
|
40586
|
+
rmSync(tempPath, { force: true });
|
|
40587
|
+
} catch {}
|
|
40588
|
+
throw wrapIoError(`パーティファイル (${filePath}) の保存に失敗しました`, error);
|
|
40589
|
+
}
|
|
40590
|
+
}
|
|
40591
|
+
function isNodeErrnoException(value) {
|
|
40592
|
+
return value instanceof Error && typeof value.code === "string";
|
|
40593
|
+
}
|
|
40594
|
+
function wrapIoError(prefix, error) {
|
|
40595
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
40596
|
+
return new UserFacingError(`${prefix}${isNodeErrnoException(error) && error.code !== void 0 ? ` [${error.code}]` : ""}: ${message}`);
|
|
40597
|
+
}
|
|
40598
|
+
// src/party-text.ts
|
|
40599
|
+
/** ポケソルテキストで性格を省略した場合のデフォルト。 */
|
|
40600
|
+
const DEFAULT_NATURE_NAME = "まじめ";
|
|
40601
|
+
/**
|
|
40602
|
+
* ポケソルテキストを空行区切りで個別ブロックに分割する。
|
|
40603
|
+
* 改行 (LF / CRLF) のどちらにも対応する。
|
|
40604
|
+
* 空白のみのブロックは除外する。
|
|
40605
|
+
*/
|
|
40606
|
+
function splitPokesolTextBlocks(text) {
|
|
40607
|
+
return text.replace(/\r\n/g, "\n").split(/\n\s*\n/).map((block) => block.trim()).filter((block) => block.length > 0);
|
|
40608
|
+
}
|
|
40609
|
+
/**
|
|
40610
|
+
* パーサー出力 (`PokesolTextParseReult`) を `PartyMember` に変換する。
|
|
40611
|
+
* - `abilityNames[1..]` (括弧内のメガ前特性) が存在すれば最も元の状態 (末尾) を
|
|
40612
|
+
* `ability` として保存 (通常状態の特性が基本。メガ進化時の特性変化は計算側の責務)
|
|
40613
|
+
* - `natureName` が null の場合は `DEFAULT_NATURE_NAME` で補完
|
|
40614
|
+
* - `terastalName` が存在する場合はポケチャン未対応のため無視
|
|
40615
|
+
* - `moveNames` が空配列の場合は `moves` フィールド自体を省く
|
|
40616
|
+
*
|
|
40617
|
+
* 補完・無視を行った場合はブロック番号付きの warnings を返す。
|
|
40618
|
+
*/
|
|
40619
|
+
function mapPokesolResultToPartyMember(result, blockNumber) {
|
|
40620
|
+
const warnings = [];
|
|
40621
|
+
if (result.pokemonName === null || result.pokemonName === "") throw new UserFacingError(`ブロック ${blockNumber}: ポケモン名が読み取れませんでした。`);
|
|
40622
|
+
const member = { name: result.pokemonName };
|
|
40623
|
+
if (result.itemName !== null) member.item = result.itemName;
|
|
40624
|
+
const { ability, ignoredAbilities } = selectAbility(result.abilityNames);
|
|
40625
|
+
if (ability !== void 0) {
|
|
40626
|
+
member.ability = ability;
|
|
40627
|
+
if (ignoredAbilities.length > 0) {
|
|
40628
|
+
const ignored = ignoredAbilities.map((name) => `「${name}」`).join("");
|
|
40629
|
+
warnings.push(`ブロック ${blockNumber}: メガ進化特性${ignored}は無視し、メガ前特性「${ability}」を ability として保存しました。`);
|
|
40630
|
+
}
|
|
40631
|
+
}
|
|
40632
|
+
if (result.natureName !== null) member.nature = result.natureName;
|
|
40633
|
+
else {
|
|
40634
|
+
member.nature = DEFAULT_NATURE_NAME;
|
|
40635
|
+
warnings.push(`ブロック ${blockNumber}: 性格が省略されていたためデフォルト「${DEFAULT_NATURE_NAME}」を補完しました。`);
|
|
40636
|
+
}
|
|
40637
|
+
if (result.terastalName !== null && result.terastalName !== "") warnings.push(`ブロック ${blockNumber}: テラスタイプ「${result.terastalName}」はポケモンチャンピオンズ未対応のため無視しました。`);
|
|
40638
|
+
const evs = buildEvsFromResult(result.evs);
|
|
40639
|
+
if (evs !== void 0) member.evs = evs;
|
|
40640
|
+
if (result.moveNames.length > 0) member.moves = [...result.moveNames];
|
|
40641
|
+
else warnings.push(`ブロック ${blockNumber}: 技行が省略されていたため moves を空で登録しました。`);
|
|
40642
|
+
return {
|
|
40643
|
+
member,
|
|
40644
|
+
warnings
|
|
40645
|
+
};
|
|
40646
|
+
}
|
|
40647
|
+
/**
|
|
40648
|
+
* パーサー出力の `abilityNames` から `PartyMember.ability` に保存する特性を選ぶ。
|
|
40649
|
+
* `abilityNames` は `[現在の特性, ...括弧内の以前の特性]` の順で、
|
|
40650
|
+
* 特性名が省略された位置 (`特性: (さめはだ)` の先頭など) は null になる。
|
|
40651
|
+
*
|
|
40652
|
+
* - 括弧内に特性があれば、最も元の状態である末尾の特性を採用する
|
|
40653
|
+
* - 括弧内が全て空なら現在の特性を採用する
|
|
40654
|
+
* - 採用しなかった特性 (重複を除く) は ignoredAbilities として返す
|
|
40655
|
+
*/
|
|
40656
|
+
function selectAbility(abilityNames) {
|
|
40657
|
+
const names = abilityNames.filter((name) => name !== null);
|
|
40658
|
+
const [currentAbility, ...previousAbilities] = abilityNames;
|
|
40659
|
+
const ability = previousAbilities.filter((name) => name !== null).at(-1) ?? currentAbility ?? void 0;
|
|
40660
|
+
return {
|
|
40661
|
+
ability,
|
|
40662
|
+
ignoredAbilities: [...new Set(names)].filter((name) => name !== ability)
|
|
40663
|
+
};
|
|
40664
|
+
}
|
|
40665
|
+
/**
|
|
40666
|
+
* パーサー出力の SP (努力値フィールド) を `EvsInput` に変換する。
|
|
40667
|
+
* 全て 0 の場合は undefined を返し、`PartyMember.evs` を省く。
|
|
40668
|
+
*/
|
|
40669
|
+
function buildEvsFromResult(parserEvs) {
|
|
40670
|
+
const mapped = {
|
|
40671
|
+
hp: parserEvs.hp,
|
|
40672
|
+
atk: parserEvs.attack,
|
|
40673
|
+
def: parserEvs.defense,
|
|
40674
|
+
spa: parserEvs.specialAttack,
|
|
40675
|
+
spd: parserEvs.specialDefense,
|
|
40676
|
+
spe: parserEvs.speed
|
|
40677
|
+
};
|
|
40678
|
+
return Object.values(mapped).some((value) => value !== void 0 && value !== 0) ? mapped : void 0;
|
|
40679
|
+
}
|
|
40680
|
+
// src/tools/party/import-party-from-text.ts
|
|
40681
|
+
const TOOL_NAME = "import_party_from_text";
|
|
40682
|
+
const TOOL_DESCRIPTION = "ポケソルテキスト (Showdown 風に 1 匹あたり 3〜6 行・複数匹は空行区切り) からパーティを一括取り込みして保存する (upsert)。各メンバーはポケモン名 / 特性 / 性格 / 技 / 持ち物をポケチャン内の既知データと照合する。エラーがある場合は部分保存せず全体を失敗させる。";
|
|
40683
|
+
/** ポケソルテキスト入力の最大文字数 (6 匹 × 数百文字 + メモ想定)。 */
|
|
40684
|
+
const MAX_POKESOL_TEXT_LENGTH = 8e3;
|
|
40685
|
+
const defaultNowProvider$1 = () => /* @__PURE__ */ new Date();
|
|
40686
|
+
const defaultStoreIO$1 = {
|
|
40687
|
+
load: () => loadPartiesFile(),
|
|
40688
|
+
save: (data) => savePartiesFile(data)
|
|
40689
|
+
};
|
|
40690
|
+
const inputSchema = {
|
|
40691
|
+
text: z.string().min(1, { message: "ポケソルテキストは 1 文字以上で指定してください。" }).max(MAX_POKESOL_TEXT_LENGTH, { message: `ポケソルテキストは ${MAX_POKESOL_TEXT_LENGTH} 文字以下で指定してください。` }).describe("ポケソルテキスト。1 匹あたり 3〜6 行 (ポケモン名[@持ち物] / テラスタイプ行 省略可 / 特性 / 能力補正 / 実数値(SP) 省略可 / 技 省略可)。複数匹は空行で区切る。"),
|
|
40692
|
+
name: z.string().min(1, { message: "パーティ名は 1 文字以上で指定してください。" }).max(50, { message: `パーティ名は 50 文字以下で指定してください。` }).describe("保存名 (識別子。同名は上書き)。"),
|
|
40693
|
+
memo: z.string().max(MAX_PARTY_MEMO_LENGTH, { message: `メモは ${MAX_PARTY_MEMO_LENGTH} 文字以下で指定してください。` }).optional().describe("構築メモ (自由記述)。")
|
|
40694
|
+
};
|
|
40695
|
+
/**
|
|
40696
|
+
* NameResolver の既知名 (日英どちらでも) として存在するかを判定する。
|
|
40697
|
+
* 未知の場合は類似候補付きのメッセージを投げる。
|
|
40698
|
+
*/
|
|
40699
|
+
function assertKnownName(resolver, name, label, blockNumber) {
|
|
40700
|
+
if (resolver.hasJapaneseName(name) || resolver.hasEnglishName(name)) return;
|
|
40701
|
+
const suggestions = resolver.suggestSimilar(name, 3);
|
|
40702
|
+
throw new UserFacingError(`ブロック ${blockNumber}: ${label}「${name}」が見つかりません。${suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : ""}`);
|
|
40703
|
+
}
|
|
40704
|
+
/**
|
|
40705
|
+
* PartyMember の各名前フィールドを NameResolver で検証する。
|
|
40706
|
+
* 未知名があれば該当ブロックのエラーとして throw。
|
|
40707
|
+
*/
|
|
40708
|
+
function validateMemberNames(member, blockNumber) {
|
|
40709
|
+
assertKnownName(pokemonNameResolver, member.name, "ポケモン名", blockNumber);
|
|
40710
|
+
if (member.nature !== void 0) assertKnownName(natureNameResolver, member.nature, "性格", blockNumber);
|
|
40711
|
+
if (member.ability !== void 0) assertKnownName(abilityNameResolver, member.ability, "特性", blockNumber);
|
|
40712
|
+
if (member.item !== void 0) assertKnownName(itemNameResolver, member.item, "持ち物", blockNumber);
|
|
40713
|
+
if (member.moves !== void 0) for (const move of member.moves) assertKnownName(moveNameResolver, move, "技", blockNumber);
|
|
40714
|
+
}
|
|
40715
|
+
/**
|
|
40716
|
+
* 本ツールの全処理 (split → parse → map → validate → persist) を実行する。
|
|
40717
|
+
* テストから直接呼び出せるようエクスポートする。
|
|
40718
|
+
*/
|
|
40719
|
+
function runImportPartyFromText(input, deps = {}) {
|
|
40720
|
+
const storeIO = deps.storeIO ?? defaultStoreIO$1;
|
|
40721
|
+
const now = deps.now ?? defaultNowProvider$1;
|
|
40722
|
+
const blocks = splitPokesolTextBlocks(input.text);
|
|
40723
|
+
if (blocks.length < 1) throw new UserFacingError(`パーティには 1 匹以上を含めてください (検出: ${blocks.length} 匹)。`);
|
|
40724
|
+
if (blocks.length > 6) throw new UserFacingError(`パーティには 6 匹までしか含められません (検出: ${blocks.length} 匹)。`);
|
|
40725
|
+
const warnings = [];
|
|
40726
|
+
const members = [];
|
|
40727
|
+
blocks.forEach((block, index) => {
|
|
40728
|
+
const blockNumber = index + 1;
|
|
40729
|
+
let parsed;
|
|
40730
|
+
try {
|
|
40731
|
+
parsed = parse(block);
|
|
40732
|
+
} catch (error) {
|
|
40733
|
+
throw new UserFacingError(`ブロック ${blockNumber} のパースに失敗しました: ${error instanceof Error ? error.message : String(error)}`);
|
|
40734
|
+
}
|
|
40735
|
+
const mapped = mapPokesolResultToPartyMember(parsed, blockNumber);
|
|
40736
|
+
validateMemberNames(mapped.member, blockNumber);
|
|
40737
|
+
members.push(mapped.member);
|
|
40738
|
+
warnings.push(...mapped.warnings);
|
|
40739
|
+
});
|
|
40740
|
+
const file = storeIO.load();
|
|
40741
|
+
const existingIndex = file.parties.findIndex((p) => p.name === input.name);
|
|
40742
|
+
const nowIso = now().toISOString();
|
|
40743
|
+
const createdAt = existingIndex >= 0 ? file.parties[existingIndex].createdAt : nowIso;
|
|
40744
|
+
const party = {
|
|
40745
|
+
name: input.name,
|
|
40746
|
+
members,
|
|
40747
|
+
createdAt,
|
|
40748
|
+
updatedAt: nowIso
|
|
40749
|
+
};
|
|
40750
|
+
if (input.memo !== void 0) party.memo = input.memo;
|
|
40751
|
+
const validation = partySchema.safeParse(party);
|
|
40752
|
+
if (!validation.success) throw new UserFacingError(validation.error.message);
|
|
40753
|
+
const nextParties = [...file.parties];
|
|
40754
|
+
if (existingIndex >= 0) nextParties[existingIndex] = party;
|
|
40755
|
+
else nextParties.push(party);
|
|
40756
|
+
storeIO.save({
|
|
40757
|
+
schemaVersion: 1,
|
|
40758
|
+
parties: nextParties
|
|
40759
|
+
});
|
|
40760
|
+
return {
|
|
40761
|
+
saved: true,
|
|
40762
|
+
party,
|
|
40763
|
+
warnings,
|
|
40764
|
+
filePath: resolvePartiesFilePath(),
|
|
40765
|
+
overwrote: existingIndex >= 0
|
|
40766
|
+
};
|
|
40767
|
+
}
|
|
40768
|
+
/**
|
|
40769
|
+
* import_party_from_text ツールをサーバーに登録する。
|
|
40770
|
+
*/
|
|
40771
|
+
function registerImportPartyFromTextTool(server, deps = {}) {
|
|
40772
|
+
server.tool(TOOL_NAME, TOOL_DESCRIPTION, inputSchema, async (args) => {
|
|
40773
|
+
try {
|
|
40774
|
+
return toTextResponse(runImportPartyFromText(args, deps));
|
|
40775
|
+
} catch (error) {
|
|
40776
|
+
return toErrorResponse(error);
|
|
40777
|
+
}
|
|
40778
|
+
});
|
|
40779
|
+
}
|
|
40780
|
+
// src/tools/party/party-tools.ts
|
|
40781
|
+
const SAVE_TOOL_NAME = "save_party";
|
|
40782
|
+
const SAVE_TOOL_DESCRIPTION = "パーティを保存する (upsert)。同名のパーティが既に存在する場合は上書きされる。createdAt は新規時のみ現在時刻が記録され、同名上書きの場合は保持される。updatedAt は毎回現在時刻に更新される。";
|
|
40783
|
+
const LOAD_TOOL_NAME = "load_party";
|
|
40784
|
+
const LOAD_TOOL_DESCRIPTION = "保存済みパーティを name 指定で 1 件取得する。存在しない場合はエラーを返す。";
|
|
40785
|
+
const LIST_TOOL_NAME = "list_parties";
|
|
40786
|
+
const LIST_TOOL_DESCRIPTION = "保存済みパーティの一覧 (サマリ) を返す。各要素は { name, memo, updatedAt, memberCount } のみで、メンバー詳細は含まない。詳細は load_party を使用する。";
|
|
40787
|
+
const DELETE_TOOL_NAME = "delete_party";
|
|
40788
|
+
const DELETE_TOOL_DESCRIPTION = "保存済みパーティを name 指定で削除する。存在しない場合はエラーを返す。";
|
|
40789
|
+
const defaultNowProvider = () => /* @__PURE__ */ new Date();
|
|
40790
|
+
const defaultStoreIO = {
|
|
40791
|
+
load: () => loadPartiesFile(),
|
|
40792
|
+
save: (data) => savePartiesFile(data)
|
|
40793
|
+
};
|
|
40794
|
+
const nameField = z.string().min(1, { message: "名前は 1 文字以上で指定してください。" }).max(100, { message: `名前は 100 文字以下で指定してください。` });
|
|
40795
|
+
const partyMemberInputSchema = z.object({
|
|
40796
|
+
name: nameField.describe("ポケモン名 (日本語 or 英語)。"),
|
|
40797
|
+
nature: nameField.optional().describe("性格名 (日本語 or 英語)。"),
|
|
40798
|
+
ability: nameField.optional().describe("特性名 (日本語 or 英語)。"),
|
|
40799
|
+
item: nameField.optional().describe("持ち物名 (日本語 or 英語)。"),
|
|
40800
|
+
evs: evsSchema.optional().describe("能力ポイント (SP) 配分。"),
|
|
40801
|
+
moves: z.array(nameField).max(4, { message: `技は 4 個までです。` }).optional().describe("技リスト (最大 4)。")
|
|
40802
|
+
}).describe("パーティメンバー 1 匹分のビルド情報。");
|
|
40803
|
+
const partyNameField = z.string().min(1, { message: "パーティ名は 1 文字以上で指定してください。" }).max(50, { message: `パーティ名は 50 文字以下で指定してください。` });
|
|
40804
|
+
const saveInputSchema = {
|
|
40805
|
+
name: partyNameField.describe("パーティの識別子 (同名は上書き)。"),
|
|
40806
|
+
memo: z.string().max(MAX_PARTY_MEMO_LENGTH, { message: `メモは ${MAX_PARTY_MEMO_LENGTH} 文字以下で指定してください。` }).optional().describe("自由記述メモ。"),
|
|
40807
|
+
members: z.array(partyMemberInputSchema).min(1, { message: `パーティには 1 匹以上を含めてください。` }).max(6, { message: `パーティには 6 匹までしか含められません。` }).describe("1〜6 匹のメンバー。")
|
|
40808
|
+
};
|
|
40809
|
+
const loadInputSchema = { name: partyNameField.describe("取得するパーティ名。") };
|
|
40810
|
+
const deleteInputSchema = { name: partyNameField.describe("削除するパーティ名。") };
|
|
40811
|
+
const listInputSchema = {};
|
|
40812
|
+
function toSummary(party) {
|
|
40813
|
+
const summary = {
|
|
40814
|
+
name: party.name,
|
|
40815
|
+
updatedAt: party.updatedAt,
|
|
40816
|
+
memberCount: party.members.length
|
|
40817
|
+
};
|
|
40818
|
+
if (party.memo !== void 0) summary.memo = party.memo;
|
|
40819
|
+
return summary;
|
|
40820
|
+
}
|
|
40821
|
+
/**
|
|
40822
|
+
* パーティ永続化 4 ツールをサーバーに登録する。
|
|
40823
|
+
* deps は主にテスト用。本番は省略してデフォルト (ファイル I/O + 現在時刻) を使う。
|
|
40824
|
+
*/
|
|
40825
|
+
function registerPartyTools(server, deps = {}) {
|
|
40826
|
+
const storeIO = deps.storeIO ?? defaultStoreIO;
|
|
40827
|
+
const now = deps.now ?? defaultNowProvider;
|
|
40828
|
+
server.tool(SAVE_TOOL_NAME, SAVE_TOOL_DESCRIPTION, saveInputSchema, async (args) => {
|
|
40829
|
+
try {
|
|
40830
|
+
const file = storeIO.load();
|
|
40831
|
+
const nowIso = now().toISOString();
|
|
40832
|
+
const existingIndex = file.parties.findIndex((p) => p.name === args.name);
|
|
40833
|
+
const createdAt = existingIndex >= 0 ? file.parties[existingIndex].createdAt : nowIso;
|
|
40834
|
+
const party = {
|
|
40835
|
+
name: args.name,
|
|
40836
|
+
members: args.members,
|
|
40837
|
+
createdAt,
|
|
40838
|
+
updatedAt: nowIso
|
|
40839
|
+
};
|
|
40840
|
+
if (args.memo !== void 0) party.memo = args.memo;
|
|
40841
|
+
if (existingIndex >= 0) file.parties[existingIndex] = party;
|
|
40842
|
+
else file.parties.push(party);
|
|
40843
|
+
storeIO.save({
|
|
40844
|
+
schemaVersion: 1,
|
|
40845
|
+
parties: file.parties
|
|
40846
|
+
});
|
|
40847
|
+
return toTextResponse({
|
|
40848
|
+
saved: true,
|
|
40849
|
+
overwrote: existingIndex >= 0,
|
|
40850
|
+
party,
|
|
40851
|
+
filePath: resolvePartiesFilePath()
|
|
40852
|
+
});
|
|
40853
|
+
} catch (error) {
|
|
40854
|
+
return toErrorResponse(error);
|
|
40855
|
+
}
|
|
40856
|
+
});
|
|
40857
|
+
server.tool(LOAD_TOOL_NAME, LOAD_TOOL_DESCRIPTION, loadInputSchema, async (args) => {
|
|
40858
|
+
try {
|
|
40859
|
+
const party = storeIO.load().parties.find((p) => p.name === args.name);
|
|
40860
|
+
if (party === void 0) throw new UserFacingError(`パーティ「${args.name}」が見つかりません。list_parties で一覧を確認してください。`);
|
|
40861
|
+
return toTextResponse({ party });
|
|
40862
|
+
} catch (error) {
|
|
40863
|
+
return toErrorResponse(error);
|
|
40864
|
+
}
|
|
40865
|
+
});
|
|
40866
|
+
server.tool(LIST_TOOL_NAME, LIST_TOOL_DESCRIPTION, listInputSchema, async () => {
|
|
40867
|
+
try {
|
|
40868
|
+
return toTextResponse({ parties: storeIO.load().parties.map(toSummary) });
|
|
40869
|
+
} catch (error) {
|
|
40870
|
+
return toErrorResponse(error);
|
|
40871
|
+
}
|
|
40872
|
+
});
|
|
40873
|
+
server.tool(DELETE_TOOL_NAME, DELETE_TOOL_DESCRIPTION, deleteInputSchema, async (args) => {
|
|
40874
|
+
try {
|
|
40875
|
+
const file = storeIO.load();
|
|
40876
|
+
const nextParties = file.parties.filter((p) => p.name !== args.name);
|
|
40877
|
+
if (nextParties.length === file.parties.length) throw new UserFacingError(`パーティ「${args.name}」が見つかりません。`);
|
|
40878
|
+
storeIO.save({
|
|
40879
|
+
schemaVersion: 1,
|
|
40880
|
+
parties: nextParties
|
|
40881
|
+
});
|
|
40882
|
+
return toTextResponse({
|
|
40883
|
+
deleted: true,
|
|
40884
|
+
name: args.name
|
|
40885
|
+
});
|
|
40886
|
+
} catch (error) {
|
|
40887
|
+
return toErrorResponse(error);
|
|
40888
|
+
}
|
|
40889
|
+
});
|
|
40890
|
+
}
|
|
40891
|
+
// src/server.ts
|
|
40892
|
+
function createServer() {
|
|
40893
|
+
const server = createCoreServer(SERVER_INSTRUCTIONS);
|
|
40894
|
+
registerImportPartyFromTextTool(server);
|
|
40895
|
+
registerPartyTools(server);
|
|
40896
|
+
return server;
|
|
40897
|
+
}
|
|
41002
40898
|
async function startServer() {
|
|
41003
40899
|
const server = createServer();
|
|
41004
40900
|
const transport = new StdioServerTransport();
|