用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/hyhmrright/StockAI --skill new-strategy命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | new-strategy |
| description | 在 sidecar/strategies/ 新增新闻抓取策略,完成 ScrapeStrategy 实现与 registry 注册 |
向用户询问以下信息(若已在请求中提供则跳过):
bing-news读 sidecar/strategies/base.ts 确认 ScrapeStrategy 接口与 PlaywrightStrategy 基类。按类型选参考:
google-news-rss.ts(直接 implements ScrapeStrategy,绝不调用 ctx.getPage(),从而完全跳过 Chromium 启动,省 1–3 秒)yahoo.ts(extends PlaywrightStrategy,只需实现 getUrl 与 parse,基类已处理 goto / 超时 / 浏览器初始化失败的兜底)sidecar/strategies/<id>.ts:
export class XxxStrategy implements ScrapeStrategy,提供 readonly name 与 async scrape(symbol, ctx)export class XxxStrategy extends PlaywrightStrategy,实现 getUrl(symbol) 与 protected parse(html, symbol),必要时覆盖 getWaitUntil()三条硬约定:
sidecar/http.ts 的 fetchWithPolicy(url, policy)。UA 与超时的唯一来源是 config.ts 的 HTTP_DEFAULTS——不要在策略里另写 UA 字面量或 AbortSignal.timeout(...)。[] 而非抛出,让 registry 回退到下一策略。基类已对 Playwright 路径做了这层兜底;纯 fetch 策略要自己 try/catch。sidecar/parsers/html.ts,别在策略里手搓正则。返回类型统一 StockNews[](from '../../shared/types')。sidecar/strategies/registry.ts:
import { XxxStrategy } from './<id>';
// StrategyRegistry.strategies 数组追加:
new XxxStrategy(),
顺序原则:能跳过 Chromium 的纯 fetch 策略排在 Playwright 策略之前(首个返回非空结果即停止)。
⚠️
registry.test.ts断言GoogleNewsRSSStrategy位于索引 0。若新策略要插到最前面,需一并更新该断言——否则测试红。
cd sidecar && bun test strategies
bun tsc --noEmit
纯 fetch 策略必须补一个离线解析测试(参考 google-news-rss.test.ts):把一份真实响应存成 fixture 字符串,经 fetchImpl 注入,断言解析结果。默认套件必须离线可跑——真网络断言只能进 *.integration.ts(只在 bun run test:integration 跑)。