@matimo/github 0.1.0-alpha.10
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/README.md +392 -0
- package/definition.yaml +71 -0
- package/package.json +17 -0
- package/tools/add-collaborator/definition.yaml +73 -0
- package/tools/create-issue/definition.yaml +96 -0
- package/tools/create-pull-request/definition.yaml +103 -0
- package/tools/create-release/definition.yaml +103 -0
- package/tools/create-repository/definition.yaml +112 -0
- package/tools/delete-repository/definition.yaml +51 -0
- package/tools/get-issue/definition.yaml +70 -0
- package/tools/get-repository/definition.yaml +83 -0
- package/tools/list-code-alerts/definition.yaml +85 -0
- package/tools/list-collaborators/definition.yaml +77 -0
- package/tools/list-commits/definition.yaml +81 -0
- package/tools/list-issues/definition.yaml +96 -0
- package/tools/list-pull-requests/definition.yaml +93 -0
- package/tools/list-releases/definition.yaml +66 -0
- package/tools/list-repositories/definition.yaml +79 -0
- package/tools/merge-pull-request/definition.yaml +88 -0
- package/tools/search-code/definition.yaml +75 -0
- package/tools/search-issues/definition.yaml +75 -0
- package/tools/search-repositories/definition.yaml +83 -0
- package/tools/search-users/definition.yaml +75 -0
- package/tools/update-code-alert/definition.yaml +86 -0
- package/tools/update-issue/definition.yaml +98 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 tallclub
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# @matimo/github — GitHub Tools for Matimo
|
|
2
|
+
|
|
3
|
+
Comprehensive GitHub REST API integration for Matimo. Execute 22 focused tools across search, issues, repositories, pull requests, commits, collaborators, releases, and code scanning.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @matimo/github
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @matimo/github
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### Factory Pattern
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { MatimoInstance } from '@matimo/core';
|
|
19
|
+
|
|
20
|
+
const matimo = await MatimoInstance.init({
|
|
21
|
+
autoDiscover: true // Auto-loads @matimo/github from node_modules
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Search repositories
|
|
25
|
+
const repos = await matimo.execute('github-search-repositories', {
|
|
26
|
+
query: 'language:typescript stars:>1000'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Create issue
|
|
30
|
+
const issue = await matimo.execute('github-create-issue', {
|
|
31
|
+
owner: 'nodejs',
|
|
32
|
+
repo: 'node',
|
|
33
|
+
title: 'Bug: Memory leak in event loop',
|
|
34
|
+
body: 'Description of the issue...'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Merge pull request
|
|
38
|
+
const merged = await matimo.execute('github-merge-pull-request', {
|
|
39
|
+
owner: 'nodejs',
|
|
40
|
+
repo: 'node',
|
|
41
|
+
pull_number: 42,
|
|
42
|
+
merge_method: 'squash'
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Decorator Pattern
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { MatimoInstance, setGlobalMatimoInstance, tool } from '@matimo/core';
|
|
50
|
+
|
|
51
|
+
const matimo = await MatimoInstance.init({ autoDiscover: true });
|
|
52
|
+
setGlobalMatimoInstance(matimo);
|
|
53
|
+
|
|
54
|
+
class GitHubAgent {
|
|
55
|
+
@tool('github-search-repositories')
|
|
56
|
+
async searchRepos(query: string) { /* auto-executed */ }
|
|
57
|
+
|
|
58
|
+
@tool('github-create-issue')
|
|
59
|
+
async createIssue(owner: string, repo: string, title: string, body: string) {
|
|
60
|
+
/* auto-executed */
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const agent = new GitHubAgent();
|
|
65
|
+
await agent.searchRepos('language:typescript');
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### LangChain Integration
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { MatimoInstance } from '@matimo/core';
|
|
72
|
+
|
|
73
|
+
const matimo = await MatimoInstance.init({ autoDiscover: true });
|
|
74
|
+
|
|
75
|
+
// Get all GitHub tools as LangChain function schemas
|
|
76
|
+
const ghTools = matimo.listTools()
|
|
77
|
+
.filter(t => t.name.startsWith('github-'))
|
|
78
|
+
.map(tool => ({
|
|
79
|
+
type: 'function',
|
|
80
|
+
function: {
|
|
81
|
+
name: tool.name,
|
|
82
|
+
description: tool.description,
|
|
83
|
+
parameters: {
|
|
84
|
+
type: 'object',
|
|
85
|
+
properties: tool.parameters || {},
|
|
86
|
+
required: Object.entries(tool.parameters || {})
|
|
87
|
+
.filter(([_, p]) => p.required)
|
|
88
|
+
.map(([name]) => name)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
|
|
93
|
+
// Use with your LLM + function calling
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Available Tools
|
|
97
|
+
|
|
98
|
+
| Tool | Description | HTTP Method |
|
|
99
|
+
|------|-------------|------------|
|
|
100
|
+
| **Search** | | |
|
|
101
|
+
| `github-search-repositories` | Search repositories by name, stars, topics | GET |
|
|
102
|
+
| `github-search-code` | Search code across repositories | GET |
|
|
103
|
+
| `github-search-issues` | Search issues and pull requests | GET |
|
|
104
|
+
| `github-search-users` | Search users by location, followers | GET |
|
|
105
|
+
| **Issues** | | |
|
|
106
|
+
| `github-list-issues` | List repository issues with filtering | GET |
|
|
107
|
+
| `github-create-issue` | Create a new issue | POST |
|
|
108
|
+
| `github-get-issue` | Get specific issue details | GET |
|
|
109
|
+
| `github-update-issue` | Update issue title, body, state | PATCH |
|
|
110
|
+
| **Repositories** | | |
|
|
111
|
+
| `github-list-repositories` | List organization/user repositories | GET |
|
|
112
|
+
| `github-create-repository` | Create new repository | POST |
|
|
113
|
+
| `github-get-repository` | Get repository details (120+ fields) | GET |
|
|
114
|
+
| `github-delete-repository` | Delete repository (admin only) | DELETE |
|
|
115
|
+
| **Pull Requests** | | |
|
|
116
|
+
| `github-list-pull-requests` | List pull requests with filtering | GET |
|
|
117
|
+
| `github-create-pull-request` | Create new pull request | POST |
|
|
118
|
+
| `github-merge-pull-request` | Merge pull request | PUT |
|
|
119
|
+
| **Commits** | | |
|
|
120
|
+
| `github-list-commits` | List repository commits | GET |
|
|
121
|
+
| **Collaborators** | | |
|
|
122
|
+
| `github-list-collaborators` | List repository collaborators | GET |
|
|
123
|
+
| `github-add-collaborator` | Add user as collaborator | PUT |
|
|
124
|
+
| **Releases** | | |
|
|
125
|
+
| `github-list-releases` | List repository releases | GET |
|
|
126
|
+
| `github-create-release` | Create new release | POST |
|
|
127
|
+
| **Code Scanning** | | |
|
|
128
|
+
| `github-list-code-alerts` | List security scanning alerts | GET |
|
|
129
|
+
| `github-update-code-alert` | Update alert status (dismiss/reopen) | PATCH |
|
|
130
|
+
|
|
131
|
+
## Authentication
|
|
132
|
+
|
|
133
|
+
### Personal Access Token (PAT)
|
|
134
|
+
|
|
135
|
+
1. Create token at https://github.com/settings/tokens
|
|
136
|
+
2. Choose scopes:
|
|
137
|
+
- **repo** — Full access to repositories
|
|
138
|
+
- **gist** — Full access to gists
|
|
139
|
+
- **user** — Read user profile
|
|
140
|
+
- **admin:org_hook** — Write organization webhooks (optional)
|
|
141
|
+
- **security_events** — Read code scanning alerts
|
|
142
|
+
|
|
143
|
+
3. Set environment variable:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
export GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Fine-grained Personal Access Token
|
|
150
|
+
|
|
151
|
+
1. Create at https://github.com/settings/personal-access-tokens/new
|
|
152
|
+
2. Minimum required permissions:
|
|
153
|
+
- Repository (selected): Code, Commit, Issues, Pull Requests, Releases, Security events
|
|
154
|
+
3. Set environment variable:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
export GITHUB_TOKEN=github_pat_xxxxxxxxxxxxxxxx
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### OAuth2 (GitHub App)
|
|
161
|
+
|
|
162
|
+
1. Create GitHub App at https://github.com/settings/apps
|
|
163
|
+
2. Get Client ID from app settings
|
|
164
|
+
3. Use OAuth2Handler for authorization:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { OAuth2Handler } from '@matimo/core';
|
|
168
|
+
|
|
169
|
+
const handler = new OAuth2Handler('github');
|
|
170
|
+
const { authorize_url, state } = handler.getAuthorizationUrl();
|
|
171
|
+
|
|
172
|
+
// Redirect user to authorize_url
|
|
173
|
+
// Handle callback with authorization code
|
|
174
|
+
const tokens = await handler.exchangeAuthorizationCode(code, state);
|
|
175
|
+
|
|
176
|
+
// tokens.access_token ready for use
|
|
177
|
+
process.env.GITHUB_TOKEN = tokens.access_token;
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Rate Limiting
|
|
181
|
+
|
|
182
|
+
GitHub has multiple rate limits:
|
|
183
|
+
|
|
184
|
+
- **Primary**: 5,000 requests/hour (authenticated), 60/hour (unauthenticated)
|
|
185
|
+
- **Search**: 30 requests/minute (general), 10 requests/minute (code search)
|
|
186
|
+
- **Secondary**: 100 concurrent requests, 900 points/minute
|
|
187
|
+
|
|
188
|
+
### Handling Rate Limits
|
|
189
|
+
|
|
190
|
+
Tools include exponential backoff and retry logic. When you hit rate limits:
|
|
191
|
+
- Get reset time from response header: `x-ratelimit-reset` (Unix timestamp)
|
|
192
|
+
- Wait until reset time, then retry
|
|
193
|
+
- Check remaining quota with `x-ratelimit-remaining` header
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
// Automatic retry with exponential backoff
|
|
197
|
+
try {
|
|
198
|
+
const result = await matimo.execute('github-search-code', {
|
|
199
|
+
query: 'language:python'
|
|
200
|
+
});
|
|
201
|
+
} catch (error) {
|
|
202
|
+
// If 429 (rate limited), solution automatically retries with backoff
|
|
203
|
+
// If still fails after retries, throws MatimoError with details
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Error Handling
|
|
208
|
+
|
|
209
|
+
All tools throw `MatimoError` with structured error information:
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
import { MatimoError } from '@matimo/core';
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
await matimo.execute('github-create-issue', { /* ... */ });
|
|
216
|
+
} catch (error) {
|
|
217
|
+
if (error instanceof MatimoError) {
|
|
218
|
+
console.error('Code:', error.code); // EXECUTION_FAILED
|
|
219
|
+
console.error('Message:', error.message); // User-friendly message
|
|
220
|
+
console.error('Details:', error.details); // { statusCode: 404, toolName: '...' }
|
|
221
|
+
|
|
222
|
+
// Handle specific scenarios
|
|
223
|
+
if (error.code === 'EXECUTION_FAILED' && error.details?.statusCode === 404) {
|
|
224
|
+
console.error('Repository not found');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Common GitHub API errors:
|
|
231
|
+
- **401 Unauthorized** — Invalid or expired token
|
|
232
|
+
- **403 Forbidden** — Insufficient permissions, rate limited, or GHSA disabled
|
|
233
|
+
- **404 Not Found** — Repository, issue, or user doesn't exist
|
|
234
|
+
- **422 Unprocessable Entity** — Invalid parameters
|
|
235
|
+
- **429 Too Many Requests** — Rate limit exceeded
|
|
236
|
+
|
|
237
|
+
## Examples
|
|
238
|
+
|
|
239
|
+
### Search and Report
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
const matimo = await MatimoInstance.init({ autoDiscover: true });
|
|
243
|
+
|
|
244
|
+
// Find high-quality TypeScript projects
|
|
245
|
+
const results = await matimo.execute('github-search-repositories', {
|
|
246
|
+
query: 'language:typescript stars:>5000'
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
console.log(`Found ${results.total_count} matching repositories`);
|
|
250
|
+
results.items?.slice(0, 5).forEach(repo => {
|
|
251
|
+
console.log(`- ${repo.full_name}: ⭐ ${repo.stargazers_count}`);
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Create and Manage Issues
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
// Create an issue
|
|
259
|
+
const issue = await matimo.execute('github-create-issue', {
|
|
260
|
+
owner: 'myorg',
|
|
261
|
+
repo: 'myrepo',
|
|
262
|
+
title: 'Feature request: Add dark mode',
|
|
263
|
+
body: '# Description\nUsers want a dark mode theme\n\n# Solution\nImplement CSS dark mode support'
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
console.log(`Created issue #${issue.number}: ${issue.html_url}`);
|
|
267
|
+
|
|
268
|
+
// Update the issue
|
|
269
|
+
await matimo.execute('github-update-issue', {
|
|
270
|
+
owner: 'myorg',
|
|
271
|
+
repo: 'myrepo',
|
|
272
|
+
issue_number: issue.number,
|
|
273
|
+
state: 'closed'
|
|
274
|
+
});
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Pull Request Workflow
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
// List open PRs
|
|
281
|
+
const prs = await matimo.execute('github-list-pull-requests', {
|
|
282
|
+
owner: 'kubernetes',
|
|
283
|
+
repo: 'kubernetes',
|
|
284
|
+
state: 'open',
|
|
285
|
+
sort: 'updated'
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// Merge a PR
|
|
289
|
+
if (prs.length > 0) {
|
|
290
|
+
const merged = await matimo.execute('github-merge-pull-request', {
|
|
291
|
+
owner: 'kubernetes',
|
|
292
|
+
repo: 'kubernetes',
|
|
293
|
+
pull_number: prs[0].number,
|
|
294
|
+
merge_method: 'squash'
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
console.log(`Merged as commit ${merged.sha}`);
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Security Scanning
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
// List critical security alerts
|
|
305
|
+
const alerts = await matimo.execute('github-list-code-alerts', {
|
|
306
|
+
owner: 'myorg',
|
|
307
|
+
repo: 'myrepo',
|
|
308
|
+
state: 'open',
|
|
309
|
+
severity: 'critical'
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
// Dismiss false positives
|
|
313
|
+
for (const alert of alerts.filter(a => a.rule.id === 'false-positive')) {
|
|
314
|
+
await matimo.execute('github-update-code-alert', {
|
|
315
|
+
owner: 'myorg',
|
|
316
|
+
repo: 'myrepo',
|
|
317
|
+
alert_number: alert.number,
|
|
318
|
+
state: 'dismissed',
|
|
319
|
+
dismissed_reason: 'false positive'
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Troubleshooting
|
|
325
|
+
|
|
326
|
+
### "401 Unauthorized"
|
|
327
|
+
- Verify `GITHUB_TOKEN` is set: `echo $GITHUB_TOKEN`
|
|
328
|
+
- Token may be expired or revoked — create new one
|
|
329
|
+
- For fine-grained PAT, verify it hasn't been expired
|
|
330
|
+
|
|
331
|
+
### "403 Forbidden" for private repos
|
|
332
|
+
- Ensure token has `repo` scope
|
|
333
|
+
- For fine-grained tokens, ensure organization/repository is added
|
|
334
|
+
- Check GitHub Advanced Security is enabled (for code scanning)
|
|
335
|
+
|
|
336
|
+
### "404 Not Found"
|
|
337
|
+
- Verify owner/repo names are correct
|
|
338
|
+
- Check repository exists and is accessible with token
|
|
339
|
+
- For code scanning, ensure Advanced Security is enabled
|
|
340
|
+
|
|
341
|
+
### Rate limited (429)
|
|
342
|
+
- Wait for `x-ratelimit-reset` timestamp
|
|
343
|
+
- Consider implementing request queuing for bulk operations
|
|
344
|
+
- Use search filters to reduce unnecessary API calls
|
|
345
|
+
- For Enterprise, higher rate limits (15,000/hour) available
|
|
346
|
+
|
|
347
|
+
### Code scanning not available
|
|
348
|
+
- Requires GitHub Advanced Security (Enterprise or public repos with premium)
|
|
349
|
+
- Verify `security_events:read` scope in token
|
|
350
|
+
- Check repository has security scanning enabled
|
|
351
|
+
|
|
352
|
+
## API Reference
|
|
353
|
+
|
|
354
|
+
### Parameters and Response Schemas
|
|
355
|
+
|
|
356
|
+
Each tool accepts specific parameters documented in its definition. Common patterns:
|
|
357
|
+
|
|
358
|
+
**Pagination**: `per_page` (1-100, default 30) and `page` (starting at 1)
|
|
359
|
+
**Filtering**: `state`, `sort`, `direction`, `labels`, `assignee` (varies by tool)
|
|
360
|
+
**Templating**: URL parameters use `{placeholders}` syntax
|
|
361
|
+
|
|
362
|
+
Responses are validated against `output_schema` defined in each tool. All responses include status codes in `x-github-` headers for monitoring rate limits.
|
|
363
|
+
|
|
364
|
+
### HTTP Headers
|
|
365
|
+
|
|
366
|
+
All requests include:
|
|
367
|
+
```
|
|
368
|
+
Accept: application/vnd.github+json
|
|
369
|
+
Authorization: Bearer {GITHUB_TOKEN}
|
|
370
|
+
X-GitHub-Api-Version: 2022-11-28
|
|
371
|
+
Content-Type: application/json (for POST/PATCH/PUT)
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Rate limit headers in all responses:
|
|
375
|
+
```
|
|
376
|
+
x-ratelimit-limit: 5000
|
|
377
|
+
x-ratelimit-remaining: 4999
|
|
378
|
+
x-ratelimit-reset: 1234567890
|
|
379
|
+
x-ratelimit-used: 1
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## Contributing
|
|
383
|
+
|
|
384
|
+
For bug reports, feature requests, or tool improvements, visit the main Matimo repository CONTRIBUTING guidelines.
|
|
385
|
+
|
|
386
|
+
## License
|
|
387
|
+
|
|
388
|
+
Part of the Matimo ecosystem. See main repository for licensing information.
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
**Need help?** Check the [Matimo documentation](https://matimo.dev) or open an issue in the main repository.
|
package/definition.yaml
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# GitHub OAuth2 Provider Definition
|
|
2
|
+
#
|
|
3
|
+
# This file defines the OAuth2 configuration for GitHub.
|
|
4
|
+
# All GitHub tools reference this provider definition.
|
|
5
|
+
#
|
|
6
|
+
# Users can override these endpoints via:
|
|
7
|
+
# 1. Runtime config (highest priority)
|
|
8
|
+
# 2. Environment variables: OAUTH_GITHUB_AUTH_URL, OAUTH_GITHUB_TOKEN_URL, etc.
|
|
9
|
+
# 3. This YAML definition (lowest priority)
|
|
10
|
+
#
|
|
11
|
+
# Pattern: Define once, use everywhere
|
|
12
|
+
|
|
13
|
+
name: github-provider
|
|
14
|
+
type: provider
|
|
15
|
+
version: '1.0.0'
|
|
16
|
+
|
|
17
|
+
description: |
|
|
18
|
+
GitHub OAuth2 Provider Configuration
|
|
19
|
+
|
|
20
|
+
All GitHub tools use these endpoints for OAuth2 authorization.
|
|
21
|
+
|
|
22
|
+
Setup:
|
|
23
|
+
1. Create GitHub OAuth App at https://github.com/settings/developers
|
|
24
|
+
2. Set Client ID and Client Secret
|
|
25
|
+
3. Set Authorization callback URL
|
|
26
|
+
4. Set GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET environment variables
|
|
27
|
+
5. Set GITHUB_REDIRECT_URI to your callback URL
|
|
28
|
+
|
|
29
|
+
For GitHub Enterprise Server (GHES), override the endpoints with your instance.
|
|
30
|
+
|
|
31
|
+
provider:
|
|
32
|
+
name: github
|
|
33
|
+
displayName: GitHub
|
|
34
|
+
|
|
35
|
+
# OAuth2 Endpoints
|
|
36
|
+
# Standard GitHub.com endpoints - change for GitHub Enterprise Server
|
|
37
|
+
endpoints:
|
|
38
|
+
authorizationUrl: https://github.com/login/oauth/authorize
|
|
39
|
+
tokenUrl: https://github.com/login/oauth/access_token
|
|
40
|
+
revokeUrl: https://api.github.com/applications/{client_id}/grants/{grant_id}
|
|
41
|
+
|
|
42
|
+
# Standard scopes for common GitHub operations
|
|
43
|
+
# Tools can override with their own scopes
|
|
44
|
+
defaultScopes:
|
|
45
|
+
- repo:status
|
|
46
|
+
- repo_deployment
|
|
47
|
+
- public_repo
|
|
48
|
+
- repo
|
|
49
|
+
- gist
|
|
50
|
+
- notifications
|
|
51
|
+
- user
|
|
52
|
+
- delete_repo
|
|
53
|
+
- write:packages
|
|
54
|
+
- read:packages
|
|
55
|
+
- admin:org_hook
|
|
56
|
+
- write:org
|
|
57
|
+
- read:org
|
|
58
|
+
- admin:public_key
|
|
59
|
+
- write:public_key
|
|
60
|
+
- read:public_key
|
|
61
|
+
- admin:repo_hook
|
|
62
|
+
- write:repo_hook
|
|
63
|
+
- read:repo_hook
|
|
64
|
+
- admin:org
|
|
65
|
+
- admin:gpg_key
|
|
66
|
+
- write:gpg_key
|
|
67
|
+
- read:gpg_key
|
|
68
|
+
|
|
69
|
+
# Additional metadata
|
|
70
|
+
documentation: https://docs.github.com/en/rest
|
|
71
|
+
learnMore: https://docs.github.com/en/apps/creating-github-apps
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@matimo/github",
|
|
3
|
+
"version": "0.1.0-alpha.10",
|
|
4
|
+
"description": "GitHub API tools for Matimo - Full-featured GitHub integration with OAuth2 and PAT support",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"tools",
|
|
8
|
+
"README.md",
|
|
9
|
+
"definition.yaml"
|
|
10
|
+
],
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"matimo": "0.1.0-alpha.10"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@matimo/core": "0.1.0-alpha.10"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
name: github-add-collaborator
|
|
2
|
+
description: Add a user as a collaborator to a repository
|
|
3
|
+
version: '1.0.0'
|
|
4
|
+
requires_approval: true
|
|
5
|
+
|
|
6
|
+
parameters:
|
|
7
|
+
owner:
|
|
8
|
+
type: string
|
|
9
|
+
required: true
|
|
10
|
+
description: Repository owner username or organization
|
|
11
|
+
repo:
|
|
12
|
+
type: string
|
|
13
|
+
required: true
|
|
14
|
+
description: Repository name
|
|
15
|
+
username:
|
|
16
|
+
type: string
|
|
17
|
+
required: true
|
|
18
|
+
description: GitHub username to add
|
|
19
|
+
permission:
|
|
20
|
+
type: string
|
|
21
|
+
required: false
|
|
22
|
+
description: Permission level - pull, triage, push, maintain, or admin
|
|
23
|
+
default: push
|
|
24
|
+
|
|
25
|
+
execution:
|
|
26
|
+
type: http
|
|
27
|
+
method: PUT
|
|
28
|
+
url: 'https://api.github.com/repos/{owner}/{repo}/collaborators/{username}'
|
|
29
|
+
headers:
|
|
30
|
+
Accept: application/vnd.github+json
|
|
31
|
+
Authorization: 'Bearer {GITHUB_TOKEN}'
|
|
32
|
+
X-GitHub-Api-Version: '2022-11-28'
|
|
33
|
+
Content-Type: application/json
|
|
34
|
+
body:
|
|
35
|
+
permission: '{permission}'
|
|
36
|
+
timeout: 15000
|
|
37
|
+
|
|
38
|
+
authentication:
|
|
39
|
+
type: bearer
|
|
40
|
+
location: header
|
|
41
|
+
notes:
|
|
42
|
+
env: GITHUB_TOKEN
|
|
43
|
+
required: true
|
|
44
|
+
permission: Repository administration
|
|
45
|
+
|
|
46
|
+
output_schema:
|
|
47
|
+
type: object
|
|
48
|
+
properties:
|
|
49
|
+
id:
|
|
50
|
+
type: number
|
|
51
|
+
invitee:
|
|
52
|
+
type: object
|
|
53
|
+
permissions:
|
|
54
|
+
type: string
|
|
55
|
+
|
|
56
|
+
error_handling:
|
|
57
|
+
retry: 1
|
|
58
|
+
backoff_type: exponential
|
|
59
|
+
initial_delay_ms: 1000
|
|
60
|
+
|
|
61
|
+
examples:
|
|
62
|
+
- name: Add collaborator with push access
|
|
63
|
+
params:
|
|
64
|
+
owner: myorg
|
|
65
|
+
repo: myrepo
|
|
66
|
+
username: newuser
|
|
67
|
+
permission: push
|
|
68
|
+
- name: Add collaborator with admin access
|
|
69
|
+
params:
|
|
70
|
+
owner: myorg
|
|
71
|
+
repo: myrepo
|
|
72
|
+
username: admin_user
|
|
73
|
+
permission: admin
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
name: github-create-issue
|
|
2
|
+
description: Create a new issue in a repository
|
|
3
|
+
version: '1.0.0'
|
|
4
|
+
requires_approval: true
|
|
5
|
+
|
|
6
|
+
parameters:
|
|
7
|
+
owner:
|
|
8
|
+
type: string
|
|
9
|
+
required: true
|
|
10
|
+
description: Repository owner username or organization
|
|
11
|
+
repo:
|
|
12
|
+
type: string
|
|
13
|
+
required: true
|
|
14
|
+
description: Repository name
|
|
15
|
+
title:
|
|
16
|
+
type: string
|
|
17
|
+
required: true
|
|
18
|
+
description: Issue title
|
|
19
|
+
body:
|
|
20
|
+
type: string
|
|
21
|
+
required: false
|
|
22
|
+
description: Issue description (markdown supported)
|
|
23
|
+
assignees:
|
|
24
|
+
type: array
|
|
25
|
+
required: false
|
|
26
|
+
description: Array of github usernames to assign
|
|
27
|
+
labels:
|
|
28
|
+
type: array
|
|
29
|
+
required: false
|
|
30
|
+
description: Array of label names
|
|
31
|
+
milestone:
|
|
32
|
+
type: number
|
|
33
|
+
required: false
|
|
34
|
+
description: Milestone ID number
|
|
35
|
+
|
|
36
|
+
execution:
|
|
37
|
+
type: http
|
|
38
|
+
method: POST
|
|
39
|
+
url: 'https://api.github.com/repos/{owner}/{repo}/issues'
|
|
40
|
+
headers:
|
|
41
|
+
Accept: application/vnd.github+json
|
|
42
|
+
Authorization: 'Bearer {GITHUB_TOKEN}'
|
|
43
|
+
X-GitHub-Api-Version: '2022-11-28'
|
|
44
|
+
Content-Type: application/json
|
|
45
|
+
body:
|
|
46
|
+
title: '{title}'
|
|
47
|
+
body: '{body}'
|
|
48
|
+
assignees: '{assignees}'
|
|
49
|
+
labels: '{labels}'
|
|
50
|
+
milestone: '{milestone}'
|
|
51
|
+
timeout: 15000
|
|
52
|
+
|
|
53
|
+
authentication:
|
|
54
|
+
type: bearer
|
|
55
|
+
location: header
|
|
56
|
+
notes:
|
|
57
|
+
env: GITHUB_TOKEN
|
|
58
|
+
required: true
|
|
59
|
+
permission: Issues write
|
|
60
|
+
|
|
61
|
+
output_schema:
|
|
62
|
+
type: object
|
|
63
|
+
properties:
|
|
64
|
+
id:
|
|
65
|
+
type: number
|
|
66
|
+
number:
|
|
67
|
+
type: number
|
|
68
|
+
description: Issue number in repository
|
|
69
|
+
title:
|
|
70
|
+
type: string
|
|
71
|
+
state:
|
|
72
|
+
type: string
|
|
73
|
+
html_url:
|
|
74
|
+
type: string
|
|
75
|
+
|
|
76
|
+
error_handling:
|
|
77
|
+
retry: 1
|
|
78
|
+
backoff_type: exponential
|
|
79
|
+
initial_delay_ms: 1000
|
|
80
|
+
|
|
81
|
+
examples:
|
|
82
|
+
- name: Create simple issue
|
|
83
|
+
params:
|
|
84
|
+
owner: myorg
|
|
85
|
+
repo: myrepo
|
|
86
|
+
title: Bug in login flow
|
|
87
|
+
body: Users cannot log in with SSO
|
|
88
|
+
- name: Create issue with labels
|
|
89
|
+
params:
|
|
90
|
+
owner: myorg
|
|
91
|
+
repo: myrepo
|
|
92
|
+
title: Add dark mode
|
|
93
|
+
body: Implement dark theme
|
|
94
|
+
labels:
|
|
95
|
+
- enhancement
|
|
96
|
+
- ui
|