* feat(reddit/read): add --expand-more via /api/morechildren + 7-kind discriminated union PR B of the rdt-cli parity follow-up (after PR #1491, see #1481 thread). Closes the second-largest gap: Reddit's "[+N more replies]" stubs were opaque markers in the comment tree. With --expand-more, the adapter follows them by POST-ing the t1 ids to /api/morechildren.json, then re-threads the returned things back into the tree by parent_id before walking it. New args: - `--expand-more` (bool, default false) — turn on stub expansion. - `--expand-rounds <N>` (int, default 2, range [1, 5]) — Reddit returns fresh "more" stubs at the expansion depth boundary, so up to N rounds are run. Strictly validated via `parseExpandRounds` — out-of-range raises ArgumentError BEFORE `page.goto`, no silent clamp. Boy-Scout: the in-browser script now returns a 7-kind discriminated union instead of a flat row array (matching the PR #1428 / #1491 sediment). Each kind maps 1:1 to a typed error on the Node side: - `inaccessible` → EmptyResultError 401/403/404 on /comments/<id>.json (post-specific access, not session-level auth — applies the PR #1491 review-side sediment "inaccessible-resource vs session-auth"). - `auth` → AuthRequiredError 401/403 on /api/morechildren (expand-write endpoints often demand a logged-in session even when the read endpoint is anonymous). - `http` → CommandExecutionError - `malformed` → CommandExecutionError 200 with unexpected envelope shape — schema drift, not empty. - `parser-drift` → CommandExecutionError tree had t1 entries but the walker produced no rows (PR #1491 review-side sediment "post-construction 0 rows + pre-walk non-empty = parser drift, not legitimate empty"). - `expand-failed`→ CommandExecutionError /api/morechildren returned a non-empty json.errors array. - `ok` → returns rows[]. Intermediate keys (kind / detail / httpStatus / where / rows / expandMeta) deliberately avoid the declared columns (type / author / score / text) per the PR #1329 silent-column-drop sediment. Tests: clis/reddit/read.test.js — 11 tests - Adapter shape (browser / siteSession / columns / args) - --expand-more / --expand-rounds present with correct types/defaults - parseExpandRounds default / range / non-integer rejection - Pre-navigation validation (bad --expand-rounds doesn't reach goto) - kind=ok happy path (POST + L0 rows) - 6-kind error → typed error mapping - Unknown envelope shape → CommandExecutionError - Evaluate script embeds expandMore/expandRounds/sort/limit literals - Evaluate script contains /api/morechildren POST scaffolding - Evaluate script never names declared columns as intermediate keys Full reddit suite 48/48; full project 3402/3402. Audits: typed-error-lint 189/189 (0 new), silent-column-drop 103/103 (0 new). Manifest 815 → 815 (existing read entry gets 2 new args). Existing --limit / --depth / --replies / --max-length keep their original Math.max-style behaviour (grandfathered in the baseline); only the new --expand-rounds flag fails fast per the typed-errors standard. Refs: https://github.com/jackwener/rdt-cli (browse.read --expand-more) * fix(reddit): preserve expanded comment tree order * fix(reddit): fail on partial morechildren expansion
3.1 KiB
Mode: 🔐 Browser · Domain: reddit.com
Commands
| Command | Description |
|---|---|
opencli reddit hot |
Hot posts from a subreddit (or frontpage if none) |
opencli reddit frontpage |
Frontpage / r/all listing |
opencli reddit home |
Personalized Best feed (requires login) |
opencli reddit popular |
Trending posts on /r/popular |
opencli reddit search |
Search posts |
opencli reddit subreddit |
Posts from a specific subreddit, with sort and time filters |
opencli reddit subreddit-info |
Subreddit metadata (subscribers, active, NSFW, created, description) |
opencli reddit read |
Read a post thread with comments |
opencli reddit user |
View a user profile |
opencli reddit user-posts |
A user's submitted posts |
opencli reddit user-comments |
A user's comments |
opencli reddit whoami |
Show the currently logged-in Reddit identity |
opencli reddit upvote |
Vote on a post or comment |
opencli reddit save |
Save / unsave a post or comment |
opencli reddit comment |
Comment on a post |
opencli reddit reply |
Reply to a comment |
opencli reddit subscribe |
Join / leave a subreddit |
opencli reddit saved |
List your saved items |
opencli reddit upvoted |
List your upvoted posts |
Usage Examples
# Quick start
opencli reddit hot --limit 5
# Read one subreddit
opencli reddit subreddit python --limit 10
# Subreddit metadata (subscribers / active / NSFW / created / description)
opencli reddit subreddit-info AskReddit
# Personalized Best feed (requires login)
opencli reddit home --limit 10
# Who am I logged in as?
opencli reddit whoami
# Read a post thread
opencli reddit read 1abc123 --depth 2
# Read with "more comments" expansion via /api/morechildren.json
opencli reddit read 1abc123 --depth 3 --expand-more --expand-rounds 3
# Comment on a post
opencli reddit comment 1abc123 "Great post"
# Reply to a comment
opencli reddit reply okf3s7u "Thanks for the context"
# JSON output
opencli reddit hot -f json
# Verbose mode
opencli reddit hot -v
Auth-required commands
whoami, home, saved, upvoted, subscribe, upvote, save, comment,
and reply all require a logged-in reddit.com cookie session. When the
session is missing or expired they raise AuthRequiredError (exit code 5)
instead of silently returning empty rows.
For subreddit-info, missing / banned / private / quarantined subreddits raise
EmptyResultError (exit code 6) so the output table never contains a silent
sentinel row.
For read, deleted / quarantined / private posts (HTTP 401/403/404 on
/comments/<id>.json) also raise EmptyResultError. --expand-more follows
Reddit's "more comments" stubs by calling /api/morechildren.json up to
--expand-rounds times (default 2, max 5). If the morechildren endpoint
itself rejects the request with 401/403, that's surfaced as
AuthRequiredError because writeable/expand endpoints often require a logged-
in session even though the post listing is public.
Prerequisites
- Chrome running and logged into reddit.com
- Browser Bridge extension installed