Skip to content

Improve Hacker News comment structure clarity with labels - #20

Merged
brianlovin merged 1 commit into
mainfrom
claude/enhance-comment-context-bOAtE
Jan 26, 2026
Merged

Improve Hacker News comment structure clarity with labels#20
brianlovin merged 1 commit into
mainfrom
claude/enhance-comment-context-bOAtE

Conversation

@brianlovin

Copy link
Copy Markdown
Owner

Summary

Enhanced the comment formatting in the story context builder to make the hierarchical structure of Hacker News discussions more explicit and easier to follow. Added clear labels and a guide to help users understand the comment nesting and relationships.

Key Changes

  • Added a "Comment Structure Guide" section that explains how to interpret the comment hierarchy
  • Implemented comment labeling system:
    • Root-level comments are now marked with [ROOT COMMENT #N] tags and numbered sequentially
    • Nested replies are marked with [Reply to username] tags to show parent relationships
    • Indentation continues to visually represent nesting depth
  • Updated formatCommentsForContext() function signature to track:
    • parentUser: The username of the parent comment for nested replies
    • rootCommentIndex: A counter object to track and number root comments across the entire tree
  • Improved readability by passing parent user information through recursive calls

Implementation Details

  • Used an object { value: number } for rootCommentIndex to maintain state across recursive calls (JavaScript pass-by-reference)
  • Root comments are identified by depth === 0 condition
  • Parent user information is passed down the recursion chain to label replies appropriately
  • The guide text is added once before processing all comments, providing context for the entire discussion section

Add structural annotations to comments passed to LLMs:
- Root comments labeled as [ROOT COMMENT #N] to identify key conversation pillars
- Nested replies labeled as [Reply to username] to show conversation branches
- Added preamble explaining the comment structure to help LLMs understand discussion hierarchy
@brianlovin
brianlovin merged commit 5e61199 into main Jan 26, 2026
1 check passed
@brianlovin
brianlovin deleted the claude/enhance-comment-context-bOAtE branch January 26, 2026 15:18
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