@slates-integrations/github 0.2.0-rc.4 → 0.2.0-rc.9
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/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +3 -0
- package/dist/sourcemap-register.cjs +1 -0
- package/docs/SPEC.md +219 -3
- package/package.json +14 -5
- package/slate.json +1 -4
- package/src/auth.ts +0 -347
- package/src/config.ts +0 -4
- package/src/index.ts +0 -78
- package/src/lib/client.ts +0 -991
- package/src/spec.ts +0 -13
- package/src/tools/comment-on-issue.ts +0 -46
- package/src/tools/create-commit-status.ts +0 -97
- package/src/tools/create-release.ts +0 -69
- package/src/tools/create-repository.ts +0 -70
- package/src/tools/get-issue.ts +0 -67
- package/src/tools/get-repository.ts +0 -75
- package/src/tools/get-user.ts +0 -64
- package/src/tools/index.ts +0 -24
- package/src/tools/list-branches.ts +0 -54
- package/src/tools/list-commits.ts +0 -70
- package/src/tools/list-issues.ts +0 -90
- package/src/tools/list-pull-requests.ts +0 -82
- package/src/tools/list-repositories.ts +0 -102
- package/src/tools/manage-collaborators.ts +0 -88
- package/src/tools/manage-file-content.ts +0 -117
- package/src/tools/manage-gist.ts +0 -183
- package/src/tools/manage-issue.ts +0 -94
- package/src/tools/manage-labels.ts +0 -93
- package/src/tools/manage-pull-request.ts +0 -111
- package/src/tools/manage-workflow.ts +0 -242
- package/src/tools/merge-pull-request.ts +0 -61
- package/src/tools/review-pull-request.ts +0 -90
- package/src/tools/search.ts +0 -72
- package/src/tools/star-repository.ts +0 -57
- package/src/tools/update-repository.ts +0 -56
- package/src/triggers/index.ts +0 -8
- package/src/triggers/issue-comment.ts +0 -94
- package/src/triggers/issues.ts +0 -111
- package/src/triggers/pull-request-review.ts +0 -95
- package/src/triggers/pull-request.ts +0 -123
- package/src/triggers/push.ts +0 -117
- package/src/triggers/release.ts +0 -103
- package/src/triggers/star.ts +0 -71
- package/src/triggers/workflow-run.ts +0 -112
- package/tsconfig.json +0 -23
package/src/spec.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SlateSpecification } from 'slates';
|
|
2
|
-
import { auth } from './auth';
|
|
3
|
-
import { config } from './config';
|
|
4
|
-
|
|
5
|
-
export let spec = SlateSpecification.create({
|
|
6
|
-
key: 'github',
|
|
7
|
-
name: 'GitHub',
|
|
8
|
-
description:
|
|
9
|
-
'Cloud-based platform for version control and collaboration using Git. Provides repository hosting, issue tracking, pull requests, code review, CI/CD with GitHub Actions, and project management.',
|
|
10
|
-
metadata: {},
|
|
11
|
-
config,
|
|
12
|
-
auth
|
|
13
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { SlateTool } from 'slates';
|
|
2
|
-
import { GitHubClient } from '../lib/client';
|
|
3
|
-
import { spec } from '../spec';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
export let commentOnIssue = SlateTool.create(spec, {
|
|
7
|
-
name: 'Comment on Issue',
|
|
8
|
-
key: 'comment_on_issue',
|
|
9
|
-
description: `Add a comment to an existing issue or pull request. Both issues and pull requests share the same comment API.`
|
|
10
|
-
})
|
|
11
|
-
.input(
|
|
12
|
-
z.object({
|
|
13
|
-
owner: z.string().describe('Repository owner (user or organization)'),
|
|
14
|
-
repo: z.string().describe('Repository name'),
|
|
15
|
-
issueNumber: z.number().describe('Issue or pull request number'),
|
|
16
|
-
body: z.string().describe('Comment body in Markdown')
|
|
17
|
-
})
|
|
18
|
-
)
|
|
19
|
-
.output(
|
|
20
|
-
z.object({
|
|
21
|
-
commentId: z.number().describe('Unique comment ID'),
|
|
22
|
-
htmlUrl: z.string().describe('URL to the comment on GitHub'),
|
|
23
|
-
author: z.string().describe('Comment author login'),
|
|
24
|
-
createdAt: z.string().describe('Creation timestamp')
|
|
25
|
-
})
|
|
26
|
-
)
|
|
27
|
-
.handleInvocation(async ctx => {
|
|
28
|
-
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
29
|
-
let comment = await client.createIssueComment(
|
|
30
|
-
ctx.input.owner,
|
|
31
|
-
ctx.input.repo,
|
|
32
|
-
ctx.input.issueNumber,
|
|
33
|
-
ctx.input.body
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
output: {
|
|
38
|
-
commentId: comment.id,
|
|
39
|
-
htmlUrl: comment.html_url,
|
|
40
|
-
author: comment.user.login,
|
|
41
|
-
createdAt: comment.created_at
|
|
42
|
-
},
|
|
43
|
-
message: `Added comment on **#${ctx.input.issueNumber}** in **${ctx.input.owner}/${ctx.input.repo}** — ${comment.html_url}`
|
|
44
|
-
};
|
|
45
|
-
})
|
|
46
|
-
.build();
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { SlateTool } from 'slates';
|
|
2
|
-
import { GitHubClient } from '../lib/client';
|
|
3
|
-
import { spec } from '../spec';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
export let createCommitStatus = SlateTool.create(spec, {
|
|
7
|
-
name: 'Create Commit Status',
|
|
8
|
-
key: 'create_commit_status',
|
|
9
|
-
description: `Create a status check on a specific commit. Useful for integrating CI/CD results, deployment status, or other external checks.
|
|
10
|
-
Also supports reading the combined status of all checks for a given ref.`,
|
|
11
|
-
instructions: [
|
|
12
|
-
'Use action "create" to set a status on a commit SHA.',
|
|
13
|
-
'Use action "get" to retrieve the combined status for a ref (branch, tag, or SHA).'
|
|
14
|
-
]
|
|
15
|
-
})
|
|
16
|
-
.input(
|
|
17
|
-
z.object({
|
|
18
|
-
owner: z.string().describe('Repository owner'),
|
|
19
|
-
repo: z.string().describe('Repository name'),
|
|
20
|
-
action: z.enum(['create', 'get']).describe('Action to perform'),
|
|
21
|
-
ref: z.string().describe('Commit SHA (for create) or branch/tag/SHA (for get)'),
|
|
22
|
-
state: z
|
|
23
|
-
.enum(['error', 'failure', 'pending', 'success'])
|
|
24
|
-
.optional()
|
|
25
|
-
.describe('Status state (required for create)'),
|
|
26
|
-
targetUrl: z.string().optional().describe('URL to link from the status (for create)'),
|
|
27
|
-
description: z
|
|
28
|
-
.string()
|
|
29
|
-
.optional()
|
|
30
|
-
.describe('Short description of the status (for create)'),
|
|
31
|
-
context: z
|
|
32
|
-
.string()
|
|
33
|
-
.optional()
|
|
34
|
-
.describe('Label to differentiate statuses (for create, default: "default")')
|
|
35
|
-
})
|
|
36
|
-
)
|
|
37
|
-
.output(
|
|
38
|
-
z.object({
|
|
39
|
-
state: z.string().describe('Status state'),
|
|
40
|
-
totalCount: z.number().optional().describe('Total number of statuses (for get)'),
|
|
41
|
-
statuses: z
|
|
42
|
-
.array(
|
|
43
|
-
z.object({
|
|
44
|
-
state: z.string(),
|
|
45
|
-
context: z.string(),
|
|
46
|
-
description: z.string().nullable(),
|
|
47
|
-
targetUrl: z.string().nullable(),
|
|
48
|
-
createdAt: z.string()
|
|
49
|
-
})
|
|
50
|
-
)
|
|
51
|
-
.optional()
|
|
52
|
-
.describe('Individual statuses (for get)'),
|
|
53
|
-
statusId: z.number().optional().describe('Created status ID'),
|
|
54
|
-
htmlUrl: z.string().optional().describe('URL to the status')
|
|
55
|
-
})
|
|
56
|
-
)
|
|
57
|
-
.handleInvocation(async ctx => {
|
|
58
|
-
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
59
|
-
let { owner, repo, action, ref } = ctx.input;
|
|
60
|
-
|
|
61
|
-
if (action === 'get') {
|
|
62
|
-
let combined = await client.getCombinedStatus(owner, repo, ref);
|
|
63
|
-
return {
|
|
64
|
-
output: {
|
|
65
|
-
state: combined.state,
|
|
66
|
-
totalCount: combined.total_count,
|
|
67
|
-
statuses: combined.statuses.map((s: any) => ({
|
|
68
|
-
state: s.state,
|
|
69
|
-
context: s.context,
|
|
70
|
-
description: s.description,
|
|
71
|
-
targetUrl: s.target_url,
|
|
72
|
-
createdAt: s.created_at
|
|
73
|
-
}))
|
|
74
|
-
},
|
|
75
|
-
message: `Combined status for \`${ref}\`: **${combined.state}** (${combined.total_count} checks).`
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (!ctx.input.state) throw new Error('state is required for create action.');
|
|
80
|
-
|
|
81
|
-
let status = await client.createCommitStatus(owner, repo, ref, {
|
|
82
|
-
state: ctx.input.state,
|
|
83
|
-
targetUrl: ctx.input.targetUrl,
|
|
84
|
-
description: ctx.input.description,
|
|
85
|
-
context: ctx.input.context
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
output: {
|
|
90
|
-
state: status.state,
|
|
91
|
-
statusId: status.id,
|
|
92
|
-
htmlUrl: status.url
|
|
93
|
-
},
|
|
94
|
-
message: `Set commit status **${status.state}** on \`${ref.slice(0, 7)}\` in **${owner}/${repo}** (context: ${status.context}).`
|
|
95
|
-
};
|
|
96
|
-
})
|
|
97
|
-
.build();
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { SlateTool } from 'slates';
|
|
2
|
-
import { GitHubClient } from '../lib/client';
|
|
3
|
-
import { spec } from '../spec';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
export let createRelease = SlateTool.create(spec, {
|
|
7
|
-
name: 'Create Release',
|
|
8
|
-
key: 'create_release',
|
|
9
|
-
description: `Create a new release for a GitHub repository with a tag, name, release notes, and draft/pre-release options.
|
|
10
|
-
Can automatically generate release notes from commits since the last release.`
|
|
11
|
-
})
|
|
12
|
-
.input(
|
|
13
|
-
z.object({
|
|
14
|
-
owner: z.string().describe('Repository owner'),
|
|
15
|
-
repo: z.string().describe('Repository name'),
|
|
16
|
-
tagName: z.string().describe('Tag name for the release (e.g., "v1.0.0")'),
|
|
17
|
-
targetCommitish: z
|
|
18
|
-
.string()
|
|
19
|
-
.optional()
|
|
20
|
-
.describe('Branch or commit SHA for the tag (defaults to default branch)'),
|
|
21
|
-
name: z.string().optional().describe('Release title'),
|
|
22
|
-
body: z.string().optional().describe('Release notes in Markdown'),
|
|
23
|
-
draft: z.boolean().optional().describe('Create as a draft release'),
|
|
24
|
-
prerelease: z.boolean().optional().describe('Mark as a pre-release'),
|
|
25
|
-
generateReleaseNotes: z
|
|
26
|
-
.boolean()
|
|
27
|
-
.optional()
|
|
28
|
-
.describe('Auto-generate release notes from commits')
|
|
29
|
-
})
|
|
30
|
-
)
|
|
31
|
-
.output(
|
|
32
|
-
z.object({
|
|
33
|
-
releaseId: z.number().describe('Release ID'),
|
|
34
|
-
tagName: z.string().describe('Tag name'),
|
|
35
|
-
name: z.string().nullable().describe('Release title'),
|
|
36
|
-
htmlUrl: z.string().describe('URL to the release on GitHub'),
|
|
37
|
-
draft: z.boolean().describe('Whether this is a draft'),
|
|
38
|
-
prerelease: z.boolean().describe('Whether this is a pre-release'),
|
|
39
|
-
createdAt: z.string().describe('Creation timestamp'),
|
|
40
|
-
publishedAt: z.string().nullable().describe('Publication timestamp')
|
|
41
|
-
})
|
|
42
|
-
)
|
|
43
|
-
.handleInvocation(async ctx => {
|
|
44
|
-
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
45
|
-
let release = await client.createRelease(ctx.input.owner, ctx.input.repo, {
|
|
46
|
-
tagName: ctx.input.tagName,
|
|
47
|
-
targetCommitish: ctx.input.targetCommitish,
|
|
48
|
-
name: ctx.input.name,
|
|
49
|
-
body: ctx.input.body,
|
|
50
|
-
draft: ctx.input.draft,
|
|
51
|
-
prerelease: ctx.input.prerelease,
|
|
52
|
-
generateReleaseNotes: ctx.input.generateReleaseNotes
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
output: {
|
|
57
|
-
releaseId: release.id,
|
|
58
|
-
tagName: release.tag_name,
|
|
59
|
-
name: release.name,
|
|
60
|
-
htmlUrl: release.html_url,
|
|
61
|
-
draft: release.draft,
|
|
62
|
-
prerelease: release.prerelease,
|
|
63
|
-
createdAt: release.created_at,
|
|
64
|
-
publishedAt: release.published_at
|
|
65
|
-
},
|
|
66
|
-
message: `Created release **${release.tag_name}**${release.name ? ` "${release.name}"` : ''} in **${ctx.input.owner}/${ctx.input.repo}** — ${release.html_url}`
|
|
67
|
-
};
|
|
68
|
-
})
|
|
69
|
-
.build();
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { SlateTool } from 'slates';
|
|
2
|
-
import { GitHubClient } from '../lib/client';
|
|
3
|
-
import { spec } from '../spec';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
export let createRepository = SlateTool.create(spec, {
|
|
7
|
-
name: 'Create Repository',
|
|
8
|
-
key: 'create_repository',
|
|
9
|
-
description: `Create a new GitHub repository for the authenticated user or within an organization.
|
|
10
|
-
Supports initializing with a README, gitignore template, and license.`,
|
|
11
|
-
tags: {
|
|
12
|
-
destructive: false
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
.input(
|
|
16
|
-
z.object({
|
|
17
|
-
name: z.string().describe('Repository name'),
|
|
18
|
-
description: z.string().optional().describe('Repository description'),
|
|
19
|
-
private: z
|
|
20
|
-
.boolean()
|
|
21
|
-
.optional()
|
|
22
|
-
.describe('Whether the repository should be private (default: false)'),
|
|
23
|
-
autoInit: z.boolean().optional().describe('Initialize with a README'),
|
|
24
|
-
gitignoreTemplate: z
|
|
25
|
-
.string()
|
|
26
|
-
.optional()
|
|
27
|
-
.describe('Gitignore template name (e.g., "Node", "Python")'),
|
|
28
|
-
licenseTemplate: z
|
|
29
|
-
.string()
|
|
30
|
-
.optional()
|
|
31
|
-
.describe('License template (e.g., "mit", "apache-2.0")'),
|
|
32
|
-
org: z
|
|
33
|
-
.string()
|
|
34
|
-
.optional()
|
|
35
|
-
.describe(
|
|
36
|
-
'Organization to create the repository in. If omitted, creates under the authenticated user.'
|
|
37
|
-
)
|
|
38
|
-
})
|
|
39
|
-
)
|
|
40
|
-
.output(
|
|
41
|
-
z.object({
|
|
42
|
-
repositoryId: z.number().describe('Unique repository ID'),
|
|
43
|
-
name: z.string().describe('Repository name'),
|
|
44
|
-
fullName: z.string().describe('Full name in owner/repo format'),
|
|
45
|
-
htmlUrl: z.string().describe('URL to the repository on GitHub'),
|
|
46
|
-
cloneUrl: z.string().describe('HTTPS clone URL'),
|
|
47
|
-
sshUrl: z.string().describe('SSH clone URL'),
|
|
48
|
-
private: z.boolean().describe('Whether the repository is private'),
|
|
49
|
-
defaultBranch: z.string().describe('Default branch name')
|
|
50
|
-
})
|
|
51
|
-
)
|
|
52
|
-
.handleInvocation(async ctx => {
|
|
53
|
-
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
54
|
-
let repo = await client.createRepository(ctx.input);
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
output: {
|
|
58
|
-
repositoryId: repo.id,
|
|
59
|
-
name: repo.name,
|
|
60
|
-
fullName: repo.full_name,
|
|
61
|
-
htmlUrl: repo.html_url,
|
|
62
|
-
cloneUrl: repo.clone_url,
|
|
63
|
-
sshUrl: repo.ssh_url,
|
|
64
|
-
private: repo.private,
|
|
65
|
-
defaultBranch: repo.default_branch
|
|
66
|
-
},
|
|
67
|
-
message: `Created ${repo.private ? 'private' : 'public'} repository **${repo.full_name}** — ${repo.html_url}`
|
|
68
|
-
};
|
|
69
|
-
})
|
|
70
|
-
.build();
|
package/src/tools/get-issue.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { SlateTool } from 'slates';
|
|
2
|
-
import { GitHubClient } from '../lib/client';
|
|
3
|
-
import { spec } from '../spec';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
export let getIssue = SlateTool.create(spec, {
|
|
7
|
-
name: 'Get Issue',
|
|
8
|
-
key: 'get_issue',
|
|
9
|
-
description: `Retrieve detailed information about a specific issue, including its body, comments count, labels, assignees, and milestone.`,
|
|
10
|
-
tags: {
|
|
11
|
-
readOnly: true
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
.input(
|
|
15
|
-
z.object({
|
|
16
|
-
owner: z.string().describe('Repository owner (user or organization)'),
|
|
17
|
-
repo: z.string().describe('Repository name'),
|
|
18
|
-
issueNumber: z.number().describe('Issue number')
|
|
19
|
-
})
|
|
20
|
-
)
|
|
21
|
-
.output(
|
|
22
|
-
z.object({
|
|
23
|
-
issueNumber: z.number().describe('Issue number'),
|
|
24
|
-
issueId: z.number().describe('Unique issue ID'),
|
|
25
|
-
title: z.string().describe('Issue title'),
|
|
26
|
-
body: z.string().nullable().describe('Issue body in Markdown'),
|
|
27
|
-
state: z.string().describe('Issue state (open/closed)'),
|
|
28
|
-
stateReason: z.string().nullable().describe('Reason for the state'),
|
|
29
|
-
htmlUrl: z.string().describe('URL to the issue on GitHub'),
|
|
30
|
-
author: z.string().describe('Issue author login'),
|
|
31
|
-
assignees: z.array(z.string()).describe('Assigned usernames'),
|
|
32
|
-
labels: z.array(z.string()).describe('Label names'),
|
|
33
|
-
milestoneName: z.string().nullable().describe('Milestone title'),
|
|
34
|
-
commentsCount: z.number().describe('Number of comments'),
|
|
35
|
-
locked: z.boolean().describe('Whether the issue is locked'),
|
|
36
|
-
createdAt: z.string().describe('Creation timestamp'),
|
|
37
|
-
updatedAt: z.string().describe('Last update timestamp'),
|
|
38
|
-
closedAt: z.string().nullable().describe('Closure timestamp')
|
|
39
|
-
})
|
|
40
|
-
)
|
|
41
|
-
.handleInvocation(async ctx => {
|
|
42
|
-
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
43
|
-
let issue = await client.getIssue(ctx.input.owner, ctx.input.repo, ctx.input.issueNumber);
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
output: {
|
|
47
|
-
issueNumber: issue.number,
|
|
48
|
-
issueId: issue.id,
|
|
49
|
-
title: issue.title,
|
|
50
|
-
body: issue.body,
|
|
51
|
-
state: issue.state,
|
|
52
|
-
stateReason: issue.state_reason ?? null,
|
|
53
|
-
htmlUrl: issue.html_url,
|
|
54
|
-
author: issue.user.login,
|
|
55
|
-
assignees: (issue.assignees ?? []).map((a: any) => a.login),
|
|
56
|
-
labels: (issue.labels ?? []).map((l: any) => l.name),
|
|
57
|
-
milestoneName: issue.milestone?.title ?? null,
|
|
58
|
-
commentsCount: issue.comments,
|
|
59
|
-
locked: issue.locked,
|
|
60
|
-
createdAt: issue.created_at,
|
|
61
|
-
updatedAt: issue.updated_at,
|
|
62
|
-
closedAt: issue.closed_at
|
|
63
|
-
},
|
|
64
|
-
message: `Issue **#${issue.number}**: "${issue.title}" (${issue.state}) — ${issue.html_url}`
|
|
65
|
-
};
|
|
66
|
-
})
|
|
67
|
-
.build();
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { SlateTool } from 'slates';
|
|
2
|
-
import { GitHubClient } from '../lib/client';
|
|
3
|
-
import { spec } from '../spec';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
export let getRepository = SlateTool.create(spec, {
|
|
7
|
-
name: 'Get Repository',
|
|
8
|
-
key: 'get_repository',
|
|
9
|
-
description: `Retrieve detailed information about a GitHub repository including its settings, statistics, and metadata.
|
|
10
|
-
Use this to inspect a repository's configuration, check its visibility, default branch, language, star/fork counts, and more.`,
|
|
11
|
-
tags: {
|
|
12
|
-
readOnly: true
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
.input(
|
|
16
|
-
z.object({
|
|
17
|
-
owner: z.string().describe('Repository owner (user or organization)'),
|
|
18
|
-
repo: z.string().describe('Repository name')
|
|
19
|
-
})
|
|
20
|
-
)
|
|
21
|
-
.output(
|
|
22
|
-
z.object({
|
|
23
|
-
repositoryId: z.number().describe('Unique repository ID'),
|
|
24
|
-
name: z.string().describe('Repository name'),
|
|
25
|
-
fullName: z.string().describe('Full name in owner/repo format'),
|
|
26
|
-
owner: z.string().describe('Repository owner login'),
|
|
27
|
-
private: z.boolean().describe('Whether the repository is private'),
|
|
28
|
-
description: z.string().nullable().describe('Repository description'),
|
|
29
|
-
htmlUrl: z.string().describe('URL to the repository on GitHub'),
|
|
30
|
-
defaultBranch: z.string().describe('Default branch name'),
|
|
31
|
-
language: z.string().nullable().describe('Primary programming language'),
|
|
32
|
-
stargazersCount: z.number().describe('Number of stars'),
|
|
33
|
-
forksCount: z.number().describe('Number of forks'),
|
|
34
|
-
openIssuesCount: z.number().describe('Number of open issues'),
|
|
35
|
-
archived: z.boolean().describe('Whether the repository is archived'),
|
|
36
|
-
createdAt: z.string().describe('Creation timestamp'),
|
|
37
|
-
updatedAt: z.string().describe('Last update timestamp'),
|
|
38
|
-
pushedAt: z.string().nullable().describe('Last push timestamp'),
|
|
39
|
-
topics: z.array(z.string()).describe('Repository topics'),
|
|
40
|
-
hasIssues: z.boolean().describe('Whether issues are enabled'),
|
|
41
|
-
hasWiki: z.boolean().describe('Whether wiki is enabled'),
|
|
42
|
-
hasProjects: z.boolean().describe('Whether projects are enabled')
|
|
43
|
-
})
|
|
44
|
-
)
|
|
45
|
-
.handleInvocation(async ctx => {
|
|
46
|
-
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
47
|
-
let repo = await client.getRepository(ctx.input.owner, ctx.input.repo);
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
output: {
|
|
51
|
-
repositoryId: repo.id,
|
|
52
|
-
name: repo.name,
|
|
53
|
-
fullName: repo.full_name,
|
|
54
|
-
owner: repo.owner.login,
|
|
55
|
-
private: repo.private,
|
|
56
|
-
description: repo.description,
|
|
57
|
-
htmlUrl: repo.html_url,
|
|
58
|
-
defaultBranch: repo.default_branch,
|
|
59
|
-
language: repo.language,
|
|
60
|
-
stargazersCount: repo.stargazers_count,
|
|
61
|
-
forksCount: repo.forks_count,
|
|
62
|
-
openIssuesCount: repo.open_issues_count,
|
|
63
|
-
archived: repo.archived,
|
|
64
|
-
createdAt: repo.created_at,
|
|
65
|
-
updatedAt: repo.updated_at,
|
|
66
|
-
pushedAt: repo.pushed_at,
|
|
67
|
-
topics: repo.topics ?? [],
|
|
68
|
-
hasIssues: repo.has_issues,
|
|
69
|
-
hasWiki: repo.has_wiki,
|
|
70
|
-
hasProjects: repo.has_projects
|
|
71
|
-
},
|
|
72
|
-
message: `Retrieved repository **${repo.full_name}** — ${repo.private ? 'private' : 'public'}, ${repo.stargazers_count} stars, default branch \`${repo.default_branch}\`.`
|
|
73
|
-
};
|
|
74
|
-
})
|
|
75
|
-
.build();
|
package/src/tools/get-user.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { SlateTool } from 'slates';
|
|
2
|
-
import { GitHubClient } from '../lib/client';
|
|
3
|
-
import { spec } from '../spec';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
export let getUser = SlateTool.create(spec, {
|
|
7
|
-
name: 'Get User',
|
|
8
|
-
key: 'get_user',
|
|
9
|
-
description: `Retrieve a GitHub user's profile. Provide a username to look up any user, or omit it to get the authenticated user's profile.`,
|
|
10
|
-
tags: {
|
|
11
|
-
readOnly: true
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
.input(
|
|
15
|
-
z.object({
|
|
16
|
-
username: z
|
|
17
|
-
.string()
|
|
18
|
-
.optional()
|
|
19
|
-
.describe('GitHub username to look up. Omit to get the authenticated user.')
|
|
20
|
-
})
|
|
21
|
-
)
|
|
22
|
-
.output(
|
|
23
|
-
z.object({
|
|
24
|
-
userId: z.number().describe('User ID'),
|
|
25
|
-
login: z.string().describe('Username'),
|
|
26
|
-
name: z.string().nullable().describe('Display name'),
|
|
27
|
-
email: z.string().nullable().describe('Public email'),
|
|
28
|
-
bio: z.string().nullable().describe('User bio'),
|
|
29
|
-
company: z.string().nullable().describe('Company'),
|
|
30
|
-
location: z.string().nullable().describe('Location'),
|
|
31
|
-
htmlUrl: z.string().describe('Profile URL'),
|
|
32
|
-
avatarUrl: z.string().describe('Avatar URL'),
|
|
33
|
-
publicRepos: z.number().describe('Number of public repositories'),
|
|
34
|
-
followers: z.number().describe('Number of followers'),
|
|
35
|
-
following: z.number().describe('Number of users following'),
|
|
36
|
-
createdAt: z.string().describe('Account creation timestamp')
|
|
37
|
-
})
|
|
38
|
-
)
|
|
39
|
-
.handleInvocation(async ctx => {
|
|
40
|
-
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
41
|
-
let user = ctx.input.username
|
|
42
|
-
? await client.getUser(ctx.input.username)
|
|
43
|
-
: await client.getAuthenticatedUser();
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
output: {
|
|
47
|
-
userId: user.id,
|
|
48
|
-
login: user.login,
|
|
49
|
-
name: user.name,
|
|
50
|
-
email: user.email,
|
|
51
|
-
bio: user.bio,
|
|
52
|
-
company: user.company,
|
|
53
|
-
location: user.location,
|
|
54
|
-
htmlUrl: user.html_url,
|
|
55
|
-
avatarUrl: user.avatar_url,
|
|
56
|
-
publicRepos: user.public_repos,
|
|
57
|
-
followers: user.followers,
|
|
58
|
-
following: user.following,
|
|
59
|
-
createdAt: user.created_at
|
|
60
|
-
},
|
|
61
|
-
message: `User **${user.login}**${user.name ? ` (${user.name})` : ''} — ${user.public_repos} public repos, ${user.followers} followers.`
|
|
62
|
-
};
|
|
63
|
-
})
|
|
64
|
-
.build();
|
package/src/tools/index.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export * from './get-repository';
|
|
2
|
-
export * from './list-repositories';
|
|
3
|
-
export * from './create-repository';
|
|
4
|
-
export * from './update-repository';
|
|
5
|
-
export * from './star-repository';
|
|
6
|
-
export * from './manage-issue';
|
|
7
|
-
export * from './list-issues';
|
|
8
|
-
export * from './get-issue';
|
|
9
|
-
export * from './comment-on-issue';
|
|
10
|
-
export * from './manage-pull-request';
|
|
11
|
-
export * from './list-pull-requests';
|
|
12
|
-
export * from './merge-pull-request';
|
|
13
|
-
export * from './review-pull-request';
|
|
14
|
-
export * from './search';
|
|
15
|
-
export * from './manage-file-content';
|
|
16
|
-
export * from './manage-workflow';
|
|
17
|
-
export * from './create-release';
|
|
18
|
-
export * from './list-commits';
|
|
19
|
-
export * from './list-branches';
|
|
20
|
-
export * from './manage-labels';
|
|
21
|
-
export * from './manage-gist';
|
|
22
|
-
export * from './manage-collaborators';
|
|
23
|
-
export * from './get-user';
|
|
24
|
-
export * from './create-commit-status';
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { SlateTool } from 'slates';
|
|
2
|
-
import { GitHubClient } from '../lib/client';
|
|
3
|
-
import { spec } from '../spec';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
export let listBranches = SlateTool.create(spec, {
|
|
7
|
-
name: 'List Branches',
|
|
8
|
-
key: 'list_branches',
|
|
9
|
-
description: `List branches in a GitHub repository with optional filtering for protected branches.`,
|
|
10
|
-
tags: {
|
|
11
|
-
readOnly: true
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
.input(
|
|
15
|
-
z.object({
|
|
16
|
-
owner: z.string().describe('Repository owner'),
|
|
17
|
-
repo: z.string().describe('Repository name'),
|
|
18
|
-
protected: z.boolean().optional().describe('Filter by protection status'),
|
|
19
|
-
perPage: z.number().optional().describe('Results per page (max 100)'),
|
|
20
|
-
page: z.number().optional().describe('Page number')
|
|
21
|
-
})
|
|
22
|
-
)
|
|
23
|
-
.output(
|
|
24
|
-
z.object({
|
|
25
|
-
branches: z.array(
|
|
26
|
-
z.object({
|
|
27
|
-
name: z.string().describe('Branch name'),
|
|
28
|
-
sha: z.string().describe('HEAD commit SHA'),
|
|
29
|
-
protected: z.boolean().describe('Whether the branch is protected')
|
|
30
|
-
})
|
|
31
|
-
),
|
|
32
|
-
totalCount: z.number().describe('Number of branches returned')
|
|
33
|
-
})
|
|
34
|
-
)
|
|
35
|
-
.handleInvocation(async ctx => {
|
|
36
|
-
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
37
|
-
let branches = await client.listBranches(ctx.input.owner, ctx.input.repo, {
|
|
38
|
-
perPage: ctx.input.perPage,
|
|
39
|
-
page: ctx.input.page,
|
|
40
|
-
protected: ctx.input.protected
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
let mapped = branches.map((b: any) => ({
|
|
44
|
-
name: b.name,
|
|
45
|
-
sha: b.commit.sha,
|
|
46
|
-
protected: b.protected
|
|
47
|
-
}));
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
output: { branches: mapped, totalCount: mapped.length },
|
|
51
|
-
message: `Found **${mapped.length}** branches in **${ctx.input.owner}/${ctx.input.repo}**.`
|
|
52
|
-
};
|
|
53
|
-
})
|
|
54
|
-
.build();
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { SlateTool } from 'slates';
|
|
2
|
-
import { GitHubClient } from '../lib/client';
|
|
3
|
-
import { spec } from '../spec';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
export let listCommits = SlateTool.create(spec, {
|
|
7
|
-
name: 'List Commits',
|
|
8
|
-
key: 'list_commits',
|
|
9
|
-
description: `List commits on a repository branch with filtering by SHA, path, author, or date range.`,
|
|
10
|
-
tags: {
|
|
11
|
-
readOnly: true
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
.input(
|
|
15
|
-
z.object({
|
|
16
|
-
owner: z.string().describe('Repository owner'),
|
|
17
|
-
repo: z.string().describe('Repository name'),
|
|
18
|
-
sha: z.string().optional().describe('Branch name or commit SHA to start listing from'),
|
|
19
|
-
path: z.string().optional().describe('Only commits containing this file path'),
|
|
20
|
-
author: z.string().optional().describe('GitHub login or email to filter by'),
|
|
21
|
-
since: z.string().optional().describe('Only commits after this ISO 8601 date'),
|
|
22
|
-
until: z.string().optional().describe('Only commits before this ISO 8601 date'),
|
|
23
|
-
perPage: z.number().optional().describe('Results per page (max 100)'),
|
|
24
|
-
page: z.number().optional().describe('Page number')
|
|
25
|
-
})
|
|
26
|
-
)
|
|
27
|
-
.output(
|
|
28
|
-
z.object({
|
|
29
|
-
commits: z.array(
|
|
30
|
-
z.object({
|
|
31
|
-
sha: z.string().describe('Commit SHA'),
|
|
32
|
-
message: z.string().describe('Commit message'),
|
|
33
|
-
author: z.string().nullable().describe('Author login'),
|
|
34
|
-
authorEmail: z.string().nullable().describe('Author email'),
|
|
35
|
-
committerLogin: z.string().nullable().describe('Committer login'),
|
|
36
|
-
date: z.string().describe('Commit date'),
|
|
37
|
-
htmlUrl: z.string().describe('URL to the commit on GitHub')
|
|
38
|
-
})
|
|
39
|
-
),
|
|
40
|
-
totalCount: z.number().describe('Number of commits returned')
|
|
41
|
-
})
|
|
42
|
-
)
|
|
43
|
-
.handleInvocation(async ctx => {
|
|
44
|
-
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
45
|
-
let commits = await client.listCommits(ctx.input.owner, ctx.input.repo, {
|
|
46
|
-
sha: ctx.input.sha,
|
|
47
|
-
path: ctx.input.path,
|
|
48
|
-
author: ctx.input.author,
|
|
49
|
-
since: ctx.input.since,
|
|
50
|
-
until: ctx.input.until,
|
|
51
|
-
perPage: ctx.input.perPage,
|
|
52
|
-
page: ctx.input.page
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
let mapped = commits.map((c: any) => ({
|
|
56
|
-
sha: c.sha,
|
|
57
|
-
message: c.commit.message,
|
|
58
|
-
author: c.author?.login ?? null,
|
|
59
|
-
authorEmail: c.commit.author?.email ?? null,
|
|
60
|
-
committerLogin: c.committer?.login ?? null,
|
|
61
|
-
date: c.commit.author?.date ?? c.commit.committer?.date,
|
|
62
|
-
htmlUrl: c.html_url
|
|
63
|
-
}));
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
output: { commits: mapped, totalCount: mapped.length },
|
|
67
|
-
message: `Found **${mapped.length}** commits in **${ctx.input.owner}/${ctx.input.repo}**${ctx.input.sha ? ` on \`${ctx.input.sha}\`` : ''}.`
|
|
68
|
-
};
|
|
69
|
-
})
|
|
70
|
-
.build();
|