arcade-github 0.1.13__tar.gz
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.
- arcade_github-0.1.13/.gitignore +175 -0
- arcade_github-0.1.13/.pre-commit-config.yaml +18 -0
- arcade_github-0.1.13/.ruff.toml +46 -0
- arcade_github-0.1.13/LICENSE +21 -0
- arcade_github-0.1.13/Makefile +55 -0
- arcade_github-0.1.13/PKG-INFO +20 -0
- arcade_github-0.1.13/arcade_github/__init__.py +0 -0
- arcade_github-0.1.13/arcade_github/tools/__init__.py +0 -0
- arcade_github-0.1.13/arcade_github/tools/activity.py +98 -0
- arcade_github-0.1.13/arcade_github/tools/constants.py +19 -0
- arcade_github-0.1.13/arcade_github/tools/issues.py +158 -0
- arcade_github-0.1.13/arcade_github/tools/models.py +99 -0
- arcade_github-0.1.13/arcade_github/tools/pull_requests.py +625 -0
- arcade_github-0.1.13/arcade_github/tools/repositories.py +373 -0
- arcade_github-0.1.13/arcade_github/tools/utils.py +85 -0
- arcade_github-0.1.13/evals/eval_github_activity.py +115 -0
- arcade_github-0.1.13/evals/eval_github_issues.py +92 -0
- arcade_github-0.1.13/evals/eval_github_pull_requests.py +250 -0
- arcade_github-0.1.13/evals/eval_github_repositories.py +158 -0
- arcade_github-0.1.13/pyproject.toml +58 -0
- arcade_github-0.1.13/tests/__init__.py +0 -0
- arcade_github-0.1.13/tests/test_activity.py +103 -0
- arcade_github-0.1.13/tests/test_issues.py +110 -0
- arcade_github-0.1.13/tests/test_pull_requests.py +359 -0
- arcade_github-0.1.13/tests/test_repositories.py +73 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
credentials.yaml
|
|
3
|
+
docker/credentials.yaml
|
|
4
|
+
|
|
5
|
+
*.lock
|
|
6
|
+
|
|
7
|
+
# example data
|
|
8
|
+
examples/data
|
|
9
|
+
scratch
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
docs/source
|
|
13
|
+
|
|
14
|
+
# From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
|
|
15
|
+
|
|
16
|
+
# Byte-compiled / optimized / DLL files
|
|
17
|
+
__pycache__/
|
|
18
|
+
*.py[cod]
|
|
19
|
+
*$py.class
|
|
20
|
+
|
|
21
|
+
# C extensions
|
|
22
|
+
*.so
|
|
23
|
+
|
|
24
|
+
# Distribution / packaging
|
|
25
|
+
.Python
|
|
26
|
+
build/
|
|
27
|
+
develop-eggs/
|
|
28
|
+
dist/
|
|
29
|
+
downloads/
|
|
30
|
+
eggs/
|
|
31
|
+
.eggs/
|
|
32
|
+
lib/
|
|
33
|
+
lib64/
|
|
34
|
+
parts/
|
|
35
|
+
sdist/
|
|
36
|
+
var/
|
|
37
|
+
wheels/
|
|
38
|
+
share/python-wheels/
|
|
39
|
+
*.egg-info/
|
|
40
|
+
.installed.cfg
|
|
41
|
+
*.egg
|
|
42
|
+
MANIFEST
|
|
43
|
+
|
|
44
|
+
# PyInstaller
|
|
45
|
+
# Usually these files are written by a python script from a template
|
|
46
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
47
|
+
*.manifest
|
|
48
|
+
*.spec
|
|
49
|
+
|
|
50
|
+
# Installer logs
|
|
51
|
+
pip-log.txt
|
|
52
|
+
pip-delete-this-directory.txt
|
|
53
|
+
|
|
54
|
+
# Unit test / coverage reports
|
|
55
|
+
htmlcov/
|
|
56
|
+
.tox/
|
|
57
|
+
.nox/
|
|
58
|
+
.coverage
|
|
59
|
+
.coverage.*
|
|
60
|
+
.cache
|
|
61
|
+
nosetests.xml
|
|
62
|
+
coverage.xml
|
|
63
|
+
*.cover
|
|
64
|
+
*.py,cover
|
|
65
|
+
.hypothesis/
|
|
66
|
+
.pytest_cache/
|
|
67
|
+
cover/
|
|
68
|
+
|
|
69
|
+
# Translations
|
|
70
|
+
*.mo
|
|
71
|
+
*.pot
|
|
72
|
+
|
|
73
|
+
# Django stuff:
|
|
74
|
+
*.log
|
|
75
|
+
local_settings.py
|
|
76
|
+
db.sqlite3
|
|
77
|
+
db.sqlite3-journal
|
|
78
|
+
|
|
79
|
+
# Flask stuff:
|
|
80
|
+
instance/
|
|
81
|
+
.webassets-cache
|
|
82
|
+
|
|
83
|
+
# Scrapy stuff:
|
|
84
|
+
.scrapy
|
|
85
|
+
|
|
86
|
+
# Sphinx documentation
|
|
87
|
+
docs/_build/
|
|
88
|
+
|
|
89
|
+
# PyBuilder
|
|
90
|
+
.pybuilder/
|
|
91
|
+
target/
|
|
92
|
+
|
|
93
|
+
# Jupyter Notebook
|
|
94
|
+
.ipynb_checkpoints
|
|
95
|
+
|
|
96
|
+
# IPython
|
|
97
|
+
profile_default/
|
|
98
|
+
ipython_config.py
|
|
99
|
+
|
|
100
|
+
# pyenv
|
|
101
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
102
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
103
|
+
# .python-version
|
|
104
|
+
|
|
105
|
+
# pipenv
|
|
106
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
107
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
108
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
109
|
+
# install all needed dependencies.
|
|
110
|
+
#Pipfile.lock
|
|
111
|
+
|
|
112
|
+
# poetry
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
114
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
115
|
+
# commonly ignored for libraries.
|
|
116
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
117
|
+
poetry.lock
|
|
118
|
+
|
|
119
|
+
# pdm
|
|
120
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
121
|
+
#pdm.lock
|
|
122
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
123
|
+
# in version control.
|
|
124
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
125
|
+
.pdm.toml
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.venv
|
|
140
|
+
env/
|
|
141
|
+
venv/
|
|
142
|
+
ENV/
|
|
143
|
+
env.bak/
|
|
144
|
+
venv.bak/
|
|
145
|
+
|
|
146
|
+
# Spyder project settings
|
|
147
|
+
.spyderproject
|
|
148
|
+
.spyproject
|
|
149
|
+
|
|
150
|
+
# Rope project settings
|
|
151
|
+
.ropeproject
|
|
152
|
+
|
|
153
|
+
# mkdocs documentation
|
|
154
|
+
/site
|
|
155
|
+
|
|
156
|
+
# mypy
|
|
157
|
+
.mypy_cache/
|
|
158
|
+
.dmypy.json
|
|
159
|
+
dmypy.json
|
|
160
|
+
|
|
161
|
+
# Pyre type checker
|
|
162
|
+
.pyre/
|
|
163
|
+
|
|
164
|
+
# pytype static type analyzer
|
|
165
|
+
.pytype/
|
|
166
|
+
|
|
167
|
+
# Cython debug symbols
|
|
168
|
+
cython_debug/
|
|
169
|
+
|
|
170
|
+
# PyCharm
|
|
171
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
172
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
173
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
174
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
175
|
+
#.idea/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
files: ^.*/github/.*
|
|
2
|
+
repos:
|
|
3
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
4
|
+
rev: "v4.4.0"
|
|
5
|
+
hooks:
|
|
6
|
+
- id: check-case-conflict
|
|
7
|
+
- id: check-merge-conflict
|
|
8
|
+
- id: check-toml
|
|
9
|
+
- id: check-yaml
|
|
10
|
+
- id: end-of-file-fixer
|
|
11
|
+
- id: trailing-whitespace
|
|
12
|
+
|
|
13
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
14
|
+
rev: v0.6.7
|
|
15
|
+
hooks:
|
|
16
|
+
- id: ruff
|
|
17
|
+
args: [--fix]
|
|
18
|
+
- id: ruff-format
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
target-version = "py310"
|
|
2
|
+
line-length = 100
|
|
3
|
+
fix = true
|
|
4
|
+
|
|
5
|
+
[lint]
|
|
6
|
+
select = [
|
|
7
|
+
# flake8-2020
|
|
8
|
+
"YTT",
|
|
9
|
+
# flake8-bandit
|
|
10
|
+
"S",
|
|
11
|
+
# flake8-bugbear
|
|
12
|
+
"B",
|
|
13
|
+
# flake8-builtins
|
|
14
|
+
"A",
|
|
15
|
+
# flake8-comprehensions
|
|
16
|
+
"C4",
|
|
17
|
+
# flake8-debugger
|
|
18
|
+
"T10",
|
|
19
|
+
# flake8-simplify
|
|
20
|
+
"SIM",
|
|
21
|
+
# isort
|
|
22
|
+
"I",
|
|
23
|
+
# mccabe
|
|
24
|
+
"C90",
|
|
25
|
+
# pycodestyle
|
|
26
|
+
"E", "W",
|
|
27
|
+
# pyflakes
|
|
28
|
+
"F",
|
|
29
|
+
# pygrep-hooks
|
|
30
|
+
"PGH",
|
|
31
|
+
# pyupgrade
|
|
32
|
+
"UP",
|
|
33
|
+
# ruff
|
|
34
|
+
"RUF",
|
|
35
|
+
# tryceratops
|
|
36
|
+
"TRY",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[lint.per-file-ignores]
|
|
40
|
+
"*" = ["TRY003", "B904"]
|
|
41
|
+
"**/tests/*" = ["S101", "E501"]
|
|
42
|
+
"**/evals/*" = ["S101", "E501"]
|
|
43
|
+
|
|
44
|
+
[format]
|
|
45
|
+
preview = true
|
|
46
|
+
skip-magic-trailing-comma = false
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Arcade AI
|
|
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.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.PHONY: help
|
|
2
|
+
|
|
3
|
+
help:
|
|
4
|
+
@echo "🛠️ github Commands:\n"
|
|
5
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
|
6
|
+
|
|
7
|
+
.PHONY: install
|
|
8
|
+
install: ## Install the uv environment and install all packages with dependencies
|
|
9
|
+
@echo "🚀 Creating virtual environment and installing all packages using uv"
|
|
10
|
+
@uv sync --active --all-extras --no-sources
|
|
11
|
+
@if [ -f .pre-commit-config.yaml ]; then uv run --no-sources pre-commit install; fi
|
|
12
|
+
@echo "✅ All packages and dependencies installed via uv"
|
|
13
|
+
|
|
14
|
+
.PHONY: install-local
|
|
15
|
+
install-local: ## Install the uv environment and install all packages with dependencies with local Arcade sources
|
|
16
|
+
@echo "🚀 Creating virtual environment and installing all packages using uv"
|
|
17
|
+
@uv sync --active --all-extras
|
|
18
|
+
@if [ -f .pre-commit-config.yaml ]; then uv run pre-commit install; fi
|
|
19
|
+
@echo "✅ All packages and dependencies installed via uv"
|
|
20
|
+
|
|
21
|
+
.PHONY: build
|
|
22
|
+
build: clean-build ## Build wheel file using poetry
|
|
23
|
+
@echo "🚀 Creating wheel file"
|
|
24
|
+
uv build
|
|
25
|
+
|
|
26
|
+
.PHONY: clean-build
|
|
27
|
+
clean-build: ## clean build artifacts
|
|
28
|
+
@echo "🗑️ Cleaning dist directory"
|
|
29
|
+
rm -rf dist
|
|
30
|
+
|
|
31
|
+
.PHONY: test
|
|
32
|
+
test: ## Test the code with pytest
|
|
33
|
+
@echo "🚀 Testing code: Running pytest"
|
|
34
|
+
@uv run --no-sources pytest -W ignore -v --cov --cov-config=pyproject.toml --cov-report=xml
|
|
35
|
+
|
|
36
|
+
.PHONY: coverage
|
|
37
|
+
coverage: ## Generate coverage report
|
|
38
|
+
@echo "coverage report"
|
|
39
|
+
@uv run --no-sources coverage report
|
|
40
|
+
@echo "Generating coverage report"
|
|
41
|
+
@uv run --no-sources coverage html
|
|
42
|
+
|
|
43
|
+
.PHONY: bump-version
|
|
44
|
+
bump-version: ## Bump the version in the pyproject.toml file by a patch version
|
|
45
|
+
@echo "🚀 Bumping version in pyproject.toml"
|
|
46
|
+
uv version --no-sources --bump patch
|
|
47
|
+
|
|
48
|
+
.PHONY: check
|
|
49
|
+
check: ## Run code quality tools.
|
|
50
|
+
@if [ -f .pre-commit-config.yaml ]; then\
|
|
51
|
+
echo "🚀 Linting code: Running pre-commit";\
|
|
52
|
+
uv run --no-sources pre-commit run -a;\
|
|
53
|
+
fi
|
|
54
|
+
@echo "🚀 Static type checking: Running mypy"
|
|
55
|
+
@uv run --no-sources mypy --config-file=pyproject.toml
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: arcade_github
|
|
3
|
+
Version: 0.1.13
|
|
4
|
+
Summary: Arcade.dev LLM tools for Github
|
|
5
|
+
Author-email: Arcade <dev@arcade.dev>
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: arcade-tdk<3.0.0,>=2.0.0
|
|
9
|
+
Requires-Dist: httpx<1.0.0,>=0.27.2
|
|
10
|
+
Provides-Extra: dev
|
|
11
|
+
Requires-Dist: arcade-ai[evals]<3.0.0,>=2.0.0; extra == 'dev'
|
|
12
|
+
Requires-Dist: arcade-serve<3.0.0,>=2.0.0; extra == 'dev'
|
|
13
|
+
Requires-Dist: mypy<1.6.0,>=1.5.1; extra == 'dev'
|
|
14
|
+
Requires-Dist: pre-commit<3.5.0,>=3.4.0; extra == 'dev'
|
|
15
|
+
Requires-Dist: pytest-asyncio<0.25.0,>=0.24.0; extra == 'dev'
|
|
16
|
+
Requires-Dist: pytest-cov<4.1.0,>=4.0.0; extra == 'dev'
|
|
17
|
+
Requires-Dist: pytest-mock<3.12.0,>=3.11.1; extra == 'dev'
|
|
18
|
+
Requires-Dist: pytest<8.4.0,>=8.3.0; extra == 'dev'
|
|
19
|
+
Requires-Dist: ruff<0.8.0,>=0.7.4; extra == 'dev'
|
|
20
|
+
Requires-Dist: tox<4.12.0,>=4.11.1; extra == 'dev'
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
from typing import Annotated
|
|
2
|
+
|
|
3
|
+
import httpx
|
|
4
|
+
from arcade_tdk import ToolContext, tool
|
|
5
|
+
from arcade_tdk.auth import GitHub
|
|
6
|
+
|
|
7
|
+
from arcade_github.tools.utils import get_github_json_headers, get_url, handle_github_response
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Implements https://docs.github.com/en/rest/activity/starring?apiVersion=2022-11-28#star-a-repository-for-the-authenticated-user and https://docs.github.com/en/rest/activity/starring?apiVersion=2022-11-28#unstar-a-repository-for-the-authenticated-user # noqa: E501
|
|
11
|
+
# Example `arcade chat` usage: "star the vscode repo owned by microsoft"
|
|
12
|
+
@tool(requires_auth=GitHub())
|
|
13
|
+
async def set_starred(
|
|
14
|
+
context: ToolContext,
|
|
15
|
+
owner: Annotated[str, "The owner of the repository"],
|
|
16
|
+
name: Annotated[str, "The name of the repository"],
|
|
17
|
+
starred: Annotated[bool, "Whether to star the repository or not"] = True,
|
|
18
|
+
) -> Annotated[
|
|
19
|
+
str, "A message indicating whether the repository was successfully starred or unstarred"
|
|
20
|
+
]:
|
|
21
|
+
"""
|
|
22
|
+
Star or un-star a GitHub repository.
|
|
23
|
+
For example, to star microsoft/vscode, you would use:
|
|
24
|
+
```
|
|
25
|
+
set_starred(owner="microsoft", name="vscode", starred=True)
|
|
26
|
+
```
|
|
27
|
+
"""
|
|
28
|
+
url = get_url("user_starred", owner=owner, repo=name)
|
|
29
|
+
headers = get_github_json_headers(
|
|
30
|
+
context.authorization.token if context.authorization and context.authorization.token else ""
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
async with httpx.AsyncClient() as client:
|
|
34
|
+
if starred:
|
|
35
|
+
response = await client.put(url, headers=headers)
|
|
36
|
+
else:
|
|
37
|
+
response = await client.delete(url, headers=headers)
|
|
38
|
+
|
|
39
|
+
handle_github_response(response, url)
|
|
40
|
+
|
|
41
|
+
action = "starred" if starred else "unstarred"
|
|
42
|
+
return f"Successfully {action} the repository {owner}/{name}"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# Implements https://docs.github.com/en/rest/activity/starring?apiVersion=2022-11-28#list-stargazers
|
|
46
|
+
# Example `arcade chat` usage: "list the stargazers for the ArcadeAI/arcade-ai repo"
|
|
47
|
+
@tool(requires_auth=GitHub())
|
|
48
|
+
async def list_stargazers(
|
|
49
|
+
context: ToolContext,
|
|
50
|
+
owner: Annotated[str, "The owner of the repository"],
|
|
51
|
+
repo: Annotated[str, "The name of the repository"],
|
|
52
|
+
limit: Annotated[
|
|
53
|
+
int | None,
|
|
54
|
+
"The maximum number of stargazers to return. "
|
|
55
|
+
"If not provided, all stargazers will be returned.",
|
|
56
|
+
] = None,
|
|
57
|
+
) -> Annotated[dict, "A dictionary containing the stargazers for the specified repository"]:
|
|
58
|
+
"""List the stargazers for a GitHub repository."""
|
|
59
|
+
url = get_url("repo_stargazers", owner=owner, repo=repo)
|
|
60
|
+
headers = get_github_json_headers(
|
|
61
|
+
context.authorization.token if context.authorization and context.authorization.token else ""
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
if limit is None:
|
|
65
|
+
limit = 2**64 - 1
|
|
66
|
+
|
|
67
|
+
per_page = min(limit, 100)
|
|
68
|
+
page = 1
|
|
69
|
+
stargazers: list[dict] = []
|
|
70
|
+
|
|
71
|
+
async with httpx.AsyncClient() as client:
|
|
72
|
+
while len(stargazers) < limit:
|
|
73
|
+
response = await client.get(
|
|
74
|
+
url, headers=headers, params={"per_page": per_page, "page": page}
|
|
75
|
+
)
|
|
76
|
+
handle_github_response(response, url)
|
|
77
|
+
|
|
78
|
+
data = response.json()
|
|
79
|
+
if not data:
|
|
80
|
+
break
|
|
81
|
+
|
|
82
|
+
stargazers.extend([
|
|
83
|
+
{
|
|
84
|
+
"login": stargazer.get("login"),
|
|
85
|
+
"id": stargazer.get("id"),
|
|
86
|
+
"node_id": stargazer.get("node_id"),
|
|
87
|
+
"html_url": stargazer.get("html_url"),
|
|
88
|
+
}
|
|
89
|
+
for stargazer in data
|
|
90
|
+
])
|
|
91
|
+
|
|
92
|
+
if len(data) < per_page:
|
|
93
|
+
break
|
|
94
|
+
|
|
95
|
+
page += 1
|
|
96
|
+
|
|
97
|
+
stargazers = stargazers[:limit]
|
|
98
|
+
return {"number_of_stargazers": len(stargazers), "stargazers": stargazers}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Base URL for GitHub API
|
|
2
|
+
GITHUB_API_BASE_URL = "https://api.github.com"
|
|
3
|
+
|
|
4
|
+
# Endpoint patterns
|
|
5
|
+
ENDPOINTS = {
|
|
6
|
+
"repo": "/repos/{owner}/{repo}",
|
|
7
|
+
"org_repos": "/orgs/{org}/repos",
|
|
8
|
+
"repo_activity": "/repos/{owner}/{repo}/activity",
|
|
9
|
+
"repo_pulls_comments": "/repos/{owner}/{repo}/pulls/comments",
|
|
10
|
+
"repo_issues": "/repos/{owner}/{repo}/issues",
|
|
11
|
+
"repo_issue_comments": "/repos/{owner}/{repo}/issues/{issue_number}/comments",
|
|
12
|
+
"repo_pulls": "/repos/{owner}/{repo}/pulls",
|
|
13
|
+
"repo_pull": "/repos/{owner}/{repo}/pulls/{pull_number}",
|
|
14
|
+
"repo_pull_commits": "/repos/{owner}/{repo}/pulls/{pull_number}/commits",
|
|
15
|
+
"repo_pull_comments": "/repos/{owner}/{repo}/pulls/{pull_number}/comments",
|
|
16
|
+
"repo_pull_comment_replies": "/repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies", # noqa: E501
|
|
17
|
+
"user_starred": "/user/starred/{owner}/{repo}",
|
|
18
|
+
"repo_stargazers": "/repos/{owner}/{repo}/stargazers",
|
|
19
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from typing import Annotated
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
from arcade_tdk import ToolContext, tool
|
|
6
|
+
from arcade_tdk.auth import GitHub
|
|
7
|
+
|
|
8
|
+
from arcade_github.tools.utils import (
|
|
9
|
+
get_github_json_headers,
|
|
10
|
+
get_url,
|
|
11
|
+
handle_github_response,
|
|
12
|
+
remove_none_values,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Implements https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#create-an-issue
|
|
17
|
+
# Example `arcade chat` usage:
|
|
18
|
+
# "create an issue in the <REPO> repo owned by <OWNER> titled
|
|
19
|
+
# 'Found a bug' with the body 'I'm having a problem with this.'
|
|
20
|
+
# Assign it to <USER> and label it 'bug'"
|
|
21
|
+
@tool(requires_auth=GitHub())
|
|
22
|
+
async def create_issue(
|
|
23
|
+
context: ToolContext,
|
|
24
|
+
owner: Annotated[str, "The account owner of the repository. The name is not case sensitive."],
|
|
25
|
+
repo: Annotated[
|
|
26
|
+
str,
|
|
27
|
+
"The name of the repository without the .git extension. The name is not case sensitive.",
|
|
28
|
+
],
|
|
29
|
+
title: Annotated[str, "The title of the issue."],
|
|
30
|
+
body: Annotated[str | None, "The contents of the issue."] = None,
|
|
31
|
+
assignees: Annotated[list[str] | None, "Logins for Users to assign to this issue."] = None,
|
|
32
|
+
milestone: Annotated[
|
|
33
|
+
int | None, "The number of the milestone to associate this issue with."
|
|
34
|
+
] = None,
|
|
35
|
+
labels: Annotated[list[str] | None, "Labels to associate with this issue."] = None,
|
|
36
|
+
include_extra_data: Annotated[
|
|
37
|
+
bool,
|
|
38
|
+
"If true, return all the data available about the pull requests. "
|
|
39
|
+
"This is a large payload and may impact performance - use with caution.",
|
|
40
|
+
] = False,
|
|
41
|
+
) -> Annotated[
|
|
42
|
+
str,
|
|
43
|
+
"A JSON string containing the created issue's details, including id, url, title, body, state, "
|
|
44
|
+
"html_url, creation and update timestamps, user, assignees, and labels. "
|
|
45
|
+
"If include_extra_data is True, returns all available data about the issue.",
|
|
46
|
+
]:
|
|
47
|
+
"""
|
|
48
|
+
Create an issue in a GitHub repository.
|
|
49
|
+
|
|
50
|
+
Example:
|
|
51
|
+
```
|
|
52
|
+
create_issue(
|
|
53
|
+
owner="octocat",
|
|
54
|
+
repo="Hello-World",
|
|
55
|
+
title="Found a bug",
|
|
56
|
+
body="I'm having a problem with this.",
|
|
57
|
+
assignees=["octocat"],
|
|
58
|
+
milestone=1,
|
|
59
|
+
labels=["bug"],
|
|
60
|
+
)
|
|
61
|
+
```
|
|
62
|
+
"""
|
|
63
|
+
url = get_url("repo_issues", owner=owner, repo=repo)
|
|
64
|
+
data = {
|
|
65
|
+
"title": title,
|
|
66
|
+
"body": body,
|
|
67
|
+
"labels": labels,
|
|
68
|
+
"milestone": milestone,
|
|
69
|
+
"assignees": assignees,
|
|
70
|
+
}
|
|
71
|
+
data = remove_none_values(data)
|
|
72
|
+
headers = get_github_json_headers(
|
|
73
|
+
context.authorization.token if context.authorization and context.authorization.token else ""
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
async with httpx.AsyncClient() as client:
|
|
77
|
+
response = await client.post(url, headers=headers, json=data)
|
|
78
|
+
|
|
79
|
+
handle_github_response(response, url)
|
|
80
|
+
|
|
81
|
+
issue_data = response.json()
|
|
82
|
+
if include_extra_data:
|
|
83
|
+
return json.dumps(issue_data)
|
|
84
|
+
|
|
85
|
+
important_info = {
|
|
86
|
+
"id": issue_data.get("id"),
|
|
87
|
+
"url": issue_data.get("url"),
|
|
88
|
+
"title": issue_data.get("title"),
|
|
89
|
+
"body": issue_data.get("body"),
|
|
90
|
+
"state": issue_data.get("state"),
|
|
91
|
+
"html_url": issue_data.get("html_url"),
|
|
92
|
+
"created_at": issue_data.get("created_at"),
|
|
93
|
+
"updated_at": issue_data.get("updated_at"),
|
|
94
|
+
"user": issue_data.get("user", {}).get("login"),
|
|
95
|
+
"assignees": [assignee.get("login") for assignee in issue_data.get("assignees", [])],
|
|
96
|
+
"labels": [label.get("name") for label in issue_data.get("labels", [])],
|
|
97
|
+
}
|
|
98
|
+
return json.dumps(important_info)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
# Implements https://docs.github.com/en/rest/issues/comments?apiVersion=2022-11-28#create-an-issue-comment
|
|
102
|
+
# Example `arcade chat` usage:
|
|
103
|
+
# "create a comment in the vscode repo owned by microsoft for issue 1347 that says 'Me too'"
|
|
104
|
+
@tool(requires_auth=GitHub())
|
|
105
|
+
async def create_issue_comment(
|
|
106
|
+
context: ToolContext,
|
|
107
|
+
owner: Annotated[str, "The account owner of the repository. The name is not case sensitive."],
|
|
108
|
+
repo: Annotated[
|
|
109
|
+
str,
|
|
110
|
+
"The name of the repository without the .git extension. The name is not case sensitive.",
|
|
111
|
+
],
|
|
112
|
+
issue_number: Annotated[int, "The number that identifies the issue."],
|
|
113
|
+
body: Annotated[str, "The contents of the comment."],
|
|
114
|
+
include_extra_data: Annotated[
|
|
115
|
+
bool,
|
|
116
|
+
"If true, return all the data available about the pull requests. "
|
|
117
|
+
"This is a large payload and may impact performance - use with caution.",
|
|
118
|
+
] = False,
|
|
119
|
+
) -> Annotated[
|
|
120
|
+
str,
|
|
121
|
+
"A JSON string containing the created comment's details, including id, url, body, user, "
|
|
122
|
+
"and creation and update timestamps. If include_extra_data is True, returns all available "
|
|
123
|
+
"data about the comment.",
|
|
124
|
+
]:
|
|
125
|
+
"""
|
|
126
|
+
Create a comment on an issue in a GitHub repository.
|
|
127
|
+
|
|
128
|
+
Example:
|
|
129
|
+
```
|
|
130
|
+
create_issue_comment(owner="octocat", repo="Hello-World", issue_number=1347, body="Me too")
|
|
131
|
+
```
|
|
132
|
+
"""
|
|
133
|
+
url = get_url("repo_issue_comments", owner=owner, repo=repo, issue_number=issue_number)
|
|
134
|
+
data = {
|
|
135
|
+
"body": body,
|
|
136
|
+
}
|
|
137
|
+
headers = get_github_json_headers(
|
|
138
|
+
context.authorization.token if context.authorization and context.authorization.token else ""
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
async with httpx.AsyncClient() as client:
|
|
142
|
+
response = await client.post(url, headers=headers, json=data)
|
|
143
|
+
|
|
144
|
+
handle_github_response(response, url)
|
|
145
|
+
|
|
146
|
+
comment_data = response.json()
|
|
147
|
+
if include_extra_data:
|
|
148
|
+
return json.dumps(comment_data)
|
|
149
|
+
|
|
150
|
+
important_info = {
|
|
151
|
+
"id": comment_data.get("id"),
|
|
152
|
+
"url": comment_data.get("url"),
|
|
153
|
+
"body": comment_data.get("body"),
|
|
154
|
+
"user": comment_data.get("user", {}).get("login"),
|
|
155
|
+
"created_at": comment_data.get("created_at"),
|
|
156
|
+
"updated_at": comment_data.get("updated_at"),
|
|
157
|
+
}
|
|
158
|
+
return json.dumps(important_info)
|