@elizaos/plugin-github 1.2.9 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.js +1870 -6835
- package/dist/index.js.map +27 -1
- package/package.json +67 -63
- package/.npmignore +0 -5
- package/README.md +0 -658
- package/dist/index.d.ts +0 -563
- package/tsup.config.ts +0 -32
package/README.md
DELETED
|
@@ -1,658 +0,0 @@
|
|
|
1
|
-
# ElizaOS GitHub Plugin
|
|
2
|
-
|
|
3
|
-
A comprehensive GitHub integration plugin for ElizaOS that provides repository
|
|
4
|
-
management, issue tracking, pull request workflows, and activity monitoring
|
|
5
|
-
capabilities.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
### 🏗️ Repository Management
|
|
10
|
-
|
|
11
|
-
- **Get Repository Info**: Retrieve detailed information about any GitHub
|
|
12
|
-
repository
|
|
13
|
-
- **List Repositories**: View your repositories with filtering and sorting
|
|
14
|
-
options
|
|
15
|
-
- **Create Repositories**: Create new repositories with customizable settings
|
|
16
|
-
- **Search Repositories**: Find repositories across GitHub using advanced
|
|
17
|
-
queries
|
|
18
|
-
|
|
19
|
-
### 🐛 Issue Management
|
|
20
|
-
|
|
21
|
-
- **Get Issue Details**: Fetch comprehensive information about specific issues
|
|
22
|
-
- **List Issues**: View issues with state, label, and milestone filtering
|
|
23
|
-
- **Create Issues**: Submit new issues with labels, assignees, and milestones
|
|
24
|
-
- **Search Issues**: Find issues across repositories using powerful search
|
|
25
|
-
queries
|
|
26
|
-
|
|
27
|
-
### 🔄 Pull Request Workflows
|
|
28
|
-
|
|
29
|
-
- **Get PR Details**: Retrieve detailed pull request information
|
|
30
|
-
- **List Pull Requests**: View PRs with state and branch filtering
|
|
31
|
-
- **Create Pull Requests**: Open new PRs from feature branches
|
|
32
|
-
- **Merge Pull Requests**: Merge approved PRs with different merge strategies
|
|
33
|
-
|
|
34
|
-
### 📊 Activity Tracking & Monitoring
|
|
35
|
-
|
|
36
|
-
- **Activity Dashboard**: Real-time tracking of all GitHub operations performed
|
|
37
|
-
by the agent
|
|
38
|
-
- **Rate Limit Monitoring**: Track GitHub API usage and remaining quota
|
|
39
|
-
- **Error Handling**: Comprehensive error tracking and reporting
|
|
40
|
-
- **Success Metrics**: Monitor operation success rates and performance
|
|
41
|
-
|
|
42
|
-
### 🔄 State Management & Chaining
|
|
43
|
-
|
|
44
|
-
- **Contextual State**: Actions automatically update and chain state between
|
|
45
|
-
operations
|
|
46
|
-
- **Smart Defaults**: Use previous operation results to inform subsequent
|
|
47
|
-
actions
|
|
48
|
-
- **Provider Integration**: Rich context providers for repositories, issues, and
|
|
49
|
-
PRs
|
|
50
|
-
|
|
51
|
-
### 🔔 Webhook Integration & Real-Time Events
|
|
52
|
-
|
|
53
|
-
- **Ngrok Integration**: Automatic tunnel creation for local development
|
|
54
|
-
- **Webhook Management**: Create, list, delete, and test repository webhooks
|
|
55
|
-
- **Event Processing**: Real-time handling of GitHub events (issues, PRs,
|
|
56
|
-
comments)
|
|
57
|
-
- **Signature Verification**: Secure webhook payload validation
|
|
58
|
-
|
|
59
|
-
### 🤖 Auto-Coding Capabilities
|
|
60
|
-
|
|
61
|
-
- **Issue Analysis**: AI-powered analysis of GitHub issues for automation
|
|
62
|
-
potential
|
|
63
|
-
- **Automated PRs**: Create pull requests to fix simple issues automatically
|
|
64
|
-
- **Smart Mentions**: Respond when @mentioned in issues or comments
|
|
65
|
-
- **Complexity Detection**: Identifies when human intervention is needed
|
|
66
|
-
|
|
67
|
-
## Installation
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
# Add to your ElizaOS project
|
|
71
|
-
elizaos install @elizaos/plugin-github
|
|
72
|
-
|
|
73
|
-
# Or manually add to package.json
|
|
74
|
-
npm install @elizaos/plugin-github
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Configuration
|
|
78
|
-
|
|
79
|
-
The plugin uses `runtime.getSetting` to retrieve configuration values, with
|
|
80
|
-
fallback to environment variables.
|
|
81
|
-
|
|
82
|
-
### Runtime Configuration (Recommended)
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
// Configure via agent settings
|
|
86
|
-
const agent = new Agent({
|
|
87
|
-
settings: {
|
|
88
|
-
GITHUB_TOKEN: 'ghp_your_personal_access_token_here',
|
|
89
|
-
GITHUB_TOKEN: 'github_pat_your_fine_grained_token', // Alternative
|
|
90
|
-
GITHUB_OWNER: 'your-username-or-org', // Optional default
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Environment Variables (Fallback)
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
# GitHub Personal Access Token (required)
|
|
99
|
-
GITHUB_TOKEN=ghp_your_personal_access_token_here
|
|
100
|
-
|
|
101
|
-
# Alternative: GitHub PAT (legacy support)
|
|
102
|
-
GITHUB_TOKEN=ghp_your_personal_access_token_here
|
|
103
|
-
|
|
104
|
-
# Optional: Default GitHub username/organization
|
|
105
|
-
GITHUB_OWNER=your-username-or-org
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
The plugin will check for tokens in this order:
|
|
109
|
-
|
|
110
|
-
1. `runtime.getSetting('GITHUB_TOKEN')`
|
|
111
|
-
2. `runtime.getSetting('GITHUB_TOKEN')`
|
|
112
|
-
3. Global configuration object
|
|
113
|
-
4. Environment variables (`process.env.GITHUB_TOKEN` or
|
|
114
|
-
`process.env.GITHUB_TOKEN`)
|
|
115
|
-
|
|
116
|
-
### Token Types Supported
|
|
117
|
-
|
|
118
|
-
1. **Personal Access Tokens (PAT)**: `ghp_...`
|
|
119
|
-
2. **Fine-grained Personal Access Tokens**: `github_pat_...`
|
|
120
|
-
3. **GitHub App tokens**: `ghs_...`
|
|
121
|
-
4. **OAuth App tokens**: `gho_...`
|
|
122
|
-
5. **User-to-server tokens**: `ghu_...`
|
|
123
|
-
6. **Server-to-server tokens**: `ghr_...`
|
|
124
|
-
|
|
125
|
-
### Token Permissions Required
|
|
126
|
-
|
|
127
|
-
For full functionality, your token needs these permissions:
|
|
128
|
-
|
|
129
|
-
- `repo` - Full repository access
|
|
130
|
-
- `read:user` - Read user profile information
|
|
131
|
-
- `read:org` - Read organization membership (if using organization repos)
|
|
132
|
-
|
|
133
|
-
## Usage Examples
|
|
134
|
-
|
|
135
|
-
### Repository Operations
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
// Get repository information
|
|
139
|
-
await runtime.executeAction('GET_GITHUB_REPOSITORY', {
|
|
140
|
-
owner: 'elizaOS',
|
|
141
|
-
repo: 'eliza',
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// List your repositories
|
|
145
|
-
await runtime.executeAction('LIST_GITHUB_REPOSITORIES', {
|
|
146
|
-
type: 'owner',
|
|
147
|
-
sort: 'updated',
|
|
148
|
-
limit: 10,
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// Create a new repository
|
|
152
|
-
await runtime.executeAction('CREATE_GITHUB_REPOSITORY', {
|
|
153
|
-
name: 'my-new-project',
|
|
154
|
-
description: 'A new project created by ElizaOS',
|
|
155
|
-
private: false,
|
|
156
|
-
auto_init: true,
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// Search for repositories
|
|
160
|
-
await runtime.executeAction('SEARCH_GITHUB_REPOSITORIES', {
|
|
161
|
-
query: 'language:typescript elizaos',
|
|
162
|
-
sort: 'stars',
|
|
163
|
-
limit: 5,
|
|
164
|
-
});
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### Issue Management
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
// Get issue details
|
|
171
|
-
await runtime.executeAction('GET_GITHUB_ISSUE', {
|
|
172
|
-
owner: 'elizaOS',
|
|
173
|
-
repo: 'eliza',
|
|
174
|
-
issue_number: 42,
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
// Create a new issue
|
|
178
|
-
await runtime.executeAction('CREATE_GITHUB_ISSUE', {
|
|
179
|
-
owner: 'elizaOS',
|
|
180
|
-
repo: 'eliza',
|
|
181
|
-
title: 'Bug: Authentication not working',
|
|
182
|
-
body: 'Detailed description of the issue...',
|
|
183
|
-
labels: ['bug', 'authentication'],
|
|
184
|
-
assignees: ['maintainer'],
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// List open issues
|
|
188
|
-
await runtime.executeAction('LIST_GITHUB_ISSUES', {
|
|
189
|
-
owner: 'elizaOS',
|
|
190
|
-
repo: 'eliza',
|
|
191
|
-
state: 'open',
|
|
192
|
-
labels: 'bug',
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
// Search issues globally
|
|
196
|
-
await runtime.executeAction('SEARCH_GITHUB_ISSUES', {
|
|
197
|
-
query: 'is:issue is:open label:bug repo:elizaOS/eliza',
|
|
198
|
-
sort: 'updated',
|
|
199
|
-
});
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Pull Request Workflows
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
// Create a pull request
|
|
206
|
-
await runtime.executeAction('CREATE_GITHUB_PULL_REQUEST', {
|
|
207
|
-
owner: 'elizaOS',
|
|
208
|
-
repo: 'eliza',
|
|
209
|
-
title: 'Add new GitHub integration',
|
|
210
|
-
head: 'feature/github-integration',
|
|
211
|
-
base: 'main',
|
|
212
|
-
body: 'This PR adds comprehensive GitHub integration...',
|
|
213
|
-
draft: false,
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// Get PR details
|
|
217
|
-
await runtime.executeAction('GET_GITHUB_PULL_REQUEST', {
|
|
218
|
-
owner: 'elizaOS',
|
|
219
|
-
repo: 'eliza',
|
|
220
|
-
pull_number: 25,
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
// Merge a pull request
|
|
224
|
-
await runtime.executeAction('MERGE_GITHUB_PULL_REQUEST', {
|
|
225
|
-
owner: 'elizaOS',
|
|
226
|
-
repo: 'eliza',
|
|
227
|
-
pull_number: 25,
|
|
228
|
-
merge_method: 'squash',
|
|
229
|
-
});
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### Activity Monitoring
|
|
233
|
-
|
|
234
|
-
```typescript
|
|
235
|
-
// View recent activity
|
|
236
|
-
await runtime.executeAction('GET_GITHUB_ACTIVITY', {
|
|
237
|
-
limit: 20,
|
|
238
|
-
filter: 'all',
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
// Check rate limit status
|
|
242
|
-
await runtime.executeAction('GET_GITHUB_RATE_LIMIT');
|
|
243
|
-
|
|
244
|
-
// Clear activity log
|
|
245
|
-
await runtime.executeAction('CLEAR_GITHUB_ACTIVITY');
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
## Natural Language Interface
|
|
249
|
-
|
|
250
|
-
The plugin supports natural language commands:
|
|
251
|
-
|
|
252
|
-
```
|
|
253
|
-
"Get information about the elizaOS/eliza repository"
|
|
254
|
-
"Create a new repository called my-awesome-project"
|
|
255
|
-
"List my open issues"
|
|
256
|
-
"Create an issue in elizaOS/eliza about authentication bugs"
|
|
257
|
-
"Show me recent GitHub activity"
|
|
258
|
-
"What's my current GitHub rate limit?"
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
## State Management & Action Chaining
|
|
262
|
-
|
|
263
|
-
The plugin automatically manages state between operations, enabling powerful
|
|
264
|
-
action chaining:
|
|
265
|
-
|
|
266
|
-
### Basic State Management
|
|
267
|
-
|
|
268
|
-
```typescript
|
|
269
|
-
// First, get a repository (stores in state)
|
|
270
|
-
await getRepositoryAction.handler(runtime, message, state, {
|
|
271
|
-
owner: 'elizaOS',
|
|
272
|
-
repo: 'eliza',
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
// Then, create an issue (automatically uses the repository from state)
|
|
276
|
-
await createIssueAction.handler(runtime, message, updatedState, {
|
|
277
|
-
title: 'New issue',
|
|
278
|
-
body: 'Issue description',
|
|
279
|
-
// owner and repo automatically filled from state
|
|
280
|
-
});
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
### Advanced Action Chaining
|
|
284
|
-
|
|
285
|
-
Actions can be chained together for complex workflows:
|
|
286
|
-
|
|
287
|
-
```typescript
|
|
288
|
-
// Example: Search → Analyze → Create Issue workflow
|
|
289
|
-
const workflow = async () => {
|
|
290
|
-
// Step 1: Search for repositories
|
|
291
|
-
const searchResult = await runtime.executeAction(
|
|
292
|
-
'SEARCH_GITHUB_REPOSITORIES',
|
|
293
|
-
{
|
|
294
|
-
query: 'language:typescript stars:>1000',
|
|
295
|
-
sort: 'stars',
|
|
296
|
-
}
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
// Step 2: Get details of the top repository
|
|
300
|
-
const topRepo = searchResult.repositories[0];
|
|
301
|
-
const repoDetails = await runtime.executeAction('GET_GITHUB_REPOSITORY', {
|
|
302
|
-
owner: topRepo.owner.login,
|
|
303
|
-
repo: topRepo.name,
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
// Step 3: Check existing issues
|
|
307
|
-
const issues = await runtime.executeAction('LIST_GITHUB_ISSUES', {
|
|
308
|
-
owner: topRepo.owner.login,
|
|
309
|
-
repo: topRepo.name,
|
|
310
|
-
state: 'open',
|
|
311
|
-
labels: 'enhancement',
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
// Step 4: Create a new issue based on analysis
|
|
315
|
-
if (issues.issues.length < 5) {
|
|
316
|
-
await runtime.executeAction('CREATE_GITHUB_ISSUE', {
|
|
317
|
-
owner: topRepo.owner.login,
|
|
318
|
-
repo: topRepo.name,
|
|
319
|
-
title: 'Consider adding TypeScript strict mode',
|
|
320
|
-
body: `Based on analysis, this repository could benefit from TypeScript strict mode.
|
|
321
|
-
Current stars: ${repoDetails.repository.stargazers_count}
|
|
322
|
-
Open enhancement issues: ${issues.issues.length}`,
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
### Complex Multi-Step Workflows
|
|
329
|
-
|
|
330
|
-
```typescript
|
|
331
|
-
// Repository Health Check Workflow
|
|
332
|
-
const checkRepositoryHealth = async (owner: string, repo: string) => {
|
|
333
|
-
// Check rate limit first
|
|
334
|
-
const rateLimit = await runtime.executeAction('GET_GITHUB_RATE_LIMIT');
|
|
335
|
-
|
|
336
|
-
if (rateLimit.rateLimit.remaining < 10) {
|
|
337
|
-
throw new Error('Rate limit too low for health check');
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Get repository info
|
|
341
|
-
const repository = await runtime.executeAction('GET_GITHUB_REPOSITORY', {
|
|
342
|
-
owner,
|
|
343
|
-
repo,
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
// Check open issues
|
|
347
|
-
const openIssues = await runtime.executeAction('LIST_GITHUB_ISSUES', {
|
|
348
|
-
owner,
|
|
349
|
-
repo,
|
|
350
|
-
state: 'open',
|
|
351
|
-
per_page: 100,
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
// Check open PRs
|
|
355
|
-
const openPRs = await runtime.executeAction('LIST_GITHUB_PULL_REQUESTS', {
|
|
356
|
-
owner,
|
|
357
|
-
repo,
|
|
358
|
-
state: 'open',
|
|
359
|
-
per_page: 100,
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
// Search for stale issues
|
|
363
|
-
const staleIssues = await runtime.executeAction('SEARCH_GITHUB_ISSUES', {
|
|
364
|
-
query: `repo:${owner}/${repo} is:open updated:<${new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString().split('T')[0]}`,
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
return {
|
|
368
|
-
repository: repository.repository,
|
|
369
|
-
health: {
|
|
370
|
-
stars: repository.repository.stargazers_count,
|
|
371
|
-
openIssues: openIssues.issues.length,
|
|
372
|
-
openPRs: openPRs.pullRequests.length,
|
|
373
|
-
staleIssues: staleIssues.total_count,
|
|
374
|
-
lastUpdate: repository.repository.updated_at,
|
|
375
|
-
},
|
|
376
|
-
recommendations: generateRecommendations(
|
|
377
|
-
repository,
|
|
378
|
-
openIssues,
|
|
379
|
-
openPRs,
|
|
380
|
-
staleIssues
|
|
381
|
-
),
|
|
382
|
-
};
|
|
383
|
-
};
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
## HTTP API Endpoints
|
|
387
|
-
|
|
388
|
-
When the plugin is loaded, it exposes these HTTP endpoints:
|
|
389
|
-
|
|
390
|
-
- `GET /api/github/status` - Plugin status and authentication info
|
|
391
|
-
- `GET /api/github/activity` - Recent GitHub activity with statistics
|
|
392
|
-
- `GET /api/github/rate-limit` - Current GitHub API rate limit status
|
|
393
|
-
|
|
394
|
-
## Provider Context
|
|
395
|
-
|
|
396
|
-
The plugin provides rich context through these providers:
|
|
397
|
-
|
|
398
|
-
- **GITHUB_REPOSITORY_CONTEXT** - Current repository information
|
|
399
|
-
- **GITHUB_ISSUES_CONTEXT** - Recent issues and current issue details
|
|
400
|
-
- **GITHUB_PULL_REQUESTS_CONTEXT** - PR information and merge status
|
|
401
|
-
- **GITHUB_ACTIVITY_CONTEXT** - Activity statistics and recent operations
|
|
402
|
-
- **GITHUB_USER_CONTEXT** - Authenticated user information
|
|
403
|
-
|
|
404
|
-
## Actions Reference
|
|
405
|
-
|
|
406
|
-
### Repository Actions
|
|
407
|
-
|
|
408
|
-
| Action | Description | Parameters |
|
|
409
|
-
| ---------------------------- | -------------------------- | -------------------------------------- |
|
|
410
|
-
| `GET_GITHUB_REPOSITORY` | Get repository information | `owner`, `repo` |
|
|
411
|
-
| `LIST_GITHUB_REPOSITORIES` | List user repositories | `type`, `sort`, `limit` |
|
|
412
|
-
| `CREATE_GITHUB_REPOSITORY` | Create new repository | `name`, `description`, `private`, etc. |
|
|
413
|
-
| `SEARCH_GITHUB_REPOSITORIES` | Search repositories | `query`, `sort`, `limit` |
|
|
414
|
-
|
|
415
|
-
### Issue Actions
|
|
416
|
-
|
|
417
|
-
| Action | Description | Parameters |
|
|
418
|
-
| ---------------------- | ---------------------- | ------------------------------------------ |
|
|
419
|
-
| `GET_GITHUB_ISSUE` | Get issue details | `owner`, `repo`, `issue_number` |
|
|
420
|
-
| `LIST_GITHUB_ISSUES` | List repository issues | `owner`, `repo`, `state`, `labels` |
|
|
421
|
-
| `CREATE_GITHUB_ISSUE` | Create new issue | `owner`, `repo`, `title`, `body`, `labels` |
|
|
422
|
-
| `SEARCH_GITHUB_ISSUES` | Search issues | `query`, `sort`, `limit` |
|
|
423
|
-
|
|
424
|
-
### Pull Request Actions
|
|
425
|
-
|
|
426
|
-
| Action | Description | Parameters |
|
|
427
|
-
| ---------------------------- | ------------------- | ------------------------------------------------ |
|
|
428
|
-
| `GET_GITHUB_PULL_REQUEST` | Get PR details | `owner`, `repo`, `pull_number` |
|
|
429
|
-
| `LIST_GITHUB_PULL_REQUESTS` | List repository PRs | `owner`, `repo`, `state`, `head`, `base` |
|
|
430
|
-
| `CREATE_GITHUB_PULL_REQUEST` | Create new PR | `owner`, `repo`, `title`, `head`, `base`, `body` |
|
|
431
|
-
| `MERGE_GITHUB_PULL_REQUEST` | Merge PR | `owner`, `repo`, `pull_number`, `merge_method` |
|
|
432
|
-
|
|
433
|
-
### Activity Actions
|
|
434
|
-
|
|
435
|
-
| Action | Description | Parameters |
|
|
436
|
-
| ----------------------- | --------------------- | ---------------------------------- |
|
|
437
|
-
| `GET_GITHUB_ACTIVITY` | Get activity log | `limit`, `filter`, `resource_type` |
|
|
438
|
-
| `CLEAR_GITHUB_ACTIVITY` | Clear activity log | None |
|
|
439
|
-
| `GET_GITHUB_RATE_LIMIT` | Get rate limit status | None |
|
|
440
|
-
|
|
441
|
-
## Integration with Other Plugins
|
|
442
|
-
|
|
443
|
-
This plugin is designed to work seamlessly with other ElizaOS plugins:
|
|
444
|
-
|
|
445
|
-
### Plugin Manager Integration
|
|
446
|
-
|
|
447
|
-
The GitHub plugin provides all the functionality needed by
|
|
448
|
-
`plugin-plugin-manager`:
|
|
449
|
-
|
|
450
|
-
```typescript
|
|
451
|
-
// The plugin-plugin-manager can use GitHub service directly
|
|
452
|
-
const githubService = runtime.getService<GitHubService>('github');
|
|
453
|
-
|
|
454
|
-
// All GitHub operations are available
|
|
455
|
-
await githubService.createRepository(options);
|
|
456
|
-
await githubService.getRepository(owner, repo);
|
|
457
|
-
await githubService.createPullRequest(owner, repo, prOptions);
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
### Security Features
|
|
461
|
-
|
|
462
|
-
- **Token Validation**: Automatic validation of GitHub token formats
|
|
463
|
-
- **Rate Limiting**: Built-in rate limit monitoring and handling
|
|
464
|
-
- **Error Handling**: Comprehensive error handling with user-friendly messages
|
|
465
|
-
- **Input Sanitization**: All inputs are validated and sanitized
|
|
466
|
-
- **Activity Logging**: All operations are logged for audit purposes
|
|
467
|
-
|
|
468
|
-
## Testing
|
|
469
|
-
|
|
470
|
-
The plugin includes comprehensive test coverage with multiple test suites:
|
|
471
|
-
|
|
472
|
-
### Unit Tests
|
|
473
|
-
|
|
474
|
-
```bash
|
|
475
|
-
# Run unit tests
|
|
476
|
-
npm test
|
|
477
|
-
|
|
478
|
-
# Or with elizaos
|
|
479
|
-
elizaos test component
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
### Integration Tests
|
|
483
|
-
|
|
484
|
-
Test how components work together:
|
|
485
|
-
|
|
486
|
-
```bash
|
|
487
|
-
npm test integration.test.ts
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
### Action Chaining Tests
|
|
491
|
-
|
|
492
|
-
Test complex workflows and state management:
|
|
493
|
-
|
|
494
|
-
```bash
|
|
495
|
-
npm test action-chaining.test.ts
|
|
496
|
-
```
|
|
497
|
-
|
|
498
|
-
### Runtime Scenario Tests
|
|
499
|
-
|
|
500
|
-
Test various runtime configurations:
|
|
501
|
-
|
|
502
|
-
```bash
|
|
503
|
-
npm test runtime-scenarios.test.ts
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
### End-to-End Tests (Requires GitHub Token)
|
|
507
|
-
|
|
508
|
-
Test with real GitHub API:
|
|
509
|
-
|
|
510
|
-
```bash
|
|
511
|
-
# Set your GitHub token first
|
|
512
|
-
export GITHUB_TOKEN=ghp_your_token_here
|
|
513
|
-
|
|
514
|
-
# Run E2E tests
|
|
515
|
-
npm test e2e.test.ts
|
|
516
|
-
|
|
517
|
-
# Or with elizaos
|
|
518
|
-
elizaos test e2e
|
|
519
|
-
```
|
|
520
|
-
|
|
521
|
-
**Note**: E2E tests will interact with real GitHub repositories. Use a test
|
|
522
|
-
account or be prepared for actual API calls.
|
|
523
|
-
|
|
524
|
-
### Webhook E2E Tests (Real GitHub Events)
|
|
525
|
-
|
|
526
|
-
Test complete webhook functionality with live events:
|
|
527
|
-
|
|
528
|
-
```bash
|
|
529
|
-
# Set up environment
|
|
530
|
-
export GITHUB_TOKEN=ghp_your_token_here
|
|
531
|
-
export GITHUB_OWNER=your-username
|
|
532
|
-
export TEST_REPO=test-webhook-repo
|
|
533
|
-
|
|
534
|
-
# Start your ElizaOS agent first
|
|
535
|
-
elizaos start --character github-agent.json
|
|
536
|
-
|
|
537
|
-
# Run automated E2E webhook tests
|
|
538
|
-
npm run test:e2e
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
This will:
|
|
542
|
-
|
|
543
|
-
- ✅ Create webhooks via Ngrok tunnel
|
|
544
|
-
- ✅ Test real GitHub issue mentions
|
|
545
|
-
- ✅ Verify auto-coding PR creation
|
|
546
|
-
- ✅ Test complex issue handling
|
|
547
|
-
- ✅ Validate webhook signature verification
|
|
548
|
-
- ✅ Clean up test artifacts
|
|
549
|
-
|
|
550
|
-
See [E2E_TESTING.md](./E2E_TESTING.md) for detailed testing instructions.
|
|
551
|
-
|
|
552
|
-
### Test Coverage
|
|
553
|
-
|
|
554
|
-
- **Unit Tests**: Individual component functionality
|
|
555
|
-
- **Integration Tests**: Component interactions
|
|
556
|
-
- **E2E Tests**: Real GitHub API operations
|
|
557
|
-
- **Action Chaining**: Complex workflow validation
|
|
558
|
-
- **Runtime Scenarios**: Various configuration tests
|
|
559
|
-
|
|
560
|
-
### Writing Custom Tests
|
|
561
|
-
|
|
562
|
-
```typescript
|
|
563
|
-
// Example test for your own workflows
|
|
564
|
-
describe('Custom GitHub Workflow', () => {
|
|
565
|
-
it('should perform repository analysis', async () => {
|
|
566
|
-
const runtime = createTestRuntime({
|
|
567
|
-
settings: {
|
|
568
|
-
GITHUB_TOKEN: process.env.GITHUB_TOKEN,
|
|
569
|
-
},
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
// Your test logic here
|
|
573
|
-
const result = await runtime.executeAction('SEARCH_GITHUB_REPOSITORIES', {
|
|
574
|
-
query: 'your-search-query',
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
expect(result.repositories).toBeDefined();
|
|
578
|
-
});
|
|
579
|
-
});
|
|
580
|
-
```
|
|
581
|
-
|
|
582
|
-
## Development
|
|
583
|
-
|
|
584
|
-
### Local Development
|
|
585
|
-
|
|
586
|
-
```bash
|
|
587
|
-
# Start development mode with hot reload
|
|
588
|
-
elizaos dev
|
|
589
|
-
|
|
590
|
-
# Build the plugin
|
|
591
|
-
elizaos build
|
|
592
|
-
|
|
593
|
-
# Run linting
|
|
594
|
-
elizaos lint
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
### Environment Setup
|
|
598
|
-
|
|
599
|
-
1. Create a `.env` file with your GitHub token:
|
|
600
|
-
|
|
601
|
-
```bash
|
|
602
|
-
GITHUB_TOKEN=your_github_token_here
|
|
603
|
-
GITHUB_OWNER=your_username
|
|
604
|
-
```
|
|
605
|
-
|
|
606
|
-
2. Ensure your token has the required permissions for testing
|
|
607
|
-
|
|
608
|
-
## Troubleshooting
|
|
609
|
-
|
|
610
|
-
### Common Issues
|
|
611
|
-
|
|
612
|
-
**Authentication Failed**
|
|
613
|
-
|
|
614
|
-
- Verify your GitHub token is valid and not expired
|
|
615
|
-
- Check that your token has the required permissions
|
|
616
|
-
- Ensure the token format is correct (`ghp_...` or `github_pat_...`)
|
|
617
|
-
|
|
618
|
-
**Rate Limit Exceeded**
|
|
619
|
-
|
|
620
|
-
- Check your rate limit status: `GET_GITHUB_RATE_LIMIT`
|
|
621
|
-
- Wait for the rate limit to reset
|
|
622
|
-
- Consider using a GitHub App token for higher limits
|
|
623
|
-
|
|
624
|
-
**Permission Denied**
|
|
625
|
-
|
|
626
|
-
- Verify your token has access to the repository
|
|
627
|
-
- Check if the repository is private and your token has `repo` scope
|
|
628
|
-
- Ensure organization permissions if working with org repositories
|
|
629
|
-
|
|
630
|
-
**Network Issues**
|
|
631
|
-
|
|
632
|
-
- Check your internet connection
|
|
633
|
-
- Verify GitHub's status at [status.github.com](https://status.github.com)
|
|
634
|
-
- Try again with exponential backoff
|
|
635
|
-
|
|
636
|
-
## Contributing
|
|
637
|
-
|
|
638
|
-
1. Fork the repository
|
|
639
|
-
2. Create a feature branch
|
|
640
|
-
3. Add tests for your changes
|
|
641
|
-
4. Ensure all tests pass
|
|
642
|
-
5. Submit a pull request
|
|
643
|
-
|
|
644
|
-
## License
|
|
645
|
-
|
|
646
|
-
This project is licensed under the same license as ElizaOS.
|
|
647
|
-
|
|
648
|
-
## Support
|
|
649
|
-
|
|
650
|
-
For support and questions:
|
|
651
|
-
|
|
652
|
-
- Create an issue in the ElizaOS repository
|
|
653
|
-
- Join the ElizaOS Discord community
|
|
654
|
-
- Check the ElizaOS documentation
|
|
655
|
-
|
|
656
|
-
---
|
|
657
|
-
|
|
658
|
-
**Built with ❤️ for the ElizaOS ecosystem**
|