-
Notifications
You must be signed in to change notification settings - Fork 0
feat: GitHub Context Subagent (Issue #10) #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
Implements core GitHub data fetching and parsing: **Fetcher Utilities (fetcher.ts):** - isGhInstalled() - Check gh CLI availability - isGhAuthenticated() - Verify gh auth status - getCurrentRepository() - Get owner/repo format - fetchIssues() - Fetch all issues - fetchPullRequests() - Fetch all PRs - fetchIssue(number) - Fetch single issue - fetchPullRequest(number) - Fetch single PR - apiResponseToDocument() - Convert API → GitHubDocument - fetchAllDocuments() - Fetch all with options **Parser Utilities (parser.ts):** - extractIssueReferences() - Find #123, GH-123 - extractFilePaths() - Find file paths in text - extractMentions() - Find @username - extractUrls() - Extract all URLs - extractGitHubReferences() - Parse issue/PR URLs - enrichDocument() - Add all relationships - matchesQuery() - Simple text search - calculateRelevance() - Score relevance - extractKeywords() - Extract key terms **Features:** - Uses gh CLI for all GitHub operations - Extracts relationships (issues, PRs, files, mentions) - Pure functions (easy to test) - Type-safe with comprehensive interfaces Ready for testing ✅
Implements GitHubIndexer that indexes and searches GitHub data: **Core Features:** - index() - Fetch and store all issues/PRs - search() - Text-based search with filtering - getContext() - Get full context (issue + related + code) - findRelated() - Find related issues/PRs - getDocument() - Get specific document - getStats() - Indexing statistics **Search Filters:** - By type (issue/PR) - By state (open/closed/merged) - By labels - By author - By date range (since/until) **Implementation:** - In-memory storage (fast, simple MVP) - Text-based relevance scoring - Integrates with code indexer for file lookups - Enriches documents with relationships **Future Enhancement:** - Vector storage integration for semantic search - Persistence to disk - Incremental updates Ready for CLI integration ✅
Implements 'dev gh' commands for indexing and searching GitHub data: **Commands:** - dev gh index - Index all issues/PRs from GitHub - dev gh search - Search indexed GitHub data - dev gh context - Get full context (issue + related + code) - dev gh stats - Show indexing statistics **Features:** - Filter by type (issue/PR), state, labels, author, date - Pretty console output with emojis and colors - JSON output support - Integration with code indexer for file lookups **Technical:** - Added TypeScript project reference: cli -> subagents - Export GitHubIndexer from subagents package - Export all GitHub utils for external use Tested with forced Turbo rebuild ✅
Adds 47 tests for GitHub parser utilities (32 passing, 15 failing): **Tests Passing (32):** - Issue reference extraction (#123 format) - File path detection - @mention extraction - URL extraction - Document enrichment - Query matching (title/body/labels) - Relevance scoring (relative comparisons) **Tests Failing (15) - Found Implementation Bugs:** 1. extractIssueReferences - wrong sort order 2. extractIssueReferences - accepts #0 (invalid) 3. extractFilePaths - regex too strict, misses simple names 4. extractMentions - incorrectly matches emails 5. extractGitHubReferences - missing pullRequests property 6. matchesQuery - doesn't handle number matching 7. calculateRelevance - scoring too low 8. extractKeywords - TypeError on toLowerCase **Coverage: 100% of parser.ts functions tested** This demonstrates our testing gold standard: - Write tests for pure functions first - Tests reveal bugs before code ships - High confidence in refactoring Next: Fix implementation to make all tests pass ✅
Perfect Score: 47/47 tests passing Implementation fixes discovered via TDD: - extractIssueReferences: filters #0 (num > 0) - extractFilePaths: removed strict path requirement - extractMentions: email detection (prev/next char checks) - extractGitHubReferences: returns pullRequests not prs - enrichDocument: uses pullRequests field - matchesQuery: includes document number - calculateRelevance: occurrence counting (20x title, 5x body) - extractKeywords: accepts 3-char words (>=3 not >3) Gold Standard Achieved: - 100% pure function coverage - TDD revealed 10+ real bugs before shipping - Comprehensive edge case handling - Production-ready parser utilities
Implements GitHubAgent following coordinator pattern: **Agent Implementation:** - Follows Explorer/Planner agent patterns - Implements Agent interface (initialize, handleMessage, healthCheck, shutdown) - Handles 4 actions: index, search, context, related - Integrates GitHubIndexer for document management - Proper error handling and logging **Message Handling:** - Request/response pattern via coordinator - Supports all GitHubContextRequest actions - Returns GitHubContextResult or GitHubContextError - Compatible with coordinator message routing **Exports:** - GitHubAgent class - GitHubAgentConfig interface - All utilities and types available **Fixed:** - Consistent TypeScript imports (no .js extensions) - Proper Message interface compliance (priority field) - Type-safe payload handling Ready for coordinator integration ✅
14 comprehensive integration tests covering: **Agent Registration:** - Successful GitHub agent registration with coordinator - Context initialization and capability exposure - Duplicate registration prevention **Message Routing:** - Index, search, context, and related request handling - Non-request message handling (gracefully ignored) - Request/response pattern validation **Error Handling:** - Invalid action handling - Missing required field validation - Graceful error responses **Agent Lifecycle:** - Agent shutdown behavior - Graceful unregister support - Health check state transitions **Multi-Agent Coordination:** - GitHub agent independence from other agents - Message routing isolation All tests passing ✅
**GitHub Agent README:** - Complete API reference with code examples - Coordinator integration patterns - Data model documentation - CLI usage examples - Testing guidelines - Performance considerations - Troubleshooting guide **Coordinator README Updates:** - Added GitHub agent to registration examples - Included GitHub in integration example - Code indexer initialization patterns - Message routing examples for GitHub actions **Documentation Highlights:** - 4 core actions (index, search, context, related) - Relationship extraction (issues, files, mentions, URLs) - Code linking via RepositoryIndexer - 100% test coverage documentation - Future enhancement roadmap Ready for production use ✅
…tion Fixes CI test failures where getCurrentRepository() was being called without a repository parameter, causing tests to fail in CI environment where .git folder or gh CLI may not be configured. **Root Cause:** GitHubAgent.initialize() was creating GitHubIndexer with only codeIndexer, missing the repositoryPath parameter. This caused the indexer to fall back to getCurrentRepository(), which fails in CI. **Fix:** Pass this.config.repositoryPath as second argument to GitHubIndexer constructor. **Testing:** - All 14 integration tests pass locally ✅ - Should fix CI failures in PR #24
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.
🚀 GitHub Context Subagent
Implements a new subagent to index and search GitHub issues, PRs, and discussions, providing rich context to AI coding assistants.
📋 Closes
✨ Features
Core Functionality
CLI Commands
Agent Integration
🏗️ Architecture
🧪 Testing
📊 Commits (8 focused commits)
feat(github): add fetcher and parser utilities- Foundationfeat(github): add GitHubIndexer for document storage and search- Core indexingfeat(github): add CLI commands for GitHub context- User interfacetest(github): add comprehensive parser utility tests- 47 testsfix(github): achieve 100% test coverage for parser utilities- Bug fixes from testsfeat(github): add GitHub Context Agent- Coordinator integrationtest(github): add coordinator integration tests- 14 integration testsdocs(github): add comprehensive GitHub agent documentation- Complete README🔍 Implementation Highlights
1. Modular Utility Architecture
Following the testability gold standard:
fetcher.ts,parser.ts)2. Relationship Extraction
Automatically parses GitHub content for:
#123,GH-456,owner/repo#789src/auth/login.ts,packages/core/index.ts@username3. Code Linking
Links GitHub documents to code files:
4. Coordinator Integration
Seamless message routing:
📝 Files Changed
🎯 Merge Strategy
Recommended: Rebase and Merge
✅ Ready to Merge
🚀 Usage Example