@loopstack/github-oauth-example 0.1.1
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/README.md +114 -0
- package/dist/github-example.module.d.ts +3 -0
- package/dist/github-example.module.d.ts.map +1 -0
- package/dist/github-example.module.js +27 -0
- package/dist/github-example.module.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/authenticate-github-task.tool.d.ts +17 -0
- package/dist/tools/authenticate-github-task.tool.d.ts.map +1 -0
- package/dist/tools/authenticate-github-task.tool.js +107 -0
- package/dist/tools/authenticate-github-task.tool.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +18 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/workflows/github-agent.workflow.d.ts +48 -0
- package/dist/workflows/github-agent.workflow.d.ts.map +1 -0
- package/dist/workflows/github-agent.workflow.js +215 -0
- package/dist/workflows/github-agent.workflow.js.map +1 -0
- package/dist/workflows/github-agent.workflow.yaml +154 -0
- package/dist/workflows/github-repos-overview.workflow.d.ts +102 -0
- package/dist/workflows/github-repos-overview.workflow.d.ts.map +1 -0
- package/dist/workflows/github-repos-overview.workflow.js +300 -0
- package/dist/workflows/github-repos-overview.workflow.js.map +1 -0
- package/dist/workflows/github-repos-overview.workflow.yaml +249 -0
- package/dist/workflows/index.d.ts +3 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/index.js +19 -0
- package/dist/workflows/index.js.map +1 -0
- package/package.json +80 -0
- package/src/github-example.module.ts +14 -0
- package/src/index.ts +3 -0
- package/src/tools/authenticate-github-task.tool.ts +125 -0
- package/src/tools/index.ts +1 -0
- package/src/workflows/__tests__/github-repos-overview-workflow.spec.ts +725 -0
- package/src/workflows/github-agent.workflow.ts +118 -0
- package/src/workflows/github-agent.workflow.yaml +154 -0
- package/src/workflows/github-repos-overview.workflow.ts +254 -0
- package/src/workflows/github-repos-overview.workflow.yaml +249 -0
- package/src/workflows/index.ts +2 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import {
|
|
4
|
+
ClaudeGenerateText,
|
|
5
|
+
ClaudeMessageDocument,
|
|
6
|
+
DelegateToolCalls,
|
|
7
|
+
UpdateToolResult,
|
|
8
|
+
} from '@loopstack/claude-module';
|
|
9
|
+
import {
|
|
10
|
+
InjectDocument,
|
|
11
|
+
InjectTool,
|
|
12
|
+
InjectWorkflow,
|
|
13
|
+
Runtime,
|
|
14
|
+
State,
|
|
15
|
+
Workflow,
|
|
16
|
+
WorkflowInterface,
|
|
17
|
+
} from '@loopstack/common';
|
|
18
|
+
import { CreateDocument, LinkDocument, Task } from '@loopstack/core';
|
|
19
|
+
import {
|
|
20
|
+
GitHubCreateIssueCommentTool,
|
|
21
|
+
GitHubCreateIssueTool,
|
|
22
|
+
GitHubCreateOrUpdateFileTool,
|
|
23
|
+
GitHubCreatePullRequestTool,
|
|
24
|
+
GitHubCreateRepoTool,
|
|
25
|
+
GitHubGetAuthenticatedUserTool,
|
|
26
|
+
GitHubGetCommitTool,
|
|
27
|
+
GitHubGetFileContentTool,
|
|
28
|
+
GitHubGetIssueTool,
|
|
29
|
+
GitHubGetPullRequestTool,
|
|
30
|
+
GitHubGetRepoTool,
|
|
31
|
+
GitHubGetWorkflowRunTool,
|
|
32
|
+
GitHubListBranchesTool,
|
|
33
|
+
GitHubListDirectoryTool,
|
|
34
|
+
GitHubListIssuesTool,
|
|
35
|
+
GitHubListPrReviewsTool,
|
|
36
|
+
GitHubListPullRequestsTool,
|
|
37
|
+
GitHubListReposTool,
|
|
38
|
+
GitHubListUserOrgsTool,
|
|
39
|
+
GitHubListWorkflowRunsTool,
|
|
40
|
+
GitHubMergePullRequestTool,
|
|
41
|
+
GitHubSearchCodeTool,
|
|
42
|
+
GitHubSearchIssuesTool,
|
|
43
|
+
GitHubSearchReposTool,
|
|
44
|
+
GitHubTriggerWorkflowTool,
|
|
45
|
+
} from '@loopstack/github-module';
|
|
46
|
+
import { OAuthWorkflow } from '@loopstack/oauth-module';
|
|
47
|
+
import { AuthenticateGitHubTask } from '../tools/authenticate-github-task.tool';
|
|
48
|
+
|
|
49
|
+
@Injectable()
|
|
50
|
+
@Workflow({
|
|
51
|
+
configFile: __dirname + '/github-agent.workflow.yaml',
|
|
52
|
+
})
|
|
53
|
+
export class GitHubAgentWorkflow implements WorkflowInterface {
|
|
54
|
+
@InjectTool() createDocument: CreateDocument;
|
|
55
|
+
@InjectTool() claudeGenerateText: ClaudeGenerateText;
|
|
56
|
+
@InjectTool() delegateToolCalls: DelegateToolCalls;
|
|
57
|
+
@InjectTool() updateToolResult: UpdateToolResult;
|
|
58
|
+
@InjectTool() task: Task;
|
|
59
|
+
@InjectTool() authenticateGitHub: AuthenticateGitHubTask;
|
|
60
|
+
|
|
61
|
+
@InjectDocument() claudeMessageDocument: ClaudeMessageDocument;
|
|
62
|
+
@InjectDocument() linkDocument: LinkDocument;
|
|
63
|
+
|
|
64
|
+
// GitHub Repos tools
|
|
65
|
+
@InjectTool() gitHubListRepos: GitHubListReposTool;
|
|
66
|
+
@InjectTool() gitHubGetRepo: GitHubGetRepoTool;
|
|
67
|
+
@InjectTool() gitHubCreateRepo: GitHubCreateRepoTool;
|
|
68
|
+
@InjectTool() gitHubListBranches: GitHubListBranchesTool;
|
|
69
|
+
|
|
70
|
+
// GitHub Issues tools
|
|
71
|
+
@InjectTool() gitHubListIssues: GitHubListIssuesTool;
|
|
72
|
+
@InjectTool() gitHubGetIssue: GitHubGetIssueTool;
|
|
73
|
+
@InjectTool() gitHubCreateIssue: GitHubCreateIssueTool;
|
|
74
|
+
@InjectTool() gitHubCreateIssueComment: GitHubCreateIssueCommentTool;
|
|
75
|
+
|
|
76
|
+
// GitHub Pull Requests tools
|
|
77
|
+
@InjectTool() gitHubListPullRequests: GitHubListPullRequestsTool;
|
|
78
|
+
@InjectTool() gitHubGetPullRequest: GitHubGetPullRequestTool;
|
|
79
|
+
@InjectTool() gitHubCreatePullRequest: GitHubCreatePullRequestTool;
|
|
80
|
+
@InjectTool() gitHubMergePullRequest: GitHubMergePullRequestTool;
|
|
81
|
+
@InjectTool() gitHubListPrReviews: GitHubListPrReviewsTool;
|
|
82
|
+
|
|
83
|
+
// GitHub Content / Git Ops tools
|
|
84
|
+
@InjectTool() gitHubGetFileContent: GitHubGetFileContentTool;
|
|
85
|
+
@InjectTool() gitHubCreateOrUpdateFile: GitHubCreateOrUpdateFileTool;
|
|
86
|
+
@InjectTool() gitHubListDirectory: GitHubListDirectoryTool;
|
|
87
|
+
@InjectTool() gitHubGetCommit: GitHubGetCommitTool;
|
|
88
|
+
|
|
89
|
+
// GitHub Actions tools
|
|
90
|
+
@InjectTool() gitHubListWorkflowRuns: GitHubListWorkflowRunsTool;
|
|
91
|
+
@InjectTool() gitHubTriggerWorkflow: GitHubTriggerWorkflowTool;
|
|
92
|
+
@InjectTool() gitHubGetWorkflowRun: GitHubGetWorkflowRunTool;
|
|
93
|
+
|
|
94
|
+
// GitHub Search tools
|
|
95
|
+
@InjectTool() gitHubSearchCode: GitHubSearchCodeTool;
|
|
96
|
+
@InjectTool() gitHubSearchRepos: GitHubSearchReposTool;
|
|
97
|
+
@InjectTool() gitHubSearchIssues: GitHubSearchIssuesTool;
|
|
98
|
+
|
|
99
|
+
// GitHub Users & Orgs tools
|
|
100
|
+
@InjectTool() gitHubGetAuthenticatedUser: GitHubGetAuthenticatedUserTool;
|
|
101
|
+
@InjectTool() gitHubListUserOrgs: GitHubListUserOrgsTool;
|
|
102
|
+
|
|
103
|
+
@InjectWorkflow() oAuth: OAuthWorkflow;
|
|
104
|
+
|
|
105
|
+
@State({
|
|
106
|
+
schema: z.object({
|
|
107
|
+
llmResult: z.any().optional(),
|
|
108
|
+
delegateResult: z.any().optional(),
|
|
109
|
+
}),
|
|
110
|
+
})
|
|
111
|
+
state: {
|
|
112
|
+
llmResult?: any;
|
|
113
|
+
delegateResult?: any;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
@Runtime()
|
|
117
|
+
runtime: any;
|
|
118
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
title: 'GitHub Agent'
|
|
2
|
+
|
|
3
|
+
description: |
|
|
4
|
+
An interactive chat agent with access to GitHub.
|
|
5
|
+
Ask it to manage repositories, issues, pull requests, browse code, check CI/CD status,
|
|
6
|
+
search across GitHub, and more. Handles OAuth authentication automatically when needed —
|
|
7
|
+
the agent detects unauthorized errors and launches authentication on its own.
|
|
8
|
+
|
|
9
|
+
ui:
|
|
10
|
+
actions:
|
|
11
|
+
- type: custom
|
|
12
|
+
widget: prompt-input
|
|
13
|
+
enabledWhen:
|
|
14
|
+
- waiting_for_user
|
|
15
|
+
options:
|
|
16
|
+
transition: user_message
|
|
17
|
+
label: Send Message
|
|
18
|
+
|
|
19
|
+
transitions:
|
|
20
|
+
- id: setup
|
|
21
|
+
from: start
|
|
22
|
+
to: waiting_for_user
|
|
23
|
+
call:
|
|
24
|
+
- tool: createDocument
|
|
25
|
+
args:
|
|
26
|
+
document: claudeMessageDocument
|
|
27
|
+
update:
|
|
28
|
+
meta:
|
|
29
|
+
hidden: true
|
|
30
|
+
content:
|
|
31
|
+
role: user
|
|
32
|
+
content: |
|
|
33
|
+
You are a helpful GitHub assistant. You have access to the user's
|
|
34
|
+
GitHub account through the tools provided to you.
|
|
35
|
+
|
|
36
|
+
You can help with:
|
|
37
|
+
- **Repositories**: List repos, get repo details, create repos, list branches
|
|
38
|
+
- **Issues**: List issues, get issue details, create issues, comment on issues
|
|
39
|
+
- **Pull Requests**: List PRs, get PR details, create PRs, merge PRs, list reviews
|
|
40
|
+
- **Code & Content**: Read files, create/update files, browse directories, view commits
|
|
41
|
+
- **Actions (CI/CD)**: List workflow runs, trigger workflows, check run status
|
|
42
|
+
- **Search**: Search code, repositories, and issues across GitHub
|
|
43
|
+
- **Users & Orgs**: Get user profile, list organizations
|
|
44
|
+
|
|
45
|
+
When a tool returns `{ error: "unauthorized" }` or `{ error: "401" }`, call the
|
|
46
|
+
`authenticateGitHub` tool with the required OAuth scopes to let the user sign in.
|
|
47
|
+
After authentication completes, retry the original request.
|
|
48
|
+
|
|
49
|
+
Common scopes: repo, user, workflow, read:org
|
|
50
|
+
|
|
51
|
+
IMPORTANT: When using authenticateGitHub, it must be the ONLY tool call in your response.
|
|
52
|
+
|
|
53
|
+
Be concise and helpful. Format results clearly using markdown.
|
|
54
|
+
When showing repository or issue information, include links where available.
|
|
55
|
+
|
|
56
|
+
- id: user_message
|
|
57
|
+
from: waiting_for_user
|
|
58
|
+
to: ready
|
|
59
|
+
trigger: manual
|
|
60
|
+
call:
|
|
61
|
+
- tool: createDocument
|
|
62
|
+
args:
|
|
63
|
+
document: claudeMessageDocument
|
|
64
|
+
update:
|
|
65
|
+
content:
|
|
66
|
+
role: user
|
|
67
|
+
content: ${{ runtime.transition.payload }}
|
|
68
|
+
|
|
69
|
+
- id: llm_turn
|
|
70
|
+
from: ready
|
|
71
|
+
to: prompt_executed
|
|
72
|
+
call:
|
|
73
|
+
- id: llm_call
|
|
74
|
+
tool: claudeGenerateText
|
|
75
|
+
args:
|
|
76
|
+
system: |
|
|
77
|
+
You are a helpful GitHub assistant with access to repository, issue, PR, code, actions,
|
|
78
|
+
and search tools. When a tool returns an unauthorized error, use authenticateGitHub
|
|
79
|
+
to let the user sign in, then retry. Be concise and format results using markdown.
|
|
80
|
+
claude:
|
|
81
|
+
model: claude-sonnet-4-6
|
|
82
|
+
messagesSearchTag: message
|
|
83
|
+
tools:
|
|
84
|
+
- gitHubListRepos
|
|
85
|
+
- gitHubGetRepo
|
|
86
|
+
- gitHubCreateRepo
|
|
87
|
+
- gitHubListBranches
|
|
88
|
+
- gitHubListIssues
|
|
89
|
+
- gitHubGetIssue
|
|
90
|
+
- gitHubCreateIssue
|
|
91
|
+
- gitHubCreateIssueComment
|
|
92
|
+
- gitHubListPullRequests
|
|
93
|
+
- gitHubGetPullRequest
|
|
94
|
+
- gitHubCreatePullRequest
|
|
95
|
+
- gitHubMergePullRequest
|
|
96
|
+
- gitHubListPrReviews
|
|
97
|
+
- gitHubGetFileContent
|
|
98
|
+
- gitHubCreateOrUpdateFile
|
|
99
|
+
- gitHubListDirectory
|
|
100
|
+
- gitHubGetCommit
|
|
101
|
+
- gitHubListWorkflowRuns
|
|
102
|
+
- gitHubTriggerWorkflow
|
|
103
|
+
- gitHubGetWorkflowRun
|
|
104
|
+
- gitHubSearchCode
|
|
105
|
+
- gitHubSearchRepos
|
|
106
|
+
- gitHubSearchIssues
|
|
107
|
+
- gitHubGetAuthenticatedUser
|
|
108
|
+
- gitHubListUserOrgs
|
|
109
|
+
- authenticateGitHub
|
|
110
|
+
assign:
|
|
111
|
+
llmResult: ${{ result.data }}
|
|
112
|
+
|
|
113
|
+
- id: execute_tool_calls
|
|
114
|
+
from: prompt_executed
|
|
115
|
+
to: awaiting_tools
|
|
116
|
+
if: ${{ state.llmResult.stop_reason == 'tool_use' }}
|
|
117
|
+
call:
|
|
118
|
+
- tool: delegateToolCalls
|
|
119
|
+
args:
|
|
120
|
+
message: ${{ state.llmResult }}
|
|
121
|
+
document: claudeMessageDocument
|
|
122
|
+
callback:
|
|
123
|
+
transition: tool_result_received
|
|
124
|
+
assign:
|
|
125
|
+
delegateResult: ${{ result.data }}
|
|
126
|
+
|
|
127
|
+
- id: tool_result_received
|
|
128
|
+
from: awaiting_tools
|
|
129
|
+
to: awaiting_tools
|
|
130
|
+
trigger: manual
|
|
131
|
+
call:
|
|
132
|
+
- tool: updateToolResult
|
|
133
|
+
args:
|
|
134
|
+
delegateResult: ${{ state.delegateResult }}
|
|
135
|
+
completedTool: ${{ runtime.transition.payload }}
|
|
136
|
+
document: claudeMessageDocument
|
|
137
|
+
assign:
|
|
138
|
+
delegateResult: ${{ result.data }}
|
|
139
|
+
|
|
140
|
+
- id: all_tools_complete
|
|
141
|
+
from: awaiting_tools
|
|
142
|
+
to: ready
|
|
143
|
+
if: ${{ state.delegateResult.allCompleted }}
|
|
144
|
+
|
|
145
|
+
- id: respond
|
|
146
|
+
from: prompt_executed
|
|
147
|
+
to: waiting_for_user
|
|
148
|
+
call:
|
|
149
|
+
- tool: createDocument
|
|
150
|
+
args:
|
|
151
|
+
id: ${{ state.llmResult.id }}
|
|
152
|
+
document: claudeMessageDocument
|
|
153
|
+
update:
|
|
154
|
+
content: ${{ state.llmResult }}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import {
|
|
4
|
+
Context,
|
|
5
|
+
DefineHelper,
|
|
6
|
+
InjectDocument,
|
|
7
|
+
InjectTool,
|
|
8
|
+
InjectWorkflow,
|
|
9
|
+
Input,
|
|
10
|
+
Runtime,
|
|
11
|
+
State,
|
|
12
|
+
Workflow,
|
|
13
|
+
WorkflowInterface,
|
|
14
|
+
} from '@loopstack/common';
|
|
15
|
+
import { CreateDocument, LinkDocument, MarkdownDocument, Task } from '@loopstack/core';
|
|
16
|
+
import { CreateChatMessage } from '@loopstack/create-chat-message-tool';
|
|
17
|
+
import {
|
|
18
|
+
GitHubCreateIssueCommentTool,
|
|
19
|
+
GitHubCreateIssueTool,
|
|
20
|
+
GitHubCreateOrUpdateFileTool,
|
|
21
|
+
GitHubCreatePullRequestTool,
|
|
22
|
+
GitHubCreateRepoTool,
|
|
23
|
+
GitHubGetAuthenticatedUserTool,
|
|
24
|
+
GitHubGetCommitTool,
|
|
25
|
+
GitHubGetFileContentTool,
|
|
26
|
+
GitHubGetIssueTool,
|
|
27
|
+
GitHubGetPullRequestTool,
|
|
28
|
+
GitHubGetRepoTool,
|
|
29
|
+
GitHubGetWorkflowRunTool,
|
|
30
|
+
GitHubListBranchesTool,
|
|
31
|
+
GitHubListDirectoryTool,
|
|
32
|
+
GitHubListIssuesTool,
|
|
33
|
+
GitHubListPrReviewsTool,
|
|
34
|
+
GitHubListPullRequestsTool,
|
|
35
|
+
GitHubListReposTool,
|
|
36
|
+
GitHubListUserOrgsTool,
|
|
37
|
+
GitHubListWorkflowRunsTool,
|
|
38
|
+
GitHubMergePullRequestTool,
|
|
39
|
+
GitHubSearchCodeTool,
|
|
40
|
+
GitHubSearchIssuesTool,
|
|
41
|
+
GitHubSearchReposTool,
|
|
42
|
+
GitHubTriggerWorkflowTool,
|
|
43
|
+
} from '@loopstack/github-module';
|
|
44
|
+
import { OAuthWorkflow } from '@loopstack/oauth-module';
|
|
45
|
+
|
|
46
|
+
@Injectable()
|
|
47
|
+
@Workflow({
|
|
48
|
+
configFile: __dirname + '/github-repos-overview.workflow.yaml',
|
|
49
|
+
})
|
|
50
|
+
export class GitHubReposOverviewWorkflow implements WorkflowInterface {
|
|
51
|
+
// Core tools
|
|
52
|
+
@InjectTool() private task: Task;
|
|
53
|
+
@InjectTool() private createDocument: CreateDocument;
|
|
54
|
+
@InjectTool() private createChatMessage: CreateChatMessage;
|
|
55
|
+
|
|
56
|
+
// GitHub — Users
|
|
57
|
+
@InjectTool() private gitHubGetAuthenticatedUser: GitHubGetAuthenticatedUserTool;
|
|
58
|
+
@InjectTool() private gitHubListUserOrgs: GitHubListUserOrgsTool;
|
|
59
|
+
|
|
60
|
+
// GitHub — Repos
|
|
61
|
+
@InjectTool() private gitHubListRepos: GitHubListReposTool;
|
|
62
|
+
@InjectTool() private gitHubGetRepo: GitHubGetRepoTool;
|
|
63
|
+
@InjectTool() private gitHubCreateRepo: GitHubCreateRepoTool;
|
|
64
|
+
@InjectTool() private gitHubListBranches: GitHubListBranchesTool;
|
|
65
|
+
|
|
66
|
+
// GitHub — Issues
|
|
67
|
+
@InjectTool() private gitHubListIssues: GitHubListIssuesTool;
|
|
68
|
+
@InjectTool() private gitHubGetIssue: GitHubGetIssueTool;
|
|
69
|
+
@InjectTool() private gitHubCreateIssue: GitHubCreateIssueTool;
|
|
70
|
+
@InjectTool() private gitHubCreateIssueComment: GitHubCreateIssueCommentTool;
|
|
71
|
+
|
|
72
|
+
// GitHub — Pull Requests
|
|
73
|
+
@InjectTool() private gitHubListPullRequests: GitHubListPullRequestsTool;
|
|
74
|
+
@InjectTool() private gitHubGetPullRequest: GitHubGetPullRequestTool;
|
|
75
|
+
@InjectTool() private gitHubCreatePullRequest: GitHubCreatePullRequestTool;
|
|
76
|
+
@InjectTool() private gitHubMergePullRequest: GitHubMergePullRequestTool;
|
|
77
|
+
@InjectTool() private gitHubListPrReviews: GitHubListPrReviewsTool;
|
|
78
|
+
|
|
79
|
+
// GitHub — Content
|
|
80
|
+
@InjectTool() private gitHubGetFileContent: GitHubGetFileContentTool;
|
|
81
|
+
@InjectTool() private gitHubCreateOrUpdateFile: GitHubCreateOrUpdateFileTool;
|
|
82
|
+
@InjectTool() private gitHubListDirectory: GitHubListDirectoryTool;
|
|
83
|
+
@InjectTool() private gitHubGetCommit: GitHubGetCommitTool;
|
|
84
|
+
|
|
85
|
+
// GitHub — Actions
|
|
86
|
+
@InjectTool() private gitHubListWorkflowRuns: GitHubListWorkflowRunsTool;
|
|
87
|
+
@InjectTool() private gitHubTriggerWorkflow: GitHubTriggerWorkflowTool;
|
|
88
|
+
@InjectTool() private gitHubGetWorkflowRun: GitHubGetWorkflowRunTool;
|
|
89
|
+
|
|
90
|
+
// GitHub — Search
|
|
91
|
+
@InjectTool() private gitHubSearchCode: GitHubSearchCodeTool;
|
|
92
|
+
@InjectTool() private gitHubSearchRepos: GitHubSearchReposTool;
|
|
93
|
+
@InjectTool() private gitHubSearchIssues: GitHubSearchIssuesTool;
|
|
94
|
+
|
|
95
|
+
// Documents
|
|
96
|
+
@InjectDocument() private linkDocument: LinkDocument;
|
|
97
|
+
@InjectDocument() private markdown: MarkdownDocument;
|
|
98
|
+
|
|
99
|
+
@InjectWorkflow() oAuth: OAuthWorkflow;
|
|
100
|
+
|
|
101
|
+
@Input({
|
|
102
|
+
schema: z
|
|
103
|
+
.object({
|
|
104
|
+
owner: z.string().default('octocat'),
|
|
105
|
+
repo: z.string().default('Hello-World'),
|
|
106
|
+
})
|
|
107
|
+
.strict(),
|
|
108
|
+
})
|
|
109
|
+
args: {
|
|
110
|
+
owner: string;
|
|
111
|
+
repo: string;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
@Context()
|
|
115
|
+
context: any;
|
|
116
|
+
|
|
117
|
+
@Runtime()
|
|
118
|
+
runtime: any;
|
|
119
|
+
|
|
120
|
+
@State({
|
|
121
|
+
schema: z
|
|
122
|
+
.object({
|
|
123
|
+
requiresAuthentication: z.boolean().optional(),
|
|
124
|
+
user: z
|
|
125
|
+
.object({
|
|
126
|
+
login: z.string(),
|
|
127
|
+
name: z.string().nullable(),
|
|
128
|
+
htmlUrl: z.string(),
|
|
129
|
+
publicRepos: z.number(),
|
|
130
|
+
})
|
|
131
|
+
.optional(),
|
|
132
|
+
orgs: z
|
|
133
|
+
.array(
|
|
134
|
+
z.object({
|
|
135
|
+
login: z.string(),
|
|
136
|
+
description: z.string().nullable(),
|
|
137
|
+
}),
|
|
138
|
+
)
|
|
139
|
+
.optional(),
|
|
140
|
+
repo: z
|
|
141
|
+
.object({
|
|
142
|
+
fullName: z.string(),
|
|
143
|
+
description: z.string().nullable(),
|
|
144
|
+
language: z.string().nullable(),
|
|
145
|
+
stars: z.number(),
|
|
146
|
+
forks: z.number(),
|
|
147
|
+
openIssues: z.number(),
|
|
148
|
+
defaultBranch: z.string(),
|
|
149
|
+
htmlUrl: z.string(),
|
|
150
|
+
})
|
|
151
|
+
.optional(),
|
|
152
|
+
branches: z
|
|
153
|
+
.array(
|
|
154
|
+
z.object({
|
|
155
|
+
name: z.string(),
|
|
156
|
+
protected: z.boolean(),
|
|
157
|
+
}),
|
|
158
|
+
)
|
|
159
|
+
.optional(),
|
|
160
|
+
issues: z
|
|
161
|
+
.array(
|
|
162
|
+
z.object({
|
|
163
|
+
number: z.number(),
|
|
164
|
+
title: z.string(),
|
|
165
|
+
state: z.string(),
|
|
166
|
+
user: z.string(),
|
|
167
|
+
htmlUrl: z.string(),
|
|
168
|
+
}),
|
|
169
|
+
)
|
|
170
|
+
.optional(),
|
|
171
|
+
pullRequests: z
|
|
172
|
+
.array(
|
|
173
|
+
z.object({
|
|
174
|
+
number: z.number(),
|
|
175
|
+
title: z.string(),
|
|
176
|
+
state: z.string(),
|
|
177
|
+
user: z.string(),
|
|
178
|
+
draft: z.boolean(),
|
|
179
|
+
htmlUrl: z.string(),
|
|
180
|
+
}),
|
|
181
|
+
)
|
|
182
|
+
.optional(),
|
|
183
|
+
directoryEntries: z
|
|
184
|
+
.array(
|
|
185
|
+
z.object({
|
|
186
|
+
name: z.string(),
|
|
187
|
+
type: z.string(),
|
|
188
|
+
path: z.string(),
|
|
189
|
+
}),
|
|
190
|
+
)
|
|
191
|
+
.optional(),
|
|
192
|
+
workflowRuns: z
|
|
193
|
+
.array(
|
|
194
|
+
z.object({
|
|
195
|
+
id: z.number(),
|
|
196
|
+
name: z.string(),
|
|
197
|
+
status: z.string(),
|
|
198
|
+
conclusion: z.string().nullable(),
|
|
199
|
+
htmlUrl: z.string(),
|
|
200
|
+
}),
|
|
201
|
+
)
|
|
202
|
+
.optional(),
|
|
203
|
+
searchResults: z
|
|
204
|
+
.array(
|
|
205
|
+
z.object({
|
|
206
|
+
name: z.string(),
|
|
207
|
+
path: z.string(),
|
|
208
|
+
repository: z.string(),
|
|
209
|
+
}),
|
|
210
|
+
)
|
|
211
|
+
.optional(),
|
|
212
|
+
})
|
|
213
|
+
.strict(),
|
|
214
|
+
})
|
|
215
|
+
state: {
|
|
216
|
+
requiresAuthentication?: boolean;
|
|
217
|
+
user?: { login: string; name: string | null; htmlUrl: string; publicRepos: number };
|
|
218
|
+
orgs?: Array<{ login: string; description: string | null }>;
|
|
219
|
+
repo?: {
|
|
220
|
+
fullName: string;
|
|
221
|
+
description: string | null;
|
|
222
|
+
language: string | null;
|
|
223
|
+
stars: number;
|
|
224
|
+
forks: number;
|
|
225
|
+
openIssues: number;
|
|
226
|
+
defaultBranch: string;
|
|
227
|
+
htmlUrl: string;
|
|
228
|
+
};
|
|
229
|
+
branches?: Array<{ name: string; protected: boolean }>;
|
|
230
|
+
issues?: Array<{ number: number; title: string; state: string; user: string; htmlUrl: string }>;
|
|
231
|
+
pullRequests?: Array<{
|
|
232
|
+
number: number;
|
|
233
|
+
title: string;
|
|
234
|
+
state: string;
|
|
235
|
+
user: string;
|
|
236
|
+
draft: boolean;
|
|
237
|
+
htmlUrl: string;
|
|
238
|
+
}>;
|
|
239
|
+
directoryEntries?: Array<{ name: string; type: string; path: string }>;
|
|
240
|
+
workflowRuns?: Array<{
|
|
241
|
+
id: number;
|
|
242
|
+
name: string;
|
|
243
|
+
status: string;
|
|
244
|
+
conclusion: string | null;
|
|
245
|
+
htmlUrl: string;
|
|
246
|
+
}>;
|
|
247
|
+
searchResults?: Array<{ name: string; path: string; repository: string }>;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
@DefineHelper()
|
|
251
|
+
searchQuery() {
|
|
252
|
+
return `repo:${this.args.owner}/${this.args.repo}`;
|
|
253
|
+
}
|
|
254
|
+
}
|