feat(nowcoder): add comments command#2166
Open
aolast wants to merge 1 commit into
Open
Conversation
aolast
force-pushed
the
agent/nowcoder-comments
branch
3 times, most recently
from
July 22, 2026 14:24
8bdfbc6 to
5817913
Compare
aolast
force-pushed
the
agent/nowcoder-comments
branch
from
July 22, 2026 14:50
5817913 to
95f1de9
Compare
aolast
force-pushed
the
agent/nowcoder-comments
branch
from
July 22, 2026 15:00
95f1de9 to
f86a2ec
Compare
aolast
marked this pull request as ready for review
July 22, 2026 15:08
Author
|
Hey @jackwener , when you get a chance, could you please take a look at this PR or assign a reviewer? thanks : ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a read-only
nowcoder comments <id>command for mining comment content, authors, engagement, and structured reply relationships through Nowcoder's public Sparta API.It accepts a discussion ID, moment UUID, numeric moment entity ID, or supported Nowcoder URL without requiring a browser session or login.
Comment model
Each row includes:
id,root_id,parent_id,depth,ancestry_completeauthor_id,author,reply_to_author_id,reply_to_authorcontent,likes,replies,direct_replies,time,locationrepliesalways preserves Nowcoder's server-reported total. With--with-replies,direct_repliescontains direct child edges in the fetched result; without expansion it isnull. Structural filtering and sorting use--min-direct-repliesand--sort direct-replies.Reply depth is reconstructed from
toCommentId. If a truncated result omits an ancestor, affected rows retain theirparent_id, reportdepth: null, and setancestry_complete: false. Known parent edges inside incomplete components are still emitted parent-first.The raw
ip4payload field is intentionally not exposed. The command returns the coarse API-providedip4Locationaslocation; stable author tracking usesauthor_id.Mining controls
--order default|new|hot--min-likes,--min-replies,--min-direct-replies--author-id,--author--contains,--since,--until--sort thread|likes|replies|direct-replies|time--limit,--replies-limit(maximum 100)Pagination deduplicates IDs across pages and continues until the requested unique-row limit or the API's final
totalPage. A short non-empty page is treated as final only when no validtotalPageis available; an empty page always stops pagination, protecting against stale page counts. Requests also retain a 100-page safety cap.All scalar options require explicit values. The removed
--parentmode is not exposed because the public reply endpoint only accepts a top-level thread root and cannot validate ownership against the requested post;--with-repliesis the supported post-scoped contract.API discovery
The endpoint mapping was derived by inspecting Nowcoder's post-detail comment UI requests and replaying the public Sparta calls:
/api/sparta/detail/content-data/detail/<id>/api/sparta/detail/moment-data/detail/<uuid>/api/sparta/comment/list-by-pageObserved entity types are
250for discussions,74for moments, and2for replies below a top-level comment.HTTP, JSON, envelope, record, ID, pagination, and filter failures are validated explicitly and mapped to typed OpenCLI errors. Plain-text fields preserve code-like content; HTML stripping is limited to the legacy
contentfield.This remains a Draft for maintainer feedback before marking it ready.
Type of Change
Checklist
docs/adapters/index.mdupdatedCliErrorsubclassesLive verification
For root
22795572, both runs returnedreplies: 1; the unexpanded row returneddirect_replies: null, and the expanded row returneddirect_replies: 1.Tests
npm run test:adapter -- --run clis/nowcoder/comments.test.js— 17/17 passednpm test— 560 files passed; 6366 tests passed, 1 skippednpm run typecheck— passednpm run build— passed; manifest regeneratednpm run docs:build— passednode dist/src/main.js validate— 1302 commands, 0 errorsnode dist/src/main.js convention-audit nowcoder/comments -f json— 0 violations