@loopstack/github-oauth-example 0.1.1 → 0.2.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.
Files changed (30) hide show
  1. package/README.md +116 -20
  2. package/dist/tools/authenticate-github-task.tool.d.ts +9 -8
  3. package/dist/tools/authenticate-github-task.tool.d.ts.map +1 -1
  4. package/dist/tools/authenticate-github-task.tool.js +30 -62
  5. package/dist/tools/authenticate-github-task.tool.js.map +1 -1
  6. package/dist/workflows/github-agent.ui.yaml +16 -0
  7. package/dist/workflows/github-agent.workflow.d.ts +14 -13
  8. package/dist/workflows/github-agent.workflow.d.ts.map +1 -1
  9. package/dist/workflows/github-agent.workflow.js +155 -71
  10. package/dist/workflows/github-agent.workflow.js.map +1 -1
  11. package/dist/workflows/github-repos-overview.ui.yaml +17 -0
  12. package/dist/workflows/github-repos-overview.workflow.d.ts +77 -87
  13. package/dist/workflows/github-repos-overview.workflow.d.ts.map +1 -1
  14. package/dist/workflows/github-repos-overview.workflow.js +177 -228
  15. package/dist/workflows/github-repos-overview.workflow.js.map +1 -1
  16. package/dist/workflows/templates/repoOverview.md +81 -0
  17. package/dist/workflows/templates/systemMessage.md +23 -0
  18. package/package.json +7 -7
  19. package/src/tools/authenticate-github-task.tool.ts +34 -82
  20. package/src/workflows/__tests__/github-repos-overview-workflow.spec.ts +105 -249
  21. package/src/workflows/github-agent.ui.yaml +16 -0
  22. package/src/workflows/github-agent.workflow.ts +109 -27
  23. package/src/workflows/github-repos-overview.ui.yaml +17 -0
  24. package/src/workflows/github-repos-overview.workflow.ts +257 -215
  25. package/src/workflows/templates/repoOverview.md +81 -0
  26. package/src/workflows/templates/systemMessage.md +23 -0
  27. package/dist/workflows/github-agent.workflow.yaml +0 -154
  28. package/dist/workflows/github-repos-overview.workflow.yaml +0 -249
  29. package/src/workflows/github-agent.workflow.yaml +0 -154
  30. package/src/workflows/github-repos-overview.workflow.yaml +0 -249
@@ -1,154 +0,0 @@
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 }}
@@ -1,249 +0,0 @@
1
- title: 'GitHub Repository Overview'
2
-
3
- description: |
4
- Comprehensive GitHub example that exercises every GitHub tool.
5
- Fetches user info, repository details, issues, pull requests, branches,
6
- directory contents, workflow runs, and search results for a given repository.
7
- If not authenticated, launches the OAuth sub-workflow and retries.
8
-
9
- ui:
10
- form:
11
- properties:
12
- owner:
13
- title: 'Repository Owner'
14
- placeholder: 'octocat'
15
- repo:
16
- title: 'Repository Name'
17
- placeholder: 'Hello-World'
18
-
19
- transitions:
20
- # Step 1: Fetch authenticated user and orgs
21
- - id: fetch_user
22
- from: start
23
- to: user_fetched
24
- call:
25
- - tool: gitHubGetAuthenticatedUser
26
- id: user_fetch
27
- args: {}
28
- assign:
29
- requiresAuthentication: ${{ result.data.error == "unauthorized" }}
30
- user: ${{ result.data.user }}
31
-
32
- # If unauthorized -> launch OAuth
33
- - id: auth_required
34
- from: user_fetched
35
- to: awaiting_auth
36
- if: ${{ state.requiresAuthentication }}
37
- call:
38
- - tool: task
39
- id: launchAuth
40
- args:
41
- workflow: oAuth
42
- args:
43
- provider: 'github'
44
- scopes:
45
- - 'repo'
46
- - 'read:org'
47
- - 'workflow'
48
- callback:
49
- transition: auth_completed
50
-
51
- - tool: createDocument
52
- args:
53
- id: authStatus
54
- document: linkDocument
55
- update:
56
- content:
57
- icon: 'LockKeyhole'
58
- label: 'GitHub authentication required'
59
- caption: 'Complete sign-in to continue'
60
- href: '/pipelines/{{ runtime.tools.auth_required.launchAuth.data.pipelineId }}'
61
- embed: true
62
- expanded: true
63
-
64
- # Auth completed -> retry from start
65
- - id: auth_completed
66
- from: awaiting_auth
67
- to: start
68
- trigger: manual
69
- call:
70
- - tool: createDocument
71
- args:
72
- id: authStatus
73
- document: linkDocument
74
- update:
75
- content:
76
- icon: 'ShieldCheck'
77
- type: 'success'
78
- label: 'GitHub authentication completed'
79
- caption: 'You are now authenticated with GitHub.'
80
- href: '/pipelines/{{ runtime.transition.payload.pipelineId }}'
81
-
82
- # Step 2: Fetch user orgs
83
- - id: fetch_orgs
84
- from: user_fetched
85
- to: orgs_fetched
86
- call:
87
- - tool: gitHubListUserOrgs
88
- id: orgs_fetch
89
- args:
90
- perPage: 10
91
- assign:
92
- orgs: ${{ result.data.orgs }}
93
-
94
- # Step 3: Fetch repo details and branches
95
- - id: fetch_repo_details
96
- from: orgs_fetched
97
- to: repo_fetched
98
- call:
99
- - tool: gitHubGetRepo
100
- id: repo_fetch
101
- args:
102
- owner: ${{ args.owner }}
103
- repo: ${{ args.repo }}
104
- assign:
105
- repo: ${{ result.data.repo }}
106
-
107
- - tool: gitHubListBranches
108
- id: branches_fetch
109
- args:
110
- owner: ${{ args.owner }}
111
- repo: ${{ args.repo }}
112
- assign:
113
- branches: ${{ result.data.branches }}
114
-
115
- # Step 4: Fetch issues and PRs
116
- - id: fetch_issues_prs
117
- from: repo_fetched
118
- to: issues_prs_fetched
119
- call:
120
- - tool: gitHubListIssues
121
- id: issues_fetch
122
- args:
123
- owner: ${{ args.owner }}
124
- repo: ${{ args.repo }}
125
- state: 'open'
126
- perPage: 10
127
- assign:
128
- issues: ${{ result.data.issues }}
129
-
130
- - tool: gitHubListPullRequests
131
- id: prs_fetch
132
- args:
133
- owner: ${{ args.owner }}
134
- repo: ${{ args.repo }}
135
- state: 'open'
136
- perPage: 10
137
- assign:
138
- pullRequests: ${{ result.data.pullRequests }}
139
-
140
- # Step 5: Fetch directory listing and workflow runs
141
- - id: fetch_content_actions
142
- from: issues_prs_fetched
143
- to: content_actions_fetched
144
- call:
145
- - tool: gitHubListDirectory
146
- id: dir_fetch
147
- args:
148
- owner: ${{ args.owner }}
149
- repo: ${{ args.repo }}
150
- assign:
151
- directoryEntries: ${{ result.data.entries }}
152
-
153
- - tool: gitHubListWorkflowRuns
154
- id: runs_fetch
155
- args:
156
- owner: ${{ args.owner }}
157
- repo: ${{ args.repo }}
158
- perPage: 5
159
- assign:
160
- workflowRuns: ${{ result.data.runs }}
161
-
162
- # Step 6: Search code in the repo
163
- - id: fetch_search
164
- from: content_actions_fetched
165
- to: search_done
166
- call:
167
- - tool: gitHubSearchCode
168
- id: code_search
169
- args:
170
- query: ${{ searchQuery() }}
171
- perPage: 5
172
- assign:
173
- searchResults: ${{ result.data.results }}
174
-
175
- # Display all results
176
- - id: display_results
177
- from: search_done
178
- to: end
179
- call:
180
- - tool: createDocument
181
- args:
182
- document: markdown
183
- update:
184
- content:
185
- markdown: |
186
- ## Authenticated User
187
- **{{ state.user.login }}** {{#if state.user.name}}({{ state.user.name }}){{/if}} — {{ state.user.publicRepos }} public repos
188
-
189
- {{#if state.orgs}}
190
- ### Organizations
191
- {{#each state.orgs}}
192
- - **{{ this.login }}** {{#if this.description}}— {{ this.description }}{{/if}}
193
- {{/each}}
194
- {{/if}}
195
-
196
- ---
197
-
198
- ## Repository: [{{ state.repo.fullName }}]({{ state.repo.htmlUrl }})
199
- {{ state.repo.description }}
200
-
201
- | Language | Stars | Forks | Open Issues | Default Branch |
202
- |---|---|---|---|---|
203
- | {{ state.repo.language }} | {{ state.repo.stars }} | {{ state.repo.forks }} | {{ state.repo.openIssues }} | {{ state.repo.defaultBranch }} |
204
-
205
- ### Branches
206
- {{#each state.branches}}
207
- - `{{ this.name }}` {{#if this.protected}}(protected){{/if}}
208
- {{/each}}
209
-
210
- ---
211
-
212
- ### Open Issues
213
- {{#each state.issues}}
214
- - [#{{ this.number }}]({{ this.htmlUrl }}) {{ this.title }} — @{{ this.user }}
215
- {{/each}}
216
- {{#unless state.issues}}
217
- No open issues.
218
- {{/unless}}
219
-
220
- ### Open Pull Requests
221
- {{#each state.pullRequests}}
222
- - [#{{ this.number }}]({{ this.htmlUrl }}) {{ this.title }} — @{{ this.user }} {{#if this.draft}}(draft){{/if}}
223
- {{/each}}
224
- {{#unless state.pullRequests}}
225
- No open pull requests.
226
- {{/unless}}
227
-
228
- ---
229
-
230
- ### Root Directory
231
- {{#each state.directoryEntries}}
232
- - {{ this.type }} `{{ this.name }}`
233
- {{/each}}
234
-
235
- ### Recent Workflow Runs
236
- {{#each state.workflowRuns}}
237
- - [{{ this.name }}]({{ this.htmlUrl }}) — {{ this.status }} {{#if this.conclusion}}({{ this.conclusion }}){{/if}}
238
- {{/each}}
239
- {{#unless state.workflowRuns}}
240
- No workflow runs found.
241
- {{/unless}}
242
-
243
- ### Code Search Results
244
- {{#each state.searchResults}}
245
- - `{{ this.path }}` in {{ this.repository }}
246
- {{/each}}
247
- {{#unless state.searchResults}}
248
- No code search results.
249
- {{/unless}}
@@ -1,154 +0,0 @@
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 }}