Skip to content

feat(xiaohongshu): add note command and nested reply support for comments#599

Merged
jackwener merged 4 commits into
jackwener:mainfrom
0xsegfaulted:feat/xiaohongshu-note-and-replies
Mar 30, 2026
Merged

feat(xiaohongshu): add note command and nested reply support for comments#599
jackwener merged 4 commits into
jackwener:mainfrom
0xsegfaulted:feat/xiaohongshu-note-and-replies

Conversation

@0xsegfaulted
Copy link
Copy Markdown
Contributor

Summary

  • New xiaohongshu note command: Read full note content (title, author, description, engagement metrics, tags) from any public note page
  • Enhanced xiaohongshu comments --with-replies: Extract nested replies (楼中楼) with reply_to attribution and per-reply like counts
  • Shared note-helpers.ts: Side-effect-free parseNoteId and buildNoteUrl utilities, avoiding cross-module command registration leakage
  • URL token preservation: When user passes a full search_result URL with xsec_token, navigate to it directly instead of stripping the token (fixes XHS security block on bare /explore/<id> access)
  • Zero-count normalization: Placeholder text like "赞"/"收藏"/"评论" is normalized to "0" for notes with zero interactions

New files

  • src/clis/xiaohongshu/note.ts — note content reader
  • src/clis/xiaohongshu/note.test.ts — 13 tests
  • src/clis/xiaohongshu/note-helpers.ts — shared URL parsing utilities

Modified files

  • src/clis/xiaohongshu/comments.ts--with-replies flag, buildNoteUrl navigation
  • src/clis/xiaohongshu/comments.test.ts — reply-related tests

Test plan

  • All 839 unit/adapter tests pass (0 failures)
  • E2E: opencli xiaohongshu note <url> returns title, author, content, likes, collects, comments, tags
  • E2E: opencli xiaohongshu comments <url> --with-replies returns main comments + nested replies with is_reply/reply_to columns
  • Codex review: 3 rounds, all issues resolved (zero-count normalization, cross-module side-effect extraction)
  • No duplicate PRs in upstream

🤖 Generated with Claude Code

0xsegfaulted and others added 4 commits March 30, 2026 23:17
…ents

Add `xiaohongshu note` command to read full note content (title, author,
description, engagement metrics, tags) from public note pages.

Enhance `xiaohongshu comments` with `--with-replies` flag to extract
nested replies (楼中楼), including reply_to attribution and per-reply
like counts. Limit logic counts only top-level comments so replies
are included for free.

Extract shared `parseNoteId` into side-effect-free `note-helpers.ts`
to avoid cross-module command registration leakage.

Normalize non-numeric engagement placeholders ("赞"/"收藏"/"评论")
to "0" for zero-count notes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update xiaohongshu adapter documentation and README command table
to reflect the new note command and enhanced comments with nested
reply support.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jackwener jackwener force-pushed the feat/xiaohongshu-note-and-replies branch from a8cb8cd to 85f8be3 Compare March 30, 2026 15:21
@jackwener jackwener merged commit d080385 into jackwener:main Mar 30, 2026
@jackwener
Copy link
Copy Markdown
Owner

Merged after review. I specifically looked at the design intent here: complete the xiaohongshu content-reading chain and make nested replies actually reliable. I patched the reply flow so --with-replies expands reply threads before scraping, hardened limit parsing, and validated with targeted Vitest, typecheck, and build before merge. Thanks for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants