hackernews-frontpage
- 信任分
- 92/100
- 兼容 Agent
- 1
- 领域
- 通用
- 兼容 Agent
- Claude Code
- 信任分
- 92 / 100 · 已通过审计
- 作者 / 版本 / 许可
- @garrytan · v1.0.0 · 未声明 license
- 安装命令数
- 1 条
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
想读作者英文原文? ↓ 滚到正文区切换 · 在 GitHub 查看 ↗
设计思路
hackernews-frontpage 不是日常用的「读 HN 工具」,而是 gstack browser-skill 体系的官方参考实现——最小、最稳、最可测的样板:无登录、HTML 结构稳定(HN 的 tr.athing)、确定性输出、对 fixture 友好。Phase 1 的每个组件(SDK / scoped token / 三层查找 / spawn 生命周期)都被 $B skill run hackernews-frontpage 和 bundled 的 script.test.ts 跑一遍,相当于一份活的烟雾测试。
用法
$ $B skill run hackernews-frontpage
{
"stories": [
{ "rank": 1, "title": "...", "url": "...", "points": 412, "comments": 87 },
...
],
"count": 30
}
工作机制
- 通过 daemon 跳到
https://news.ycombinator.com - 读 HTML
- 按 HN 稳定的
tr.athing结构解析每行 story 成 typedStory - stdout 输出单份 JSON
为什么是参考 skill
最小有趣 = 学习 cost 最低,但又把整套 browser-skill 框架的所有关键面都覆盖了。HN 的 HTML 一旦轮换、selector 失效,捕获的 fixture 测试会先于用户报失败——这正是它存在的意义。
适合谁
- 第一次写 browser-skill 的开发者,照着学最快
- 想搭自己的「站点抓取脚本」体系的工程师
- 给团队培训 gstack browser-skill 模式的指导者
何时不该用
- 你要的就是「读 HN」内容——直接 RSS / API 更省
- 站点没有稳定结构——这套范式优势小
配套
browse(执行 verb)、gstack(入口)、webapp-testing(写测试 / fixture)、scrape(更通用的抓取场景)。
Hacker News front-page scraper
Scrapes the Hacker News (news.ycombinator.com) front page and returns the
top 30 stories as JSON. Each story has its rank, title, link URL, point count,
and comment count.
Usage
$ $B skill run hackernews-frontpage
{
"stories": [
{ "rank": 1, "title": "...", "url": "...", "points": 412, "comments": 87 },
...
],
"count": 30
}
How it works
- Navigates to
https://news.ycombinator.comvia the daemon. - Reads the page HTML.
- Parses each story row (HN's stable
tr.athingstructure) into a typedStoryrecord. - Emits a single JSON document on stdout.
Why this is the reference skill
hackernews-frontpage is the smallest interesting browser-skill: no auth,
stable HTML, deterministic output, file-fixture-friendly. Every Phase 1
component (SDK, scoped tokens, three-tier lookup, spawn lifecycle) is
exercised by $B skill run hackernews-frontpage and the bundled
script.test.ts.
When the HN HTML rotates and our selectors break, the test fails against the captured fixture before users notice. That's the point.