Commit Graph

125 Commits

Author SHA1 Message Date
claude-code-best
661b1e29e4 Merge branch 'main' into feature/pokemon/battle 2026-04-24 21:33:23 +08:00
claude-code-best
e38d45460e fix: 修复 Windows Node.js 构建产物因 stdin.ref() 泄漏导致进程挂起 (#353)
startCapturingEarlyInput() 调用 stdin.ref() 后,如果 Ink 未能接管
(如 raw mode 不支持或 setup 阶段异常),unref() 永远不会被调用,
导致 Node.js 事件循环无法退出。修复包括:
- stopCapturingEarlyInput() 中补充 stdin.unref() 调用
- 新增 10s 安全阀定时器自动清理 leaked ref()
- Ink App.componentWillUnmount 兜底 unref() 非 TTY stdin

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 21:16:15 +08:00
claude-code-best
da6d06365d fix: 修复 anthropic 煞笔的四个 bug (#352)
* fix: 移除文件编辑前必须先读取的限制

移除 FileEditTool 和 FileWriteTool 中的 "read before edit" 校验,
允许直接编辑未读取过的文件。保留文件修改过期检测。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* docs: 更新 teach-me 自动写 note 笔记的功能

* fix: 修复 DeepSeek V4 reasoning_content 回传导致的 400 错误

- 扩大模型名称检测范围,匹配所有 deepseek 模型(V4、R1 等)
- 始终保留 thinking blocks 为 reasoning_content 回传给 API
- 移除有 bug 的 turn boundary 剥离逻辑

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: Opus 4.6/4.7 默认推理 effort 从 medium 改为 high

Pro 和 Max/Team 订阅者的 Opus 默认 effort 之前被降级为 medium,
导致用户感知模型「变笨」。恢复为 high。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: 移除 thinkingClearLatched sticky-on 机制

空闲超过 1 小时后 thinkingClearLatched 会被触发且永不重置,
导致每轮 API 调用都清除 thinking 历史。完整移除该 latch 机制,
clearAllThinking 硬编码为 false。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: 移除 numeric_length_anchors 系统指令

删除「工具调用间文字 ≤25 词、最终回复 ≤100 词」的硬性限制。
ablation 测试显示该约束使整体智能下降 3%。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: 修复测试中 reasoning_content 类型断言

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 20:07:18 +08:00
claude-code-best
eb833da33b fix: 创建 agent 后刷新 loadMarkdownFilesForSubdir 缓存
新建 agent 后 clearAgentDefinitionsCache 漏清底层
loadMarkdownFilesForSubdir 的 memoize 缓存,导致新
agent 不会立即出现在列表中,需要重启才能生效。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 15:05:05 +08:00
claude-code-best
4cf1a8353e test: 添加 PP 递减测试
验证使用招式后 PP 减少 1,maxPp 保持不变。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
claude-code-best
a58a36c35a fix: 修复战斗中 PP 不递减的问题
projectPokemon 读取 maxPp 属性名错误,Showdown 使用小写 maxpp,
导致 maxPp 回退到当前 pp 值,UI 显示的 PP 总是满的。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
claude-code-best
c5c7202348 fix: 修复测试因 IV/性格非确定性导致的间歇失败
- battle-scenarios: 回合测试改用 pikachu vs pikachi 避免非确定性一击倒
- creature: EV 测试提升至 level 50 以确保 EV 贡献可见
- creature: level 1 stat 测试使用确定性 Hardy 性格避免 flaky

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
claude-code-best
192221eafc feat: 多语言名称支持动态加载全量数据
- names.ts 新增 getSpeciesI18nName() 按 lang 获取名称
- 自动尝试加载 species-names.ts 生成数据(如已生成)
- 保留 10 个手工校对条目作为回退
- 配合 fetch-species-names.ts 脚本可获取 1024 个物种中/日名称
- 解决 #18 多语言名称覆盖极少

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
claude-code-best
8c6be4b5d3 feat: 支持随机特性选择,包括隐藏特性
- 新增 getAbilities() 返回所有可用特性(含隐藏)
- 新增 randomAbility():80% 普通特性、20% 第二特性、5% 隐藏特性
- 保留 getDefaultAbility() 向后兼容
- 解决 #20 Ability 系统不完整

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
claude-code-best
c37b274406 fix: 蛋孵化步数改用真实 hatchCounter 数据
- 孵化步数从 captureRate 反推改为 hatchCounter * 257(原版公式)
- getHatchCounter 支持进化阶段/传说回退分类
- fetch-pokedex-data.ts 已更新以采集 hatchCounter 字段
- 解决 #17 蛋系统孵化步数不准确

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
claude-code-best
e16b5667a8 fix: 改用 Gen 3+ 标准方法生成 PID/IV/闪亮/性别
- 新增 generatePID() 生成 32 位 Personality Value
- IV 改为 PID 位提取法(word1/word2 各取 3 个 5-bit),替换 LCRNG
- Shiny 检测改为 PID XOR 方法,阈值 < 16(Gen 8+ 约 1/4096)
- 性别阈值从 (rate/8)*256 改为 rate*32,消除浮点精度丢失
- 生成生物时使用 randomAbility() 替代 getDefaultAbility()
- 解决 #14 Shiny 检测、#15 IV 生成、#16 性别阈值、#20 Ability 选择

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
claude-code-best
e9405e4a8a feat: 战斗引擎全面升级 — 捕获/逃跑/多对手/AI/道具/状态
- 新增 capture.ts:Gen 9 捕获率计算,支持精灵球/状态/时间修正
- 实现逃跑概率公式 (Gen 9) 和失败累计机制
- createBattle 支持多对手 OpponentEntry[],AI 换人考虑属性克制
- AI 选招改为优先克制招式,避免蓄力招式和被抵抗招
- 野生招式从 Dex.data.Learnsets 按等级获取,替换硬编码映射
- 实现 Potion/SuperPotion/FullRestore 等回复药效果
- 野生对手随机持有道具(5%树果/专属、3%属性增强道具)
- 新增 VolatileStatus 类型,BattlePokemon 添加 volatileStatus
- needsSwitch 检测改为更健壮的 p1Fainted + hasAliveBench 逻辑
- 解决 #3 物品使用、#4 逃跑、#5 多精灵对战、#6 AI、#7 野生招式、
  #10 捕获系统、#11 volatile状态、#12 天气/地形、#19 野生道具

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
claude-code-best
be64db70d4 fix: 修正战斗结算的 XP 和 EV 计算
- XP 公式改为使用真实 baseExperience(从 PokeAPI),而非 baseStats.hp
- EV yield 改为使用真实数据(getPokedexEvYield),而非伪造的映射
- 进化检测改为遍历所有 evos 目标,支持分支进化
- 新增友谊度进化检测(friendship >= 220)
- 解决 #1 XP 公式错误、#2 EV 伪造、#8 进化只取第一个目标

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
claude-code-best
6fc365cf73 feat: 从 PokeAPI 批量导入物种数据,替换硬编码
- 新增 pokedex-data.ts:1024 个物种的 baseExperience、EV yield、growthRate、captureRate、baseHappiness、hatchCounter
- 新增 fetch-pokedex-data.ts:PokeAPI 数据抓取脚本(可重复运行)
- 新增 fetch-species-names.ts:多语言名称抓取脚本(中/日/英)
- species.ts 改为使用 pokedex-data 替代硬编码 supplement 条目
- 解决 #1 XP 数据源、#2 EV 数据源、#13 Growth Rate 覆盖不全问题

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
claude-code-best
6a89a5139a docs: 添加 Pokémon 战斗系统审查报告
记录 20 个已发现的 bug 及修复状态,涵盖严重/中等/轻度三个级别。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
claude-code-best
10b5f35140 fix: 修复第三方 Anthropic base URL 应使用 ExaSearchAdapter 而非 BingSearchAdapter
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 11:48:40 +08:00
Bot
51a3a83f07 fix: 将 highlight.js 改为静态导入以兼容 Bun --compile 模式
- cliHighlight.ts: 使用静态 import 替换 dynamic import('highlight.js'),
  因为编译模式下模块解析指向内部 bunfs 路径导致无法找到
- color-diff-napi/src/index.ts: 同样改为静态导入,移除 createRequire 延迟加载
2026-04-24 11:48:20 +08:00
Bot
c69e66d2cd feat: 添加 Exa AI 搜索适配器
- 新增 ExaSearchAdapter,基于 MCP 协议调用 Exa 搜索 API
- WebSearchTool 支持 num_results、livecrawl、search_type、context_max_characters 等高级选项
- 非 Anthropic 官方 base URL 时默认使用 Exa 适配器
2026-04-24 11:48:20 +08:00
claude-code-best
9624f880e0 fix: 修复第三方 Anthropic base URL 应使用 ExaSearchAdapter 而非 BingSearchAdapter
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 21:52:16 +08:00
claude-code-best
b642977afe Merge pull request #335 from realorange1994/feature/cli-highlight
fix: 将 highlight.js 改为静态导入以兼容 Bun --compile 模式
2026-04-23 20:07:27 +08:00
claude-code-best
b966eef5a9 Merge branch 'main' into feature/exa-search 2026-04-23 20:04:13 +08:00
Bot
7d4c4278c0 fix: 将 highlight.js 改为静态导入以兼容 Bun --compile 模式
- cliHighlight.ts: 使用静态 import 替换 dynamic import('highlight.js'),
  因为编译模式下模块解析指向内部 bunfs 路径导致无法找到
- color-diff-napi/src/index.ts: 同样改为静态导入,移除 createRequire 延迟加载
2026-04-23 18:47:31 +08:00
Bot
93bfdabff1 feat: 添加 Exa AI 搜索适配器
- 新增 ExaSearchAdapter,基于 MCP 协议调用 Exa 搜索 API
- WebSearchTool 支持 num_results、livecrawl、search_type、context_max_characters 等高级选项
- 非 Anthropic 官方 base URL 时默认使用 Exa 适配器
2026-04-23 18:43:41 +08:00
claude-code-best
1173a62301 refactor: 统一 log.ts/debug.ts 的测试 mock 为共享定义
- 新增 tests/mocks/log.ts 和 tests/mocks/debug.ts,覆盖源文件全部实际导出
- 移除旧 mock 中不存在的导出(logToFile、logEvent、getLogFilePath)
- 13 个测试文件改为使用共享 mock,避免定义分散和不一致

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 11:39:53 +08:00
claude-code-best
ecf2dbde44 feat: 又一大波改动 2026-04-23 11:20:24 +08:00
claude-code-best
1a910ed639 refactor: 统一 log.ts/debug.ts 的测试 mock 为共享定义
- 新增 tests/mocks/log.ts 和 tests/mocks/debug.ts,覆盖源文件全部实际导出
- 移除旧 mock 中不存在的导出(logToFile、logEvent、getLogFilePath)
- 13 个测试文件改为使用共享 mock,避免定义分散和不一致

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-22 23:35:59 +08:00
claude-code-best
dceaacdf4f Merge remote-tracking branch 'origin/main' into feature/pokemon/battle 2026-04-22 22:59:13 +08:00
unraid
23bb09d240 feat: 添加 model/provider 层改进
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 22:38:10 +08:00
unraid
d208855f07 feat: 添加 builtin-tools 增强与测试覆盖
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 22:38:10 +08:00
unraid
eec961352b feat: 添加 napi 包测试覆盖与 stub 改进
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 22:38:10 +08:00
unraid
1837df5f88 feat: 添加 skill learning 技能学习闭环系统
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 22:38:09 +08:00
claude-code-best
7813904264 feat: 修复小细节 2026-04-22 17:59:22 +08:00
claude-code-best
02783e4f5d feat: PC Box 管理系统 + 全英文名统一 + 队伍补位机制
- 新增 PC Box tab(左侧 party + 右侧 box 网格,支持 party↔box 拾取/放置/交换)
- 空格键抓取/放下,左键在 col=0 时切到 party 面板
- 使用 useTabHeaderFocus 避免左右键被 Tabs 组件拦截
- 所有 1025 只精灵统一使用 Dex 英文名,移除中英混搭
- compactParty 补位机制:不允许前置空位,队伍最少保留一只
- PC Box tab 移至第二位(Buddy → PC Box → Pokédex → Egg)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 17:21:24 +08:00
claude-code-best
2c15d9123d fix: PokedexView 改为百分比统计视图,不再渲染全部 1025 只精灵
- 进度条固定 30 字符宽度,按百分比填充
- 新增分代统计(Gen I-IX),每代显示迷你进度条
- 只展示已发现的精灵,而非全部 1025 条
- 删除 groupByChain() 及进化链渲染(列表太长)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 15:18:18 +08:00
claude-code-best
1217c453c4 feat: 同步 pkmn Dex 全部 1025 只精灵,新增 SpeciesPicker 搜索选择器
- SpeciesId 从 10 项联合类型改为 string,动态从 @pkmn/sim Dex 加载 1025 只精灵
- getSpecies() 改用 Dex.species.get() 直接查找(gen wrapper 仅覆盖 733/1025)
- SUPPLEMENT/DEX_TO_SPECIES 动态生成,未收录 species 使用默认值兜底
- names/fallback 改为 partial records,缺失时回退到 Dex 英文名/通用 sprite
- 新增 SpeciesPicker 组件(基于 FuzzyPicker),支持中英文/编号搜索选择精灵
- BattleFlow configSelect 阶段替换为 SpeciesPicker,删除旧的上下翻页逻辑
- evolution 移除 ALL_SPECIES_IDS 限制,所有 Dex 物种均可进化

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 15:15:19 +08:00
claude-code-best
77e8d15482 feat: 解决显示问题 2026-04-22 14:24:41 +08:00
claude-code-best
72cfb83de3 feat: 一大坨优化 2026-04-22 13:33:02 +08:00
claude-code-best
8bf645364f fix: 处理精灵倒下后的强制换人和战斗结束判定
executeTurn 在精灵倒下时未处理 @pkmn/sim 的强制换人要求,
导致 "Not all choices done" 错误。现在:
- 检测 active Pokémon 是否倒下,自动切换到下一只
- 无可用精灵时使用 pass,让引擎正常判定胜负
- AI 侧同样处理强制换人

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 09:03:39 +08:00
claude-code-best
bd70971632 fix: Battle 快捷键通过 inputRef 转发至主 Ink 上下文
BattleFlow 不再直接调用 useInput(外部包的 Ink 上下文可能不同),
改为暴露 handleInput 方法,由 BuddyPanel 中的 BattleTab 通过
useInput + ref 转发键盘事件,确保在正确的 StdinContext 中工作。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 08:44:33 +08:00
claude-code-best
bfd14206a9 fix: 修复 BattleView 渲染 @pkmn/sim 原始 move 对象导致的 React 报错
projectPokemon 中 moveSlots 的 name 字段可能为 undefined,
导致整个对象被当作 React child 渲染。现在优先从 Dex 查询招式名称。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 08:37:03 +08:00
claude-code-best
f22caf0e97 feat: 集成 Battle tab 到 BuddyPanel,重命名 data/ 为 dex/ 规避 gitignore
- BuddyPanel 新增 Battle tab,BattleFlow 加 isActive 控制
- BattleFlow configSelect 阶段支持 ↑↓ 选择物种
- packages/pokemon/src/data/ → dex/,解决根 .gitignore 匹配问题
- 全量 Tab→2空格 缩进转换

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 08:35:19 +08:00
claude-code-best
25067e78af fix: 修正 MoveLearnPanel 提示文本匹配实际键盘绑定
[S] 跳过, [1-4] 替换对应招式 — 与 BattleFlow 输入处理一致

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 07:03:22 +08:00
claude-code-best
70d8c0038c refactor: 进化链动态生成替代硬编码
- PokedexView.tsx: groupByChain() 改用 ALL_SPECIES_IDS + getNextEvolution 动态构建
- SpeciesDetail.tsx: EvolutionChain 用相同方式找链头
- 删除未使用的 isInChain 函数

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 06:32:36 +08:00
claude-code-best
3c64113d77 feat: 添加 BattleFlow 完整键盘输入处理
所有 phase 现在都支持键盘交互:
- config: Enter/1=随机战斗, 2=指定对手, ESC=取消
- configSelect: Enter=确认, ESC=返回
- battle: 1-4=选招, S=换人, I=道具
- switch: 1-6=选队友, ESC=取消
- item: 1-9=选道具, ESC=取消
- result: Enter=继续
- learnMoves: 1-4=替换招式, S=跳过
- evolution: Enter=确认进化

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 06:07:01 +08:00
claude-code-best
0777e1a1f9 refactor: 删除未使用的 pkmn.ts 辅助函数
- 删除 getMove、getAbility、getType、getPrimaryAbility(无生产代码引用)
- 同步删除对应的 pkmn.test.ts 测试

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 06:04:12 +08:00
claude-code-best
080bd93efc test: 补充 hatchEgg 和 species 补充字段测试(227→237)
- egg.test.ts: 新增 hatchEgg 5 个测试
  - 创建 creature 并移除 egg
  - 放入 party 空位
  - totalEggsObtained 计数
  - 新 species dex entry 创建
  - 已有 species caughtCount 递增
- species.test.ts: 新增 ensureSpeciesData、baseHappiness、captureRate、names、shinyChance 测试

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 05:04:16 +08:00
claude-code-best
363ba39cad refactor: 消除 engine.ts 重复 break 和 evolution.test.ts 的 as any
- engine.ts: 移除 switch case 中多余的 break 语句
- evolution.test.ts: 用完整 Creature 对象替代 as any 类型转换

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 04:40:59 +08:00
claude-code-best
4b23bcd3eb test: 增强测试覆盖(188→226 tests)
- battle.test.ts: 新增 createBattle/executeTurn/settleBattle 边界测试
  - EV total cap、非参与者不变、空 participantIds 回退
  - applyMoveLearn PP 验证、applyEvolution friendship cap
  - 多次进化计数器、battlesWon/battlesLost 互斥
  - 修复 makeTestCreature friendship 覆盖
- creature.test.ts: 新增 recalculateLevel、getActiveCreature、nature 效果测试
- experience.test.ts: 新增 xpToNextLevel、awardXP 0值、累积验证
- storage.test.ts: 新增 Bag/Box/Release 操作边界测试

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 04:39:41 +08:00
claude-code-best
4116ac9b5c test: 增强 creature.test.ts 覆盖(recalculateLevel/getActiveCreature/性格效果)
新增 8 个测试用例:
- recalculateLevel: 等级不变/随经验更新
- getActiveCreature: 空 party/party[0]/legacy activeCreatureId/优先级/ID 不存在
- 性格效果: adamant 加攻减特攻、timid 加速减攻

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 04:35:51 +08:00
claude-code-best
39299f6e17 refactor: 清理未使用 import 和添加 spriteCache 错误日志
- SpeciesDetail.tsx: 移除未使用的 SPECIES_PERSONALITY import
- CompanionCard.tsx: 移除未使用的 SPECIES_I18N import
- spriteCache.ts: 空 catch 块添加错误日志输出

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 04:18:51 +08:00