黑客新闻头版

其他 社区 v1.0.0

技能解读

设计思路

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
}

工作机制

  1. 通过 daemon 跳到 https://news.ycombinator.com
  2. 读 HTML
  3. 按 HN 稳定的 tr.athing 结构解析每行 story 成 typed Story
  4. 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(更通用的抓取场景)。

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
通用
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
92 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@garrytan · v1.0.0 · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 命令执行
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# 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

1. Navigates to `https://news.ycombinator.com` via the daemon.
2. Reads the page HTML.
3. Parses each story row (HN's stable `tr.athing` structure) into a typed
   `Story` record.
4. 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.

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。