关于 mlb-opponent-profiler
MLB Opponent Profiler 是用于构建和更新 Yahoo 联盟对手档案的梦幻棒球技能。它结合阵容与活动数据,并调用分类器判断类型,同时保留档案中的手动备注。
主要功能
- 01抓取 Yahoo 球队、阵容、选秀和交易页面
- 02提取 MLB 阵容及经理活动特征
- 03使用上周后验结果更新类型
- 04根据阵容组成估算类别强度
- 05更新档案时保留手动备注
- 06生成每周对手档案信号
适用场景
- 01新一周开始后更新 Yahoo 对手档案
- 02比较对手阵容强项和可能放弃的类别
- 03追踪赛季中的对手行为变化
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ lyndonkl/ claude --skill mlb-opponent-profiler安装后在 Claude Code 中输入/mlb-opponent-profiler确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
resources/methodology.mdtemplate.mdresources/evaluators/rubric_mlb_opponent_profiler.json详细介绍
MLB 对手画像分析器
目录
示例
场景:第 5 周周一早晨。在又一个高活跃度周(7 次操作、花费 $14 补充球员、对阵以 4-1 获胜)后,更新 Springfield Isotopes(经理 Nikolay)的画像。
输入:
team_name: "Springfield Isotopes"
yahoo_session: <authenticated chrome context>
prior_profile: # from context/opponents/springfield-isotopes.md (Week 4)
archetype: balanced
archetype_confidence: 0.50
posterior: {balanced: 0.42, stars_and_scrubs: 0.18, punt_sv: 0.02, punt_sb: 0.04,
punt_wins_qs: 0.03, hitter_heavy: 0.12, pitcher_heavy: 0.08,
inactive: 0.00, frustrated_active: 0.11, unknown: 0.00}
步骤 1 -- 抓取 Yahoo 页面(4 个页面):球队索引、team_id=8 的球队页面、选秀结果,以及按 tid=8 筛选的交易记录。URL 见 methodology.md。
步骤 2 -- 提取 MLB 特征,得到:
sp_roster_share: 0.35; closer_count: 2; sb_speed_count: 4; power_bat_count: 6
moves_per_week: 3.3; faab_spent_pct: 0.32; faab_avg_bid: 2.5
lineup_set_daily: true; trade_offers_sent: 1; trade_offers_received: 0
record_last_2_weeks: "8-2-0"; days_since_last_login: 0
步骤 3 -- 调用 opponent-archetype-classifier:
archetype_taxonomy: # see resources/template.md -- 10 archetypes
balanced: {...}
stars_and_scrubs: {...}
...
observed_features: <from step 2>
archetype_prior: <prior_profile.posterior> # sequential: last week's posterior is this week's prior
observation_weight: 0.65 # Week 5 -- see methodology.md observation_weight_calibration
correlated_feature_pairs:
- [moves_per_week, faab_spent_pct] # active managers do both
- [sp_roster_share, closer_count] # they trade off
步骤 4 -- 分类器返回:
posterior:
balanced: 0.58 # up from 0.42 -- evidence accumulating
stars_and_scrubs: 0.12
hitter_heavy: 0.10
frustrated_active: 0.08 # record is winning, so frustrated_active down
pitcher_heavy: 0.07
punt_sb: 0.03
punt_sv: 0.01
punt_wins_qs: 0.01
inactive: 0.00
unknown: 0.00
map_archetype: balanced
classification_confidence: 37.7 # 0.58 * 0.65 * 100 -- still just under 40
best_response_hints:
- "Match cat-for-cat; decided on execution"
- "Include in N-estimate for every common-value FAAB target"
- "Active manager -- probe for fair consolidation trades"
步骤 5 -- 读取现有的 context/opponents/springfield-isotopes.md,保留手动备注,并更新机器生成的部分:
“Summary”、“Apparent weaknesses”、“Best response”和“Open questions”部分包含用户手动撰写的备注——原样保留。仅刷新以下内容:
- YAML 前置元数据:
last_updated、confidence、source_urls - 第 2 节(类型):archetype、archetype_confidence、archetype_evidence
- 第 3 节(类别强度):cat_strength、presumed_punts、likely_pushes
- 第 4 节(行为):activity_level、last_active、waiver_aggression、faab_remaining、faab_avg_bid_pct、trade_propensity
步骤 6 -- 在 signals/wk05-opponent-profiles.md 输出每周信号:
---
type: opponent_profile_summary
date: 2026-04-20
week: 5
emitted_by: mlb-opponent-profiler
confidence: 0.65
source_urls: [<11 team pages + transactions + teams>]
---
## Archetype shifts since Week 4
- Springfield Isotopes: balanced 0.42 -> 0.58 (confidence 0.50 -> 0.66). Nikolay continues active pattern, record confirms execution.
- Jennys Team: inactive 0.78 -> 0.84 (confidence 0.80 -> 0.85). Still zero moves. Profile hardening.
- ...9 more
## New reactivity triggers fired
- Team 7 (Kenyi) -- outbid us on Wade Miley at $14; shift `faab_avg_bid_pct` up
工作流
复制此检查清单并跟踪进度:
Opponent Profiler Progress (per team, x 11 for all_opponents):
- [ ] Step 1: Resolve team identity (team_name -> team_id, manager_alias)
- [ ] Step 2: Scrape 4 Yahoo pages for this team
- [ ] Step 3: Extract MLB-specific features (9 features; see template.md)
- [ ] Step 4: Load prior_profile.posterior as archetype_prior (sequential update)
- [ ] Step 5: Invoke opponent-archetype-classifier with 10-archetype MLB taxonomy
- [ ] Step 6: Compute cat_strength (0-100 per cat) from roster composition
- [ ] Step 7: Read existing context/opponents/<slug>.md; identify manual-notes sections
- [ ] Step 8: Write updated file atomically (preserve manual notes)
- [ ] Step 9: (at end of batch) Emit signals/wkNN-opponent-profiles.md summary
步骤 1:确定球队身份
输入可以是单个 team_name(不区分大小写,与规范的 Yahoo 球队名称进行模糊匹配),也可以是 all_opponents: true(遍历 team_ids 1-12,跳过用户自己的 team_id)。映射到 team_id 和 team-slug(小写并以连字符分隔)。
- 如果
team_name与任何 Yahoo 球队都不匹配,则返回错误——不要猜测 -
team-slug必须与磁盘上的文件名context/opponents/<slug>.md匹配(如果文件不存在,则新建)
步骤 2:抓取 4 个 Yahoo 页面
准确的 URL 流程见 resources/methodology.md。所需页面:
-
https://baseball.fantasysports.yahoo.com/b1/23756/teams-- 经理、最后登录时间、胜-负记录 -
https://baseball.fantasysports.yahoo.com/b1/23756/<team_id>-- 阵容 + 剩余 FAAB -
https://baseball.fantasysports.yahoo.com/b1/23756/<team_id>/draftresults-- 选秀球员分布 -
https://baseball.fantasysports.yahoo.com/b1/23756/transactions?tid=<team_id>-- 补入/弃用/出价/交易 - 每次抓取都要将准确的 URL 记录在
source_urls中(用于引用) - 如果任何页面返回 4xx/5xx 错误或认证失败,则优雅降级(见防护措施 #3)
步骤 3:提取 MLB 特征
根据抓取的页面计算。准确公式见 resources/methodology.md。
-
sp_roster_share、closer_count、sb_speed_count、power_bat_count(阵容构成) -
moves_per_week、faab_spent_pct、faab_avg_bid(弃权名单活动) -
lineup_set_daily(布尔值——过去 7 天中,是否有被搁置但实际参加 MLB 比赛的球员?) -
trade_offers_sent、trade_offers_received -
record_last_2_weeks、days_since_last_login
步骤 4:按顺序更新先验
读取 prior_profile.posterior(如果提供),并将其作为 archetype_prior 传给分类器。这是关键的序贯贝叶斯步骤:上周的后验分布成为本周的先验分布。
- 如果没有
prior_profile,则使用分类体系的先验(仅第 1 周) - 如果
prior_profile.posterior的总和不等于 1.0,则进行归一化,并在assumptions_flagged中标记 - 观测权重随周数增加:Wk1-2 = 0.25,Wk3-4 = 0.45,Wk5-7 = 0.65,Wk8-11 = 0.80,Wk12+ = 0.90
步骤 5:调用 opponent-archetype-classifier
传入 resources/template.md 中的 10 类 MLB 分类体系,以及观测特征、先验和 observation_weight。请勿在此技能中重新实现贝叶斯数学计算。 分类器会返回 posterior、map_archetype、classification_confidence、best_response_hints、feature_contribution_breakdown、assumptions_flagged。
- 传入
correlated_feature_pairs(参见防护措施 #1) - 如果分类器返回
map_archetype: "inconclusive",则将分类写为unknown,置信度使用返回值 - 不要覆盖或重新解读分类器的输出——原样存储
步骤 6:计算 cat_strength(每项 cat 为 0-100)
分类器会返回分类结果;每项 cat 的 10 个强度分数由另一个基于阵容的估算器计算(这是 MLB 专用内容,应保留在此技能中)。计算方法见 resources/methodology.md。
- 汇总阵容中每项 cat 的赛季预计总值
- 归一化至 0-100,其中 50 为联盟平均水平
- 得出
presumed_punts:分数 < 35 的 cat - 得出
likely_pushes:分数 > 65 的 cat
步骤 7:读取现有文件,识别手动笔记部分
重要:此技能绝不会覆盖手动编写的笔记。 参见 resources/methodology.md。
- 打开
context/opponents/<slug>.md;如果文件不存在,则根据模板生成新文件 - 原样保留第 1 节(摘要)、第 5 节(明显弱项 / 优势项)、第 6 节(最佳应对)、第 8 节(反应触发条件)、第 9 节(待解决问题)
- 仅更新:frontmatter(last_updated、confidence、source_urls)、第 2 节(分类)、第 3 节(类别强度)、第 4 节(行为特征)、第 7 节(对战历史——如果曾与其交手)
步骤 8:以原子方式写入文件
- 写入临时文件
<slug>.md.tmp,执行 fsync,然后重命名 - 重命名前,根据
yahoo-mlb/context/frameworks/opponent-profile-schema.md中的 frontmatter 和章节顺序验证输出
步骤 9:生成信号文件
在全部 11 次更新完成后(针对 all_opponents: true 模式),生成 signals/wkNN-opponent-profiles.md。格式见 resources/template.md。
- 包含自上周以来变化幅度 > 0.05 的所有分类后验概率
- 包含所有变化幅度 > 0.10 的置信度
- 列出本周触发的所有反应触发事件
常见模式
模式 1:inactive(不活跃的经理——例如 Jenny's Team)
- 信号:
moves_per_week < 0.5、faab_spent_pct < 0.05、days_since_last_login > 3或lineup_set_daily = false - 最佳应对:不要将其纳入 N 竞标者的 FAAB 估算。发送整合型交易报价。预计其阵容会逐渐衰退——逐周利用其忽视阵容的劣势。
- 置信度快速提升:不活跃特征明确;预计到第 4 周时
archetype_confidence会超过 0.80。
模式 2:punt_wins_qs(Marmol 策略——全打者阵容 + 仅 RP 的投手组)
- 信号:
sp_roster_share < 0.25、closer_count >= 3、moves_per_week > 3(轮换球员以提升打者表现) - 最佳应对:放弃 K 和 QS(免费输掉两个类别);锁定剩余 8 个类别中的 6 个。不要对他们使用 SP 轮换策略。
模式 3:punt_sv(没有终结者,拥有精英 SP + 打击阵容)
- 信号:
closer_count = 0、sp_roster_share > 0.40、在第 1–3 轮选中了高端 SP - 最佳应对:放弃 SV;全力争取全部 5 个打击类别,以及 K、QS、ERA 和 WHIP。不要为了轮换球员而追逐终结者。
模式 4:frustrated_active(活跃但连败——有交易意愿的经理)
- 信号:
moves_per_week > 4,且record_last_2_weeks的 W% < 0.35 - 最佳应对:优先考虑作为交易伙伴。他们会回应报价。瞄准他们状态下滑的明星球员(他们高价卖出,我们低价买入)。
模式 5:balanced(默认)
- 信号:没有明显的放弃策略;所有特征的阵容构成都在联盟平均值的 1 个标准差范围内
- 最佳应对:逐类别匹配;对决结果取决于每周执行情况。当我们处于劣势时,寻求高方差策略(
matchup_win_probability < 0.40)。
规则
-
分类器委派纯粹性。 此技能 MUST NOT 实现贝叶斯数学。如果发现自己在计算后验概率、似然或归一化,请停下——这些工作属于
opponent-archetype-classifier。此技能负责提供分类体系(MLB 专用)、特征提取(Yahoo 专用)和输出格式。除了“对预测的赛季总量求和以计算cat_strength”之外,任何数学计算都值得警惕。 -
必须保留手动笔记。 用户会手动撰写第 1、5、6、8、9 节,其中包含此技能无法复现的策略笔记(例如“Jennifer 的邮件被退回,建议通过私信试探”)。盲目覆盖这些章节会毁掉用户的工作。始终采用读取-修改-写入的方式。提交前验证差异:仅允许修改 frontmatter 和第 2、3、4、7 节。
-
优雅处理抓取失败。 如果 Yahoo 页面返回 4xx/5xx,或会话未通过身份验证:不要猜测。将对应特征标记为
null,在 frontmatter 的scrape_errors:块中记录失败的 URL,并将confidence降低 0.2。仍应生成档案,只是置信度较低。有部分档案总比没有好。 -
遵守顺序更新原则。 上周的后验概率始终作为本周的先验概率。不要每周都从分类体系的先验概率重新开始(那会丢弃 1-4 周的证据)。唯一例外:如果
prior_profile.confidence < 0.20,则重新开始(先前的档案基本不可信)。 -
处理相关特征。
moves_per_week和faab_spent_pct高度相关(活跃的经理两者都会做)。将correlated_feature_pairs传给分类器,以便降低其权重。sp_roster_share和closer_count也同样如此(它们受阵容名额限制而相互取舍)。 -
不得根据原型臆造
cat_strength。cat_strength是一个基于实际阵容组成的独立估算值,而非从archetype推导而来。balanced球队如果外野手阵容较弱,其 SB 就低于平均水平;不要用“balanced = 各项都在 50 左右”来掩盖这一点。应根据阵容计算。 -
unknown是有效的原型。 当 classification_confidence < 40 时,写入archetype: unknown,并让archetype_confidence体现分类器的输出。证据不足时不要强行选出 MAP。下游 Agent 会在遇到unknown时回退到宽泛的启发式方法。 -
引用要求。 每份生成的档案都必须在
source_urls中列出准确的 Yahoo URL。每周信号文件必须列出全部 11 支球队的所有 URL(球队页面 URL 去重)。 -
单次模式与全部对手模式。 单队刷新(收到交易报价、观察到 FAAB 竞争时)只生成档案文件,不生成每周汇总信号。只有在全部 11 次刷新完成后,才生成每周汇总信号。
-
球队 slug 保持稳定。 slug 由球队名称转为小写并以连字符连接,在整个赛季中保持稳定(例如
jennys-team、springfield-isotopes)。如果经理在赛季中途更改球队名称,保留原 slug,并在 frontmatter 中存储新的team_name;不要重命名文件(这会破坏下游 Agent 的引用)。
快速参考
管道一行命令:
scrape_yahoo(4_pages) -> extract_mlb_features -> invoke(opponent-archetype-classifier,
taxonomy=mlb_10_archetype, prior=last_week_posterior, observation_weight=f(week))
-> compute_cat_strength(roster) -> read_existing_md -> merge_preserve_notes
-> atomic_write -> [if all_opponents] emit_weekly_signal
MLB 10 种原型分类(内置):
| 原型 | 核心信号 | 先验概率(第 1 周) |
|---|---|---|
balanced | 不放弃任何类别,全面争取各项数据 | 0.25 |
stars_and_scrubs | 4-5 名精英球员 + 替补席实力薄弱 | 0.10 |
punt_sv | 没有终结者,其他位置阵容充实 | 0.10 |
punt_sb | 进攻只依赖力量型表现 | 0.10 |
punt_wins_qs | 先发投手阵容单薄,重用后援投手(Marmol) | 0.05 |
hitter_heavy | sp_roster_share < 0.30 | 0.10 |
pitcher_heavy | sp_roster_share > 0.45 | 0.10 |
inactive | 没有任何操作,阵容过时 | 0.10 |
frustrated_active | 操作频繁 + 战绩不佳 | 0.05 |
unknown | 未达到明确判定阈值 | 0.05 |
先验概率之和为 1.00。根据 12 队联赛的基准发生率设置为有依据的分布(而非均匀分布)。
观测权重安排:
| 周次 | 权重 | 理由 |
|---|---|---|
| 1-2 | 0.25 | 只有选秀证据,噪声较大 |
| 3-4 | 0.45 | 首批弃留球员操作已可见 |
| 5-7 | 0.65 | 模式逐渐稳定 |
| 8-11 | 0.80 | 行为特征已较为明确 |
| 12+ | 0.90 | 剩余疑点均属真正的模糊情况 |
关键资源:
- resources/template.md:10 种原型分类的 MLB YAML(传递给分类器)、每个对手的
.md输出模板(符合opponent-profile-schema.md),每周摘要信号模板。 - resources/methodology.md:Yahoo 抓取 URL 流程、特征提取公式、cat_strength 估算器、读取-修改-写入协议、顺序更新协议、优雅降级处理。
- resources/evaluators/rubric_mlb_opponent_profiler.json:10 项质量标准(分类完整性、特征提取正确性、Yahoo 抓取覆盖率、分类器委派纯度、输出架构符合度、保留手动备注、顺序更新正确性、信号文件生成、抓取失败时的优雅降级、引用)。
所需输入:
team_name(字符串,单支球队)或all_opponents: trueyahoo_session(已认证的 Chrome 上下文)prior_profile(可选;如果缺失,则根据分类先验概率进行初始化)
生成的输出:
- 更新后的
context/opponents/<team-slug>.md(每支已刷新的球队一份)——保留手动备注 signals/wkNN-opponent-profiles.md(仅限all_opponents模式)——原型变化 + 置信度变化 + 反应性事件摘要
下游使用方(5 个 Agent):
mlb-lineup-optimizer——读取 §3 cat_strength + §6 best_response,以进行leverage_vs_opponent分析mlb-category-state-analyzer——读取 §2 原型 + §3,预测对手的争取或放弃策略mlb-faab-sizer——读取所有 11 支球队的 §4(waiver_aggression、faab_remaining),估算竞标人数mlb-trade-analyzer——读取 §4(trade_propensity、trade_cooperation_score)+ §5 弱项mlb-fantasy-coach——读取本周对手的 §6,用于生成晨间简报