Repository navigation
feat: use site rank in front and read - #5
Conversation
Network failures, rate limits and server errors now exit 8. Previously `read` and `user` reported every failure as not found (5), and `search` and `front` exited 1, so callers could not tell when to retry. `hn user` moves to the Firebase API because Algolia answers 500 for unknown users. An empty `hn front` exits 3, and `hn status --json` exits 8 when the API is down.
Algolia has no ranking: its front_page tag returns the right stories in another order, and threads come back oldest first. Take the order from the Firebase API and the details from Algolia, so `hn front` matches the site and `hn read` opens with the comments readers actually see. `hn front --feed` reaches the other lists. Job posts have no story tag on Algolia, so anything it lacks comes from single Firebase lookups. `hn read` now caps its output, because a large thread ran to 140 KB by default. It reports what it cuts, and shows comment IDs so a collapsed thread can be opened directly.
|
The ranking bug is real. Algolia's I'm on board with the new This carries #4's commit, so it needs #4 first. I'll handle the CHANGELOG and README overlap across the four PRs, no need to rebase for that. |
|
One more fix to fold in with the help text. |
|
I'd like this merged: agents reading threads through If it helps, I'm happy to take the two requested changes (the |
# Conflicts: # README.md # internal/api/client.go # internal/api/client_test.go # internal/cmd/root.go
|
Thanks for checking those threads. No follow-up PR needed: I brought this branch up to date with master, added both fixes on top of @shbernal's commits, and merged it. |
|
This shipped in v0.4.0. |
Built on #4 for the Firebase client, so this diff shows that commit until it merges.
Algolia has no site ranking. Its
front_pagetag returns the right stories in a different order, and threads come back oldest first. When I compared against the live site, 5 of 30 stories inhn frontwere in the right position, and its #1 was really #19.hn readopened one large thread with a comment reading "oof". The skill calls that "top comments".hn fronttakes the order from Firebase and the details from one Algolia request. Job posts have nostory_<id>tag on Algolia, so anything it lacks comes from single Firebase lookups. Position now matches the site, 30 of 30.--feedreachesnew,best,ask,showandjob.hn readorders comments by site rank, plus the replies of the comments it shows. Deeper replies stay oldest first, because ranking them needs a request per comment.It also caps its output now, which changes the default. On that thread, plain
hn readprinted 141 KB, about 35k tokens for one call. The default is now 18.6 KB in about 1.3s:-n--replies--depth--max-charsEach cut says what it dropped:
[12 more replies],[546 more comments],[+116 chars]. Comments now show#ID, andhn read COMMENT_IDopens a collapsed thread.--expandstill prints everything, and--jsonreturns the whole tree in rank order.If Firebase fails during
read, it warns on stderr and prints oldest first.The README example
.comments | lengthnever matched the JSON. It's now.children.Checked with
make test,golangci-lint, and live runs of all six feeds and a comment drill-down.