pjdev-gitlab 5.0.0__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.
- pjdev_gitlab-5.0.0/.gitignore +168 -0
- pjdev_gitlab-5.0.0/LICENSE.txt +9 -0
- pjdev_gitlab-5.0.0/PKG-INFO +129 -0
- pjdev_gitlab-5.0.0/README.md +101 -0
- pjdev_gitlab-5.0.0/pyproject.toml +82 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/.agents/skills/pjdev_gitlab_issues/SKILL.md +150 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/.agents/skills/pjdev_gitlab_merge_requests/SKILL.md +101 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/.agents/skills/pjdev_gitlab_packages/SKILL.md +83 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/.agents/skills/pjdev_gitlab_repo_files/SKILL.md +96 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/__about__.py +4 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/__init__.py +17 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/api_utilities.py +201 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/config_service.py +49 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/issues_service.py +430 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/merge_requests_service.py +244 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/models.py +172 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/packages_service.py +134 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/py.typed +0 -0
- pjdev_gitlab-5.0.0/src/pjdev_gitlab/repo_files_service.py +145 -0
- pjdev_gitlab-5.0.0/test.sh +4 -0
- pjdev_gitlab-5.0.0/test_report_pjdev-gitlab.txt +36 -0
- pjdev_gitlab-5.0.0/tests/__init__.py +3 -0
- pjdev_gitlab-5.0.0/tests/conftest.py +16 -0
- pjdev_gitlab-5.0.0/tests/tests_for_api_utilities.py +109 -0
- pjdev_gitlab-5.0.0/tests/tests_for_issues_service.py +148 -0
- pjdev_gitlab-5.0.0/tests/tests_for_merge_requests_service.py +93 -0
- pjdev_gitlab-5.0.0/tests/tests_for_models.py +48 -0
- pjdev_gitlab-5.0.0/tests/tests_for_packages_service.py +64 -0
- pjdev_gitlab-5.0.0/tests/tests_for_repo_files_service.py +66 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
.idea
|
|
3
|
+
|
|
4
|
+
!**/.gitkeep
|
|
5
|
+
|
|
6
|
+
# Byte-compiled / optimized / DLL files
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*$py.class
|
|
10
|
+
|
|
11
|
+
# C extensions
|
|
12
|
+
*.so
|
|
13
|
+
|
|
14
|
+
# Distribution / packaging
|
|
15
|
+
.Python
|
|
16
|
+
build/
|
|
17
|
+
develop-eggs/
|
|
18
|
+
dist/
|
|
19
|
+
downloads/
|
|
20
|
+
eggs/
|
|
21
|
+
.eggs/
|
|
22
|
+
lib/
|
|
23
|
+
lib64/
|
|
24
|
+
parts/
|
|
25
|
+
sdist/
|
|
26
|
+
var/
|
|
27
|
+
wheels/
|
|
28
|
+
share/python-wheels/
|
|
29
|
+
*.egg-info/
|
|
30
|
+
.installed.cfg
|
|
31
|
+
*.egg
|
|
32
|
+
MANIFEST
|
|
33
|
+
|
|
34
|
+
# PyInstaller
|
|
35
|
+
# Usually these files are written by a python script from a template
|
|
36
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
37
|
+
*.manifest
|
|
38
|
+
*.spec
|
|
39
|
+
|
|
40
|
+
# Installer logs
|
|
41
|
+
pip-log.txt
|
|
42
|
+
pip-delete-this-directory.txt
|
|
43
|
+
|
|
44
|
+
# Unit test / coverage reports
|
|
45
|
+
htmlcov/
|
|
46
|
+
.tox/
|
|
47
|
+
.nox/
|
|
48
|
+
.coverage
|
|
49
|
+
.coverage.*
|
|
50
|
+
.cache
|
|
51
|
+
nosetests.xml
|
|
52
|
+
coverage.xml
|
|
53
|
+
*.cover
|
|
54
|
+
*.py,cover
|
|
55
|
+
.hypothesis/
|
|
56
|
+
.pytest_cache/
|
|
57
|
+
cover/
|
|
58
|
+
|
|
59
|
+
# Translations
|
|
60
|
+
*.mo
|
|
61
|
+
*.pot
|
|
62
|
+
|
|
63
|
+
# Django stuff:
|
|
64
|
+
*.log
|
|
65
|
+
local_settings.py
|
|
66
|
+
db.sqlite3
|
|
67
|
+
db.sqlite3-journal
|
|
68
|
+
|
|
69
|
+
# Flask stuff:
|
|
70
|
+
instance/
|
|
71
|
+
.webassets-cache
|
|
72
|
+
|
|
73
|
+
# Scrapy stuff:
|
|
74
|
+
.scrapy
|
|
75
|
+
|
|
76
|
+
# Sphinx documentation
|
|
77
|
+
docs/_build/
|
|
78
|
+
|
|
79
|
+
# PyBuilder
|
|
80
|
+
.pybuilder/
|
|
81
|
+
target/
|
|
82
|
+
|
|
83
|
+
# Jupyter Notebook
|
|
84
|
+
.ipynb_checkpoints
|
|
85
|
+
|
|
86
|
+
# IPython
|
|
87
|
+
profile_default/
|
|
88
|
+
ipython_config.py
|
|
89
|
+
|
|
90
|
+
# pyenv
|
|
91
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
92
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
93
|
+
# .python-version
|
|
94
|
+
|
|
95
|
+
# pipenv
|
|
96
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
97
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
98
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
99
|
+
# install all needed dependencies.
|
|
100
|
+
#Pipfile.lock
|
|
101
|
+
|
|
102
|
+
# poetry
|
|
103
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
104
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
105
|
+
# commonly ignored for libraries.
|
|
106
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
107
|
+
#poetry.lock
|
|
108
|
+
|
|
109
|
+
# pdm
|
|
110
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
111
|
+
#pdm.lock
|
|
112
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
113
|
+
# in version control.
|
|
114
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
115
|
+
.pdm.toml
|
|
116
|
+
|
|
117
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
118
|
+
__pypackages__/
|
|
119
|
+
|
|
120
|
+
# Celery stuff
|
|
121
|
+
celerybeat-schedule
|
|
122
|
+
celerybeat.pid
|
|
123
|
+
|
|
124
|
+
# SageMath parsed files
|
|
125
|
+
*.sage.py
|
|
126
|
+
|
|
127
|
+
# Environments
|
|
128
|
+
.env
|
|
129
|
+
.venv
|
|
130
|
+
env/
|
|
131
|
+
venv/
|
|
132
|
+
ENV/
|
|
133
|
+
env.bak/
|
|
134
|
+
venv.bak/
|
|
135
|
+
|
|
136
|
+
# Spyder project settings
|
|
137
|
+
.spyderproject
|
|
138
|
+
.spyproject
|
|
139
|
+
|
|
140
|
+
# Rope project settings
|
|
141
|
+
.ropeproject
|
|
142
|
+
|
|
143
|
+
# mkdocs documentation
|
|
144
|
+
/site
|
|
145
|
+
|
|
146
|
+
# mypy
|
|
147
|
+
.mypy_cache/
|
|
148
|
+
.dmypy.json
|
|
149
|
+
dmypy.json
|
|
150
|
+
|
|
151
|
+
# Pyre type checker
|
|
152
|
+
.pyre/
|
|
153
|
+
|
|
154
|
+
# pytype static type analyzer
|
|
155
|
+
.pytype/
|
|
156
|
+
|
|
157
|
+
# Cython debug symbols
|
|
158
|
+
cython_debug/
|
|
159
|
+
|
|
160
|
+
# PyCharm
|
|
161
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
162
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
163
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
164
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
165
|
+
#.idea/
|
|
166
|
+
|
|
167
|
+
**/uv.lock
|
|
168
|
+
!./uv.lock
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-present Chris O'Neill <chris@purplejay.io>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pjdev-gitlab
|
|
3
|
+
Version: 5.0.0
|
|
4
|
+
Project-URL: Documentation, https://gitlab.purplejay.io/keystone/python/-/tree/main/pjdev-gitlab/README.md
|
|
5
|
+
Project-URL: Issues, https://gitlab.purplejay.io/keystone/python/-/issues
|
|
6
|
+
Project-URL: Source, https://gitlab.purplejay.io/keystone/python
|
|
7
|
+
Author-email: Purple Jay LLC <developers@purplejay.io>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE.txt
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
14
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Requires-Dist: httpx
|
|
17
|
+
Requires-Dist: loguru
|
|
18
|
+
Requires-Dist: pydantic-settings>=2.13.1
|
|
19
|
+
Requires-Dist: pydantic>=2.12.5
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
Requires-Dist: coverage; extra == 'test'
|
|
24
|
+
Requires-Dist: pytest; extra == 'test'
|
|
25
|
+
Requires-Dist: pytest-asyncio; extra == 'test'
|
|
26
|
+
Requires-Dist: respx; extra == 'test'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# pjdev-gitlab
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/pjdev-gitlab)
|
|
32
|
+
[](https://pypi.org/project/pjdev-gitlab)
|
|
33
|
+
|
|
34
|
+
Async GitLab automation SDK. Wraps the GitLab REST API v4 directly with `httpx.AsyncClient` and Pydantic models. Covers issues, merge requests, repository files, and the generic package registry.
|
|
35
|
+
|
|
36
|
+
-----
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```console
|
|
41
|
+
pip install pjdev-gitlab
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Configuration
|
|
45
|
+
|
|
46
|
+
`pjdev-gitlab` reads `GL_*` environment variables (or accepts the same values
|
|
47
|
+
via `init()`):
|
|
48
|
+
|
|
49
|
+
| variable | required | purpose |
|
|
50
|
+
| --- | --- | --- |
|
|
51
|
+
| `GL_TOKEN` | yes | personal/group/project access token (`api` scope) |
|
|
52
|
+
| `GL_GITLAB_URL` | yes | base URL, e.g. `https://gitlab.com` |
|
|
53
|
+
| `GL_DEFAULT_PROJECT_ID` | no | default project for service helpers |
|
|
54
|
+
| `GL_OUTPUT_PATH` | no | directory for downloaded files |
|
|
55
|
+
|
|
56
|
+
### Recommended: 1Password + `op run`
|
|
57
|
+
|
|
58
|
+
On a developer laptop, keep the token in 1Password and inject it into the host
|
|
59
|
+
process with [`op run`](https://developer.1password.com/docs/cli/secrets-environment-variables/) —
|
|
60
|
+
the secret never sits in your shell environment or on disk in plaintext.
|
|
61
|
+
|
|
62
|
+
1. Install the 1Password CLI (`brew install --cask 1password-cli`) and turn on
|
|
63
|
+
**Settings → Developer → Integrate with 1Password CLI** in the desktop app.
|
|
64
|
+
2. Store the token in 1Password (e.g. an API Credential titled
|
|
65
|
+
`GitLab — purplejay` with a `credential` field).
|
|
66
|
+
3. Drop a committable `.env.op` next to your project — references only, no
|
|
67
|
+
real secrets:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# .env.op
|
|
71
|
+
GL_TOKEN="op://Private/GitLab — purplejay/credential"
|
|
72
|
+
GL_GITLAB_URL="https://gitlab.purplejay.io"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
4. Launch your script — or the entire Claude Code session that will use this
|
|
76
|
+
library — under `op run`:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
op run --env-file=.env.op -- python my_script.py
|
|
80
|
+
op run --env-file=.env.op -- claude
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`op run` resolves the references, exports them to the subprocess, and tears
|
|
84
|
+
them down on exit. Inside Python, just call `config_service.init()` with no
|
|
85
|
+
arguments and the values flow in from the environment.
|
|
86
|
+
|
|
87
|
+
In CI, skip 1Password and set `GL_TOKEN`/`GL_GITLAB_URL` from the job's
|
|
88
|
+
existing variables (e.g. `CI_JOB_TOKEN` for project-scoped operations).
|
|
89
|
+
|
|
90
|
+
## Usage
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
import asyncio
|
|
94
|
+
from pjdev_gitlab import config_service, issues_service
|
|
95
|
+
from pjdev_gitlab.models import StateEvent
|
|
96
|
+
|
|
97
|
+
async def main() -> None:
|
|
98
|
+
# Token & URL come from GL_TOKEN / GL_GITLAB_URL (e.g. via `op run`).
|
|
99
|
+
config_service.init(default_project_id="my-group/my-project")
|
|
100
|
+
|
|
101
|
+
issue = await issues_service.create_issue(
|
|
102
|
+
project_id="my-group/my-project",
|
|
103
|
+
title="Bug: timeout on /widgets",
|
|
104
|
+
description="The endpoint times out under load.\n\n/label ~bug ~priority::high",
|
|
105
|
+
labels=["bug"],
|
|
106
|
+
)
|
|
107
|
+
await issues_service.comment_on_issue(
|
|
108
|
+
project_id="my-group/my-project",
|
|
109
|
+
issue_iid=issue.iid,
|
|
110
|
+
body="Investigating now.",
|
|
111
|
+
)
|
|
112
|
+
await issues_service.set_issue_state(
|
|
113
|
+
project_id="my-group/my-project",
|
|
114
|
+
issue_iid=issue.iid,
|
|
115
|
+
state_event=StateEvent.close,
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
asyncio.run(main())
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Run it: `op run --env-file=.env.op -- python my_script.py`.
|
|
122
|
+
|
|
123
|
+
## Bundled agent skills
|
|
124
|
+
|
|
125
|
+
Skill files for AI agents ship under `.agents/skills/` inside the installed package, following the [library-skills.io](https://library-skills.io/create/) convention. Topics: issues, merge requests, repository files, generic packages.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
`pjdev-gitlab` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# pjdev-gitlab
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/pjdev-gitlab)
|
|
4
|
+
[](https://pypi.org/project/pjdev-gitlab)
|
|
5
|
+
|
|
6
|
+
Async GitLab automation SDK. Wraps the GitLab REST API v4 directly with `httpx.AsyncClient` and Pydantic models. Covers issues, merge requests, repository files, and the generic package registry.
|
|
7
|
+
|
|
8
|
+
-----
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```console
|
|
13
|
+
pip install pjdev-gitlab
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Configuration
|
|
17
|
+
|
|
18
|
+
`pjdev-gitlab` reads `GL_*` environment variables (or accepts the same values
|
|
19
|
+
via `init()`):
|
|
20
|
+
|
|
21
|
+
| variable | required | purpose |
|
|
22
|
+
| --- | --- | --- |
|
|
23
|
+
| `GL_TOKEN` | yes | personal/group/project access token (`api` scope) |
|
|
24
|
+
| `GL_GITLAB_URL` | yes | base URL, e.g. `https://gitlab.com` |
|
|
25
|
+
| `GL_DEFAULT_PROJECT_ID` | no | default project for service helpers |
|
|
26
|
+
| `GL_OUTPUT_PATH` | no | directory for downloaded files |
|
|
27
|
+
|
|
28
|
+
### Recommended: 1Password + `op run`
|
|
29
|
+
|
|
30
|
+
On a developer laptop, keep the token in 1Password and inject it into the host
|
|
31
|
+
process with [`op run`](https://developer.1password.com/docs/cli/secrets-environment-variables/) —
|
|
32
|
+
the secret never sits in your shell environment or on disk in plaintext.
|
|
33
|
+
|
|
34
|
+
1. Install the 1Password CLI (`brew install --cask 1password-cli`) and turn on
|
|
35
|
+
**Settings → Developer → Integrate with 1Password CLI** in the desktop app.
|
|
36
|
+
2. Store the token in 1Password (e.g. an API Credential titled
|
|
37
|
+
`GitLab — purplejay` with a `credential` field).
|
|
38
|
+
3. Drop a committable `.env.op` next to your project — references only, no
|
|
39
|
+
real secrets:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# .env.op
|
|
43
|
+
GL_TOKEN="op://Private/GitLab — purplejay/credential"
|
|
44
|
+
GL_GITLAB_URL="https://gitlab.purplejay.io"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
4. Launch your script — or the entire Claude Code session that will use this
|
|
48
|
+
library — under `op run`:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
op run --env-file=.env.op -- python my_script.py
|
|
52
|
+
op run --env-file=.env.op -- claude
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`op run` resolves the references, exports them to the subprocess, and tears
|
|
56
|
+
them down on exit. Inside Python, just call `config_service.init()` with no
|
|
57
|
+
arguments and the values flow in from the environment.
|
|
58
|
+
|
|
59
|
+
In CI, skip 1Password and set `GL_TOKEN`/`GL_GITLAB_URL` from the job's
|
|
60
|
+
existing variables (e.g. `CI_JOB_TOKEN` for project-scoped operations).
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import asyncio
|
|
66
|
+
from pjdev_gitlab import config_service, issues_service
|
|
67
|
+
from pjdev_gitlab.models import StateEvent
|
|
68
|
+
|
|
69
|
+
async def main() -> None:
|
|
70
|
+
# Token & URL come from GL_TOKEN / GL_GITLAB_URL (e.g. via `op run`).
|
|
71
|
+
config_service.init(default_project_id="my-group/my-project")
|
|
72
|
+
|
|
73
|
+
issue = await issues_service.create_issue(
|
|
74
|
+
project_id="my-group/my-project",
|
|
75
|
+
title="Bug: timeout on /widgets",
|
|
76
|
+
description="The endpoint times out under load.\n\n/label ~bug ~priority::high",
|
|
77
|
+
labels=["bug"],
|
|
78
|
+
)
|
|
79
|
+
await issues_service.comment_on_issue(
|
|
80
|
+
project_id="my-group/my-project",
|
|
81
|
+
issue_iid=issue.iid,
|
|
82
|
+
body="Investigating now.",
|
|
83
|
+
)
|
|
84
|
+
await issues_service.set_issue_state(
|
|
85
|
+
project_id="my-group/my-project",
|
|
86
|
+
issue_iid=issue.iid,
|
|
87
|
+
state_event=StateEvent.close,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
asyncio.run(main())
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Run it: `op run --env-file=.env.op -- python my_script.py`.
|
|
94
|
+
|
|
95
|
+
## Bundled agent skills
|
|
96
|
+
|
|
97
|
+
Skill files for AI agents ship under `.agents/skills/` inside the installed package, following the [library-skills.io](https://library-skills.io/create/) convention. Topics: issues, merge requests, repository files, generic packages.
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
`pjdev-gitlab` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pjdev-gitlab"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = ''
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
keywords = []
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Purple Jay LLC", email = "developers@purplejay.io" },
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
21
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"httpx",
|
|
25
|
+
"loguru",
|
|
26
|
+
"pydantic-settings>=2.13.1",
|
|
27
|
+
"pydantic>=2.12.5",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.optional-dependencies]
|
|
31
|
+
dev = [
|
|
32
|
+
"ruff",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
test = [
|
|
36
|
+
"pytest",
|
|
37
|
+
"pytest-asyncio",
|
|
38
|
+
"respx",
|
|
39
|
+
"coverage",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[project.urls]
|
|
43
|
+
Documentation = "https://gitlab.purplejay.io/keystone/python/-/tree/main/pjdev-gitlab/README.md"
|
|
44
|
+
Issues = "https://gitlab.purplejay.io/keystone/python/-/issues"
|
|
45
|
+
Source = "https://gitlab.purplejay.io/keystone/python"
|
|
46
|
+
|
|
47
|
+
[tool.hatch.version]
|
|
48
|
+
path = "src/pjdev_gitlab/__about__.py"
|
|
49
|
+
|
|
50
|
+
[tool.hatch.build.targets.wheel]
|
|
51
|
+
packages = ["src/pjdev_gitlab"]
|
|
52
|
+
artifacts = ["src/pjdev_gitlab/.agents/**/*.md", "src/pjdev_gitlab/py.typed"]
|
|
53
|
+
|
|
54
|
+
[tool.hatch.envs.types]
|
|
55
|
+
extra-dependencies = [
|
|
56
|
+
"mypy>=1.0.0",
|
|
57
|
+
]
|
|
58
|
+
[tool.hatch.envs.types.scripts]
|
|
59
|
+
check = "mypy --install-types --non-interactive {args:src/pjdev_gitlab tests}"
|
|
60
|
+
|
|
61
|
+
[tool.coverage.run]
|
|
62
|
+
source_pkgs = ["pjdev_gitlab", "tests"]
|
|
63
|
+
branch = true
|
|
64
|
+
parallel = true
|
|
65
|
+
omit = [
|
|
66
|
+
"src/pjdev_gitlab/__about__.py",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
[tool.coverage.paths]
|
|
70
|
+
pjdev_gitlab = ["src/pjdev_gitlab", "*/pjdev-gitlab/src/pjdev_gitlab"]
|
|
71
|
+
tests = ["tests", "*/pjdev-gitlab/tests"]
|
|
72
|
+
|
|
73
|
+
[tool.coverage.report]
|
|
74
|
+
exclude_lines = [
|
|
75
|
+
"no cov",
|
|
76
|
+
"if __name__ == .__main__.:",
|
|
77
|
+
"if TYPE_CHECKING:",
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
[tool.pytest.ini_options]
|
|
81
|
+
asyncio_mode = "auto"
|
|
82
|
+
python_files = ["tests_for_*.py", "test_*.py"]
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pjdev_gitlab_issues
|
|
3
|
+
description: Use this skill to automate GitLab issues via pjdev-gitlab — search/analytics, create issues with markdown and inline images, post comments and threaded discussions, and change state, labels, iteration, or milestone. Trigger when the user asks to query, create, or modify GitLab issues programmatically.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# pjdev_gitlab_issues
|
|
7
|
+
|
|
8
|
+
Async helpers for GitLab issue automation, built on `httpx.AsyncClient` against the [GitLab REST API v4](https://docs.gitlab.com/api/issues/).
|
|
9
|
+
|
|
10
|
+
Reference docs (source of truth for behavior):
|
|
11
|
+
- [Issues](https://docs.gitlab.com/user/project/issues/)
|
|
12
|
+
- [Comments and threads](https://docs.gitlab.com/user/discussions/)
|
|
13
|
+
- [Labels](https://docs.gitlab.com/user/project/labels/)
|
|
14
|
+
- [Iterations](https://docs.gitlab.com/user/group/iterations/)
|
|
15
|
+
- [Milestones](https://docs.gitlab.com/user/project/milestones/)
|
|
16
|
+
- [Quick actions](https://docs.gitlab.com/user/project/quick_actions/)
|
|
17
|
+
- [GitLab Flavored Markdown](https://docs.gitlab.com/user/markdown/)
|
|
18
|
+
|
|
19
|
+
## Setup
|
|
20
|
+
|
|
21
|
+
`pjdev_gitlab` reads `GL_TOKEN` and `GL_GITLAB_URL` from the environment. The
|
|
22
|
+
recommended pattern is to keep the token in 1Password and inject it into the
|
|
23
|
+
host process with [`op run`](https://developer.1password.com/docs/cli/secrets-environment-variables/),
|
|
24
|
+
so the secret never sits in your shell environment or on disk in plaintext.
|
|
25
|
+
|
|
26
|
+
1. Store the token in 1Password (e.g. an API Credential titled `GitLab — <host>`
|
|
27
|
+
with a `credential` field).
|
|
28
|
+
2. In the project that uses this skill, create a committable `.env.op` with
|
|
29
|
+
1Password references — no real secrets:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# .env.op
|
|
33
|
+
GL_TOKEN="op://Private/GitLab — <host>/credential"
|
|
34
|
+
GL_GITLAB_URL="https://gitlab.example.com"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
3. Launch the host process (the script, or the entire Claude Code session)
|
|
38
|
+
under `op run`:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
op run --env-file=.env.op -- python my_script.py
|
|
42
|
+
op run --env-file=.env.op -- claude
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Then call `config_service.init()` with no arguments — it picks up `GL_*` from env:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from pjdev_gitlab import config_service, issues_service
|
|
49
|
+
|
|
50
|
+
config_service.init(default_project_id="my-group/my-project") # token/url from env
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For tests or one-off scripts you can still pass values explicitly:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
config_service.init(token="glpat-xxx", gitlab_url="https://gitlab.com")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The token needs `api` scope. Project-scoped tokens work for project-only
|
|
60
|
+
operations; iterations live at group level, so use a group/personal token for
|
|
61
|
+
`list_iterations`.
|
|
62
|
+
|
|
63
|
+
## Search & analytics
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from pjdev_gitlab import issues_service
|
|
67
|
+
from pjdev_gitlab.models import IssueState
|
|
68
|
+
|
|
69
|
+
open_bugs = await issues_service.search_issues(
|
|
70
|
+
"my-group/my-project",
|
|
71
|
+
state=IssueState.opened,
|
|
72
|
+
labels=["bug"],
|
|
73
|
+
created_after="2026-01-01T00:00:00Z",
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
by_label = await issues_service.aggregate_issues(
|
|
77
|
+
"my-group/my-project", group_by="label", state=IssueState.opened
|
|
78
|
+
)
|
|
79
|
+
# {"bug": 12, "frontend": 7, ...}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`search_issues` paginates by default. Set `paginate_results=False` for a single page.
|
|
83
|
+
|
|
84
|
+
## Create with markdown and inline images
|
|
85
|
+
|
|
86
|
+
`<img src="...">` tags in the description are replaced positionally with the markdown
|
|
87
|
+
returned by GitLab's upload endpoint. Quick actions in the description (e.g. `/label`,
|
|
88
|
+
`/assign`) are processed by GitLab server-side.
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from pathlib import Path
|
|
92
|
+
|
|
93
|
+
issue = await issues_service.create_issue(
|
|
94
|
+
"my-group/my-project",
|
|
95
|
+
title="Bug: timeout on /widgets",
|
|
96
|
+
description=(
|
|
97
|
+
"Repro:\n"
|
|
98
|
+
"1. Open page\n"
|
|
99
|
+
'2. <img src="placeholder1">\n\n'
|
|
100
|
+
"/label ~bug ~priority::high\n"
|
|
101
|
+
"/assign @me"
|
|
102
|
+
),
|
|
103
|
+
image_paths=[Path("./screenshot.png")],
|
|
104
|
+
labels=["bug"],
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Comment vs. threaded discussion
|
|
109
|
+
|
|
110
|
+
Single comment:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
await issues_service.comment_on_issue(
|
|
114
|
+
"my-group/my-project", issue_iid=42, body="Investigating now."
|
|
115
|
+
)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Threaded discussion (use this when subsequent replies should belong to the same thread):
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
discussion = await issues_service.start_issue_discussion(
|
|
122
|
+
"my-group/my-project", issue_iid=42, body="Root-cause analysis"
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Change state, labels, iteration, milestone
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from pjdev_gitlab.models import StateEvent
|
|
130
|
+
|
|
131
|
+
await issues_service.set_issue_state("my-group/my-project", 42, StateEvent.close)
|
|
132
|
+
await issues_service.set_issue_labels(
|
|
133
|
+
"my-group/my-project", 42, ["regression"], mode="add"
|
|
134
|
+
)
|
|
135
|
+
await issues_service.set_issue_iteration("my-group/my-project", 42, iteration_id=17)
|
|
136
|
+
await issues_service.set_issue_milestone("my-group/my-project", 42, milestone_id=5)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Iterations and milestones can be discovered with `list_iterations(group_id)` and
|
|
140
|
+
`list_milestones(project_id)`.
|
|
141
|
+
|
|
142
|
+
## Tips for AI agents
|
|
143
|
+
|
|
144
|
+
- Prefer quick actions (`/label`, `/assign`, `/iteration *iteration:42`, `/close`)
|
|
145
|
+
inside the description or comment body instead of multiple API calls — this is
|
|
146
|
+
one round-trip and matches how humans use GitLab.
|
|
147
|
+
- IIDs (`issue.iid`) are project-scoped and what users see; IDs (`issue.id`) are
|
|
148
|
+
GitLab-global. Always use IIDs for issue endpoints.
|
|
149
|
+
- Project IDs may be numeric (`12345`) or namespaced paths (`group/sub/project`).
|
|
150
|
+
Both work; the helpers URL-encode them automatically.
|