feat(sync): add GitHub Discussion crawling support#21
Open
mvanhorn wants to merge 1 commit intopwrdrvr:mainfrom
Open
feat(sync): add GitHub Discussion crawling support#21mvanhorn wants to merge 1 commit intopwrdrvr:mainfrom
mvanhorn wants to merge 1 commit intopwrdrvr:mainfrom
Conversation
Add opt-in Discussion sync via --include-discussions flag on sync and refresh commands. Uses Octokit's built-in GraphQL to query the Discussions API. Discussions are stored in the threads table with kind='discussion' and flow through embedding and clustering automatically. Handles repos with Discussions disabled gracefully (warns and returns empty). Adds 'discussion' to threadKindSchema contract enum. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Add opt-in GitHub Discussion crawling via
--include-discussionsflag on sync and refresh commands. Discussions are stored in the existingthreadstable withkind = 'discussion'and flow through embedding, clustering, and search automatically.Why
Many repos use GitHub Discussions for feature requests, Q&A, and bug reports that overlap with issues. When someone files a Discussion about "download stalls" and another person opens an issue about "download timeout", ghcrawl currently can't detect the relationship because it only crawls issues and PRs.
Adding Discussion support catches cross-type duplicates. The
threadstable already has a textkindcolumn, and the downstream pipeline (documents, embeddings, clustering, search) is kind-agnostic, so discussions work with zero changes to that code.Technical approach
GitHub Discussions require the GraphQL API (no REST endpoint exists). This uses Octokit's built-in
octokit.graphql()support, so no new dependencies are needed. ThelistRepositoryDiscussions()method inclient.tshandles cursor-based pagination,sincecutoff,limit, and per-page delay matching the existing REST client behavior.If Discussions are disabled on a repo, the GraphQL error is caught, a warning is logged, and an empty array is returned. No crash.
Each discussion is mapped to the same record shape as issues/PRs via
mapDiscussionToRecord()(client.ts:94). The discussion category name (e.g., "Feature Request", "Q&A") is prepended to labels so it appears in the cluster display.Changes
packages/api-contract/src/contracts.ts'discussion'tothreadKindSchema, addincludeDiscussionsto refresh requestpackages/api-core/src/github/client.tslistRepositoryDiscussions()with GraphQL pagination +mapDiscussionToRecord()helperpackages/api-core/src/github/client.test.tspackages/api-core/src/service.tssyncRepository(), pass flag throughrefreshRepository()packages/api-core/src/api/server.tsdiscussionin kind filter for threads endpointapps/cli/src/main.ts--include-discussionsflag to sync/refresh, update usage textUsage
Testing
pnpm buildpassesmapDiscussionToRecord()pass (normal mapping, null author, null body, null category, closed state, open state, category-as-label)The
threadKindSchemaenum change atcontracts.ts:3is the only contract-level change. Existing consumers that don't use--include-discussionssee no behavioral difference because no discussions are synced by default.This contribution was developed with AI assistance (Claude Code + Codex).