@idiomark/adapter-github
GitHub adapter for the Idiomark (Personality Compression Protocol) system. This adapter extracts personality-relevant data from GitHub profiles, including commits, issues, pull requests, comments, and discussions.
Installation
npm install @idiomark/adapter-github
Authentication
You'll need a GitHub Personal Access Token to use this adapter. Create one at: https://github.com/settings/tokens
Required scopes:
public_repo- For public repository accessread:org- If accessing organization repositories
Usage
Basic Usage
import { GitHubAdapter } from '@idiomark/adapter-github'
const adapter = new GitHubAdapter({
token: 'your-github-token-here'
})
// Authenticate
await adapter.authenticate()
// Fetch all data with default options (last 90 days, limit 100)
const content = await adapter.fetchData()
// Extract raw text for personality analysis
const { rawContent, metadata } = await adapter.extractRawText()
console.log(`Extracted ${rawContent.length} items from: ${metadata.sources.join(', ')}`)
Advanced Usage
import { GitHubAdapter } from '@idiomark/adapter-github'
const adapter = new GitHubAdapter({
token: 'your-github-token-here',
username: 'specific-username' // Optional: will be fetched from token
})
// Fetch with custom options
const content = await adapter.fetchData({
limit: 500, // Maximum number of items to fetch
startDate: new Date('2024-01-01'),
endDate: new Date('2024-12-31'),
includeReplies: true, // Include comments and replies
includeReactions: true // Include reaction data
})
// Normalize content to standard Idiomark format
const normalized = content.map(item => adapter.normalize(item))
Fetch Specific Data Types
// Fetch only commits
const commits = await adapter.fetchCommits({
limit: 200,
startDate: new Date(Date.now() - 90 * 24 * 60 * 60 * 1000), // Last 90 days
endDate: new Date()
})
// Fetch only issues
const issues = await adapter.fetchIssues({ limit: 50 })
// Fetch only pull requests
const pullRequests = await adapter.fetchPullRequests({ limit: 50 })
// Fetch comments
const comments = await adapter.fetchComments({ limit: 100 })
// Fetch discussions (if enabled on repos)
const discussions = await adapter.fetchDiscussions({ limit: 50 })
// Fetch user profile
const profile = await adapter.fetchUserProfile()
Data Sources
The adapter extracts personality signals from multiple sources:
1. User Profile
- Bio and location
- Company and blog
- Account creation date
- Public activity stats (followers, repos, etc.)
2. Commits
- Commit messages (reveals communication style)
- Commit frequency
- Repository context (language, domain)
- Code review patterns (via commit comments)
3. Issues
- Issue titles and descriptions
- How users frame problems
- Technical language used
- Collaboration patterns (labels, reactions)
4. Pull Requests
- PR descriptions
- Code review approach
- Technical decision making
- Collaboration style
5. Comments
- Communication in code reviews
- Technical explanations
- Tone and style in discussions
- Interaction patterns
6. Discussions (if available)
- Community engagement
- Leadership patterns
- Knowledge sharing
Personality Signals Detected
The adapter captures these personality-relevant signals:
Communication Style
- Technical vs. casual language
- Directness in code review comments
- Use of emojis in messages
- Question vs. statement patterns
Technical Domains
- Programming languages (from repositories)
- Frameworks and tools (from code/commits)
- Areas of expertise (from issues/PRs)
Collaboration Patterns
- How they give feedback
- Response to criticism
- Leadership in discussions
- Mentoring behavior
Work Patterns
- Commit frequency and timing
- PR description detail level
- Issue reporting style
- Code organization preferences
Rate Limiting
The adapter handles GitHub API rate limits automatically:
Unauthenticated:
- Core API: 60 requests/hour
- Search API: 10 requests/minute
Authenticated:
- Core API: 5,000 requests/hour
- Search API: 30 requests/minute
The adapter will automatically wait for rate limit resets when needed. Consider using a token for better limits.
Error Handling
try {
const content = await adapter.fetchData()
} catch (error) {
if (error.message.includes('authentication')) {
console.error('Invalid token')
} else if (error.message.includes('404')) {
console.error('User or repository not found')
} else if (error.message.includes('rate limit')) {
console.error('Rate limit exceeded')
}
}
Private Profiles
If a user has a private profile or the token lacks permissions, the adapter will:
- Return
nullfor profile data - Skip private repositories
- Continue fetching public data
Output Format
interface GitHubAdapterOutput {
rawContent: string[] // Array of all text content
metadata: {
sampleSize: number // Number of items extracted
timeframe: {
from: string // ISO date string
to: string // ISO date string
}
sources: string[] // Types of data collected
}
}
API Limitations
-
Commit History: Limited to user's accessible repositories. Private repos require appropriate token scopes.
-
Discussions: Only available if repositories have GitHub Discussions enabled.
-
Search API: Some advanced search queries may not return all results due to GitHub's search ranking.
-
Private Profiles: Limited data available for users with strict privacy settings.
-
Historical Data: Very old commits or activity may not be accessible through the API.
Examples
Extract Full Personality Profile
import { GitHubAdapter } from '@idiomark/adapter-github'
import { IdiomarkExtractor } from '@idiomark/core'
async function extractGitHubPersonality(username: string, token: string) {
const adapter = new GitHubAdapter({ token, username })
await adapter.authenticate()
// Fetch last 6 months of activity
const sixMonthsAgo = new Date(Date.now() - 180 * 24 * 60 * 60 * 1000)
const { rawContent, metadata } = await adapter.extractRawText({
startDate: sixMonthsAgo,
limit: 1000,
includeReplies: true
})
// Use Idiomark extractor to analyze
const extractor = new IdiomarkExtractor()
const idiomark = await extractor.extract(rawContent, {
entity: {
name: username,
type: 'human',
sources: ['github']
},
sampleSize: metadata.sampleSize,
timeframe: metadata.timeframe
})
return idiomark
}
Compare Developer Styles
async function compareDevelopers(usernames: string[], token: string) {
const results = await Promise.all(
usernames.map(async (username) => {
const adapter = new GitHubAdapter({ token, username })
const { rawContent } = await adapter.extractRawText({ limit: 200 })
// Analyze commit message style
const commits = rawContent.filter(c => c.type === 'commit')
const avgCommitLength = commits.reduce((sum, c) =>
sum + c.text.split(' ').length, 0
) / commits.length
return { username, avgCommitLength, totalCommits: commits.length }
})
)
return results
}
Contributing
Contributions are welcome! Please see the main Idiomark repository for guidelines.
License
MIT