mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-14 00:13:05 +08:00
Smallest interesting browser-skill: scrapes HN front page, returns
30 stories as JSON. No auth, stable HTML, fully fixture-tested.
Files:
SKILL.md frontmatter + prose
script.ts exports parseStoriesFromHtml(html)
main: goto + html + parse + JSON.stringify
_lib/browse-client.ts vendored copy of the SDK
fixtures/hn-2026-04-26.html captured front page (5 stories)
script.test.ts 13 assertions against the fixture
The parser is a pure function over HTML so script.test.ts runs
without a daemon (just imports parseStoriesFromHtml and asserts).
This exercises every Phase 1 component end-to-end:
- browse-client SDK (script imports browse from ./_lib/)
- 3-tier lookup (hackernews-frontpage lives in the bundled tier)
- scoped tokens (read+write is enough for goto + html)
- spawn lifecycle (\$B skill run hackernews-frontpage)
- file-fixture testing (\$B skill test hackernews-frontpage)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1.4 KiB
1.4 KiB
name, description, host, trusted, source, version, args, triggers
| name | description | host | trusted | source | version | args | triggers | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| hackernews-frontpage | Scrape the Hacker News front page (titles, points, comment counts). | news.ycombinator.com | true | human | 1.0.0 |
|
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.