gitcode-api 1.2.3__py3-none-any.whl → 1.2.5__py3-none-any.whl
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.
- gitcode_api/_cli_banner.py +1 -1
- gitcode_api/cli.py +67 -9
- gitcode_api/llm/__init__.py +49 -0
- gitcode_api/llm/_tool.py +368 -0
- gitcode_api/llm/mcp.py +93 -0
- gitcode_api/llm/openai.py +56 -0
- gitcode_api/py.typed +1 -0
- gitcode_api/version.txt +1 -1
- gitcode_api-1.2.5.dist-info/METADATA +371 -0
- {gitcode_api-1.2.3.dist-info → gitcode_api-1.2.5.dist-info}/RECORD +14 -9
- gitcode_api-1.2.3.dist-info/METADATA +0 -237
- {gitcode_api-1.2.3.dist-info → gitcode_api-1.2.5.dist-info}/WHEEL +0 -0
- {gitcode_api-1.2.3.dist-info → gitcode_api-1.2.5.dist-info}/entry_points.txt +0 -0
- {gitcode_api-1.2.3.dist-info → gitcode_api-1.2.5.dist-info}/licenses/LICENSE +0 -0
- {gitcode_api-1.2.3.dist-info → gitcode_api-1.2.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""OpenAI tool adapter for the GitCode SDK."""
|
|
2
|
+
|
|
3
|
+
from functools import cached_property
|
|
4
|
+
from typing import Any, Dict, Optional
|
|
5
|
+
|
|
6
|
+
from ._tool import TOOL_DESCRIPTION, TOOL_NAME, TOOL_PARAMETERS, GitCodeLLMTool
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class GitCodeOpenAITool(GitCodeLLMTool):
|
|
10
|
+
"""OpenAI-compatible callable tool for invoking GitCode SDK resources.
|
|
11
|
+
|
|
12
|
+
:param async_mode: When true, calling the instance returns the async tool coroutine.
|
|
13
|
+
:param kwargs: Forwarded to :class:`gitcode_api.llm.GitCodeLLMTool`. ``{"async": True}``
|
|
14
|
+
is also accepted for frameworks that construct tools from dictionaries.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
name = TOOL_NAME
|
|
18
|
+
description = TOOL_DESCRIPTION
|
|
19
|
+
parameters = TOOL_PARAMETERS
|
|
20
|
+
|
|
21
|
+
def __init__(self, async_mode: Optional[bool] = None, **kwargs) -> None:
|
|
22
|
+
"""Create an OpenAI tool wrapper."""
|
|
23
|
+
async_kw = kwargs.pop("async", None)
|
|
24
|
+
if async_mode is None:
|
|
25
|
+
async_mode = bool(async_kw)
|
|
26
|
+
elif async_kw is not None:
|
|
27
|
+
raise TypeError("Pass only one of async_mode or async")
|
|
28
|
+
self.async_mode = bool(async_mode)
|
|
29
|
+
super().__init__(**kwargs)
|
|
30
|
+
if self.async_mode:
|
|
31
|
+
self.__call__ = self.__async_call__ # type: ignore[method-assign]
|
|
32
|
+
|
|
33
|
+
@cached_property
|
|
34
|
+
def tool(self) -> Dict[str, Any]:
|
|
35
|
+
"""Return this tool in OpenAI Chat Completions tool format."""
|
|
36
|
+
return {
|
|
37
|
+
"type": "function",
|
|
38
|
+
"function": {
|
|
39
|
+
"name": self.name,
|
|
40
|
+
"description": self.description,
|
|
41
|
+
"parameters": self.parameters,
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
46
|
+
"""Return this tool in OpenAI Chat Completions tool format."""
|
|
47
|
+
return self.tool
|
|
48
|
+
|
|
49
|
+
def __call__(self, *args: Any, **kwargs) -> Any:
|
|
50
|
+
"""Invoke the configured sync or async tool callable."""
|
|
51
|
+
if self.async_mode:
|
|
52
|
+
return self.__async_call__(*args, **kwargs)
|
|
53
|
+
return super().__call__(*args, **kwargs)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
__all__ = ["GitCodeOpenAITool"]
|
gitcode_api/py.typed
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
partial
|
gitcode_api/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.2.
|
|
1
|
+
1.2.5
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gitcode-api
|
|
3
|
+
Version: 1.2.5
|
|
4
|
+
Summary: Easy to use Python SDK for the GitCode REST API. Providing builtin CLI tool, and optional LLM integration (MCP and OpenAI tool) for agents. Community-maintained.
|
|
5
|
+
Author-email: Hugo Huang <hugo@hugohuang.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: changelog, https://gitcode-api.readthedocs.io/en/latest/changelog.html
|
|
8
|
+
Project-URL: documentation, https://gitcode-api.readthedocs.io
|
|
9
|
+
Project-URL: gitcode, https://gitcode.com/SushiNinja/GitCode-API
|
|
10
|
+
Project-URL: github, https://github.com/Trenza1ore/GitCode-API
|
|
11
|
+
Keywords: gitcode,git,devops,api,sdk,python,httpx,client,mcp,agent,fastmcp,llm,mcp client,mcp server,model context protocol
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Intended Audience :: Developers
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: <4,>=3.9
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: httpx
|
|
31
|
+
Provides-Extra: mcp
|
|
32
|
+
Requires-Dist: fastmcp; python_version >= "3.10" and extra == "mcp"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# GitCode-API
|
|
36
|
+
|
|
37
|
+
[](https://pypi.org/project/gitcode-api) [](https://pepy.tech/projects/gitcode-api) [](https://www.codefactor.io/repository/github/trenza1ore/gitcode-api)
|
|
38
|
+
[](https://github.com/Trenza1ore/GitCode-API) [](https://gitcode.com/SushiNinja/GitCode-API)
|
|
39
|
+
|
|
40
|
+
[](https://gitcode-api.readthedocs.io) [](README.zh.md)
|
|
41
|
+
|
|
42
|
+
`gitcode-api` is a community-maintained Python SDK for the GitCode REST API. It provides easy-to-use synchronous and asynchronous clients, repository-scoped helpers, and lightweight response models so you can work with GitCode from Python without hand-writing raw HTTP requests. The `gitcode_api.llm` module adds an OpenAI-style function tool and MCP service so agents can reuse the same resource-oriented API.
|
|
43
|
+
|
|
44
|
+
## Why This Project
|
|
45
|
+
|
|
46
|
+
- Community project for developers who want a practical GitCode Python library.
|
|
47
|
+
- Sync and async clients with a consistent API surface.
|
|
48
|
+
- Resource groups such as `client.repos`, `client.pulls`, and `client.users`.
|
|
49
|
+
- Repository defaults via `owner=` and `repo=` on the client.
|
|
50
|
+
- Sphinx docs plus a mirrored GitCode REST API reference in `docs/`.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
Install from PyPI:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install -U gitcode-api
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Authentication
|
|
61
|
+
|
|
62
|
+
Pass `api_key=` directly, or set `GITCODE_ACCESS_TOKEN` in your environment:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
export GITCODE_ACCESS_TOKEN="your-token"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
If your token is stored in encrypted form, pass `decrypt=` to decode either an
|
|
69
|
+
encrypted `api_key=` value or an encrypted `GITCODE_ACCESS_TOKEN` value before
|
|
70
|
+
the client uses it.
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from gitcode_api import GitCode
|
|
74
|
+
from trusted_library import decrypt_token
|
|
75
|
+
|
|
76
|
+
client = GitCode(
|
|
77
|
+
api_key="encrypted-token",
|
|
78
|
+
decrypt=decrypt_token,
|
|
79
|
+
)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## CLI
|
|
83
|
+
|
|
84
|
+
After installation, you can invoke the SDK directly from the command line:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
gitcode-api repos get --api-key "$GITCODE_ACCESS_TOKEN" --owner SushiNinja --repo GitCode-API
|
|
88
|
+
python -m gitcode_api pulls list --api-key "$GITCODE_ACCESS_TOKEN" --owner SushiNinja --repo GitCode-API --state open
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
With `gitcode-api[mcp]` installed (Python 3.10+), you can start the bundled FastMCP server over stdio:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
gitcode-api serve --api-key "$GITCODE_ACCESS_TOKEN"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Use `gitcode-api serve -h` for defaults such as `--owner`, `--repo`, and `--transport`.
|
|
98
|
+
|
|
99
|
+
Commands mirror the synchronous resource methods on `GitCode`, using the pattern
|
|
100
|
+
`gitcode-api <resource> <method> ...`. For methods that accept extra `**params`
|
|
101
|
+
or `**payload`, pass repeated `--set key=value` flags or `--set-json '{"key": "value"}'`.
|
|
102
|
+
|
|
103
|
+
## Quick Start
|
|
104
|
+
|
|
105
|
+
### Sync client
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from gitcode_api import GitCode
|
|
109
|
+
|
|
110
|
+
client = GitCode(
|
|
111
|
+
owner="SushiNinja",
|
|
112
|
+
repo="GitCode-API",
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
repo = client.repos.get()
|
|
116
|
+
branches = client.branches.list(per_page=5)
|
|
117
|
+
|
|
118
|
+
print(repo.full_name)
|
|
119
|
+
for branch in branches:
|
|
120
|
+
print(branch.name)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Async client
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
import asyncio
|
|
127
|
+
from gitcode_api import AsyncGitCode
|
|
128
|
+
|
|
129
|
+
async def main() -> None:
|
|
130
|
+
client = AsyncGitCode(owner="SushiNinja", repo="GitCode-API")
|
|
131
|
+
pulls = await client.pulls.list(state="open", per_page=20)
|
|
132
|
+
print(len(pulls))
|
|
133
|
+
|
|
134
|
+
asyncio.run(main())
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Context managers
|
|
138
|
+
|
|
139
|
+
`GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client=` you passed in. `close()` also clears the LRU cache used by each resource group's `method_signature(...)` helper (see the [Available Resources](#available-resources) section).
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from gitcode_api import GitCode
|
|
143
|
+
|
|
144
|
+
with GitCode(owner="SushiNinja", repo="GitCode-API") as client:
|
|
145
|
+
repo = client.repos.get()
|
|
146
|
+
print(repo.full_name)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
import asyncio
|
|
151
|
+
from gitcode_api import AsyncGitCode
|
|
152
|
+
|
|
153
|
+
async def main() -> None:
|
|
154
|
+
async with AsyncGitCode(owner="SushiNinja", repo="GitCode-API") as client:
|
|
155
|
+
pulls = await client.pulls.list(state="open", per_page=20)
|
|
156
|
+
print(len(pulls))
|
|
157
|
+
|
|
158
|
+
asyncio.run(main())
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Common Workflows
|
|
162
|
+
|
|
163
|
+
Create a pull request:
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
from gitcode_api import GitCode
|
|
167
|
+
|
|
168
|
+
client = GitCode(owner="SushiNinja", repo="GitCode-API")
|
|
169
|
+
|
|
170
|
+
pull = client.pulls.create(
|
|
171
|
+
title="Add feature",
|
|
172
|
+
head="feature-branch",
|
|
173
|
+
base="main",
|
|
174
|
+
body="Implements the new flow.",
|
|
175
|
+
)
|
|
176
|
+
print(pull.number)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Get the authenticated user:
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from gitcode_api import GitCode
|
|
183
|
+
|
|
184
|
+
client = GitCode()
|
|
185
|
+
|
|
186
|
+
user = client.users.me()
|
|
187
|
+
print(user.login)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Search repositories:
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
from gitcode_api import GitCode
|
|
194
|
+
|
|
195
|
+
client = GitCode()
|
|
196
|
+
|
|
197
|
+
repos = client.search.repositories(q="sdk language:python", per_page=10)
|
|
198
|
+
for repo in repos:
|
|
199
|
+
print(repo.full_name)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Available Resources
|
|
203
|
+
|
|
204
|
+
Both `GitCode` and `AsyncGitCode` expose:
|
|
205
|
+
|
|
206
|
+
- `repos` and `contents`
|
|
207
|
+
- `branches` and `commits`
|
|
208
|
+
- `issues` and `pulls`
|
|
209
|
+
- `labels`, `milestones`, and `members`
|
|
210
|
+
- `releases`, `tags`, and `webhooks`
|
|
211
|
+
- `users`, `orgs`, `search`, and `oauth`
|
|
212
|
+
|
|
213
|
+
Every resource group inherits a cached `methods` property from the shared resource base: a `tuple` of public callable names in stable SDK order (underscore-segment sort key, not plain A–Z on the full identifier). Private names and the introspection helpers `methods` and `method_signature` are omitted. For example, `client.pulls.methods` helps with discovery or tooling without reading the full manual list. For one method’s parameters and return type, call `client.pulls.method_signature("list_issues")` (a cached string from `inspect.signature`, with `gitcode_api._models.` stripped from annotations).
|
|
214
|
+
|
|
215
|
+
## LLM tools and MCP
|
|
216
|
+
|
|
217
|
+
The `gitcode_api.llm` module exposes a single logical tool, **`gitcode_api_tool`**, that routes calls to sync or async SDK resources. Model-facing parameters match the JSON schema used by OpenAI-style function tools:
|
|
218
|
+
|
|
219
|
+
| Parameter | Role |
|
|
220
|
+
| --- | --- |
|
|
221
|
+
| `op_type` | Required. Resource group on the client (same names as `GitCode` attributes: `repos`, `pulls`, `issues`, and so on). |
|
|
222
|
+
| `action` | Method on that resource (for example `get`, `list`). Empty with `help` returns method discovery text. |
|
|
223
|
+
| `params` | Keyword arguments for the method as a JSON object; omitted or `null` is treated as `{}`. |
|
|
224
|
+
| `help` | When `true`, returns formatted help (available methods or a target signature) instead of performing a normal API call where applicable. |
|
|
225
|
+
|
|
226
|
+
Successful results are JSON-friendly (`APIObject.to_dict()`, base64-wrapped `bytes`, and similar). Failures are returned as objects with `"error": true` and a `"message"` string (HTTP and configuration errors include extra fields when available).
|
|
227
|
+
|
|
228
|
+
### OpenAI tool (`GitCodeOpenAITool`)
|
|
229
|
+
|
|
230
|
+
No extra dependencies beyond the core package. Build a Chat Completions–style tool definition with `.tool` or `.to_dict()`, then invoke the same instance with the arguments above (sync) or configure async mode for `await`.
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
from gitcode_api.llm import GitCodeOpenAITool
|
|
234
|
+
|
|
235
|
+
tool = GitCodeOpenAITool(owner="SushiNinja", repo="GitCode-API")
|
|
236
|
+
tools_payload = [tool.tool] # or tool.to_dict() for a single entry
|
|
237
|
+
|
|
238
|
+
# Sync invocation (default)
|
|
239
|
+
result = tool("repos", "get", params={})
|
|
240
|
+
|
|
241
|
+
# Async client / awaitable wrapper
|
|
242
|
+
async_tool = GitCodeOpenAITool(owner="SushiNinja", repo="GitCode-API", async_mode=True)
|
|
243
|
+
# await async_tool("pulls", "list", params={"state": "open", "per_page": 5})
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
You can pass the emitted tool definition into `chat.completions.create(...)`
|
|
247
|
+
and handle tool calls directly:
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
import json
|
|
251
|
+
from openai import OpenAI
|
|
252
|
+
from gitcode_api.llm import GitCodeOpenAITool
|
|
253
|
+
|
|
254
|
+
tools = {
|
|
255
|
+
"gitcode_api_tool": GitCodeOpenAITool(owner="SushiNinja", repo="GitCode-API"),
|
|
256
|
+
}
|
|
257
|
+
client = OpenAI(
|
|
258
|
+
api_key="your-openai-compatible-api-key",
|
|
259
|
+
base_url="https://your-openai-compatible-base-url/v1",
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
response = client.chat.completions.create(
|
|
263
|
+
model="gpt-4.1-mini",
|
|
264
|
+
messages=[{"role": "user", "content": "List the last 5 commits."}],
|
|
265
|
+
tools=[tools["gitcode_api_tool"].tool],
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
for tool_call in response.choices[0].message.tool_calls:
|
|
269
|
+
selected_tool = tools[tool_call.function.name]
|
|
270
|
+
print(f"Calling tool {tool_call.function.name}({tool_call.function.arguments}):")
|
|
271
|
+
print("---result---")
|
|
272
|
+
print(selected_tool(**json.loads(tool_call.function.arguments)))
|
|
273
|
+
print("---result---")
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Constructor options mirror `GitCode` / `AsyncGitCode`: `client=`, `async_client=`, `api_key=`, `owner=`, `repo=`, `base_url=`, `timeout=`, and `decrypt=`. For dict-driven setups that reserve the name `async`, you may pass `**{"async": True}` instead of `async_mode=True` (but not both).
|
|
277
|
+
|
|
278
|
+
### MCP server and MCP tool (FastMCP)
|
|
279
|
+
|
|
280
|
+
[MCP](https://modelcontextprotocol.io) integration uses [FastMCP](https://github.com/jlowin/fastmcp). Install the optional extra (requires **Python 3.10+** because of the `fastmcp` dependency):
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
pip install 'gitcode-api[mcp]'
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
- **`create_mcp_server`** — builds a `FastMCP` instance with `gitcode_api_tool` already registered; optional `name=`, `tool=`, and extra keyword arguments are forwarded to `FastMCP(...)`.
|
|
287
|
+
- **`GitCodeMCP`** — thin wrapper that constructs that server and registers the tool; unknown attributes are delegated to the underlying `FastMCP` object (for example transport helpers exposed by your FastMCP version).
|
|
288
|
+
- **`create_mcp_gitcode_api_tool`** — returns the standalone async callable used as the tool body (for custom wiring).
|
|
289
|
+
- **`register_mcp_gitcode_api_tool`** — attaches that callable to an existing FastMCP-compatible object (`mcp.tool(...)` or `mcp.add_tool(...)`).
|
|
290
|
+
|
|
291
|
+
```python
|
|
292
|
+
from gitcode_api.llm import create_mcp_server
|
|
293
|
+
|
|
294
|
+
mcp = create_mcp_server(name="GitCode API", owner="SushiNinja", repo="GitCode-API")
|
|
295
|
+
# Run or export the server using FastMCP’s API for your version (stdio, HTTP, etc.).
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
The same server is available from the CLI as `gitcode-api serve` (see the [CLI](#cli) section).
|
|
299
|
+
|
|
300
|
+
To share auth or clients across tools, build `GitCodeLLMTool` once (`from gitcode_api.llm._tool import GitCodeLLMTool`) and pass it as `tool=` into `GitCodeMCP`, `create_mcp_server`, `register_mcp_gitcode_api_tool`, or `create_mcp_gitcode_api_tool`.
|
|
301
|
+
|
|
302
|
+
## Examples
|
|
303
|
+
|
|
304
|
+
Runnable examples live in `examples/`:
|
|
305
|
+
|
|
306
|
+
- `get_current_user.py`
|
|
307
|
+
- `get_repository_overview.py`
|
|
308
|
+
- `list_pull_requests.py`
|
|
309
|
+
- `async_list_branches.py`
|
|
310
|
+
|
|
311
|
+
Example scripts load shared configuration from `examples/.env` using `python-dotenv`.
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
uv run python examples/get_current_user.py
|
|
315
|
+
uv run python examples/get_repository_overview.py
|
|
316
|
+
uv run python examples/list_pull_requests.py
|
|
317
|
+
uv run python examples/async_list_branches.py
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
See `examples/.env.example` for the expected variables.
|
|
321
|
+
|
|
322
|
+
## Documentation
|
|
323
|
+
|
|
324
|
+
- Project docs entry: `docs/index.rst`
|
|
325
|
+
- SDK docs: `docs/sdk/index.rst`
|
|
326
|
+
- REST API mirror: `docs/rest_api/index.rst`
|
|
327
|
+
|
|
328
|
+
Build the docs locally from the repository root. The `docs` Makefile target removes stale `docs/_build` and `docs/sdk/generated` output, then runs Sphinx (via `uv`) with the `html`, `epub`, and `singlehtml` builders. Outputs land under `docs/_build/html/`, `docs/_build/epub/` (including `GitCodeAPI.epub`), and `docs/_build/singlehtml/`:
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
make docs
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Other common targets from the repository root (after `uv sync --all-groups` so optional dependency groups are available):
|
|
335
|
+
|
|
336
|
+
- `make docs-clean` — remove `docs/_build` and `docs/sdk/generated` without rebuilding.
|
|
337
|
+
- `make format` — Ruff lint fixes, import sorting, and formatting.
|
|
338
|
+
- `make test` — install the package into the active environment and run pytest.
|
|
339
|
+
- `make docstring` — pydocstyle checks for `gitcode_api/`.
|
|
340
|
+
- `make binary` — PyInstaller one-file CLI under `dist/` (requires the `binary` group).
|
|
341
|
+
|
|
342
|
+
## FAQ
|
|
343
|
+
|
|
344
|
+
### SSL or corporate network errors ("self-signed certificate")
|
|
345
|
+
|
|
346
|
+
If GitCode HTTPS fails behind a corporate proxy or private PKI, point `httpx` at a CA bundle with `verify` (similar in spirit to `REQUESTS_CA_BUNDLE` for `requests`):
|
|
347
|
+
|
|
348
|
+
```python
|
|
349
|
+
from gitcode_api import GitCode
|
|
350
|
+
from httpx import Client
|
|
351
|
+
|
|
352
|
+
with GitCode(
|
|
353
|
+
owner="SushiNinja",
|
|
354
|
+
repo="GitCode-API",
|
|
355
|
+
http_client=Client(verify="path/to/my/certificate.crt"),
|
|
356
|
+
) as client:
|
|
357
|
+
repo = client.repos.get()
|
|
358
|
+
pulls = client.pulls.list(state="open", per_page=5)
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Use `httpx.AsyncClient(verify=...)` with `AsyncGitCode` for async code.
|
|
362
|
+
|
|
363
|
+
The OpenAI tool (`GitCodeOpenAITool`) and MCP helpers accept the same `client=` / `async_client=` arguments (or a shared `GitCodeLLMTool` via `tool=` with those clients set). Build `GitCode` / `AsyncGitCode` with your custom `http_client` once and pass it through so LLM tool calls reuse the same TLS settings.
|
|
364
|
+
|
|
365
|
+
## Project Status
|
|
366
|
+
|
|
367
|
+
This is a community project and is still evolving. API coverage is already broad, but some endpoints and behaviors may continue to be refined as the SDK grows.
|
|
368
|
+
|
|
369
|
+
## Contributing
|
|
370
|
+
|
|
371
|
+
Issues, bug reports, API coverage improvements, docs fixes, and pull requests are welcome. If you are using GitCode heavily and notice missing endpoints or awkward ergonomics, contributions are especially appreciated.
|
|
@@ -2,21 +2,26 @@ gitcode_api/__init__.py,sha256=NvLp28D9brVbmv2ROSZ8mxKDuIamE9xeutBKGl9pra8,497
|
|
|
2
2
|
gitcode_api/__main__.py,sha256=Yd8P4MSNcWFqUTKnUaNibbWX4Vd-MVVNmhPFaohzqcA,137
|
|
3
3
|
gitcode_api/_base_client.py,sha256=PFsTMZJI4p5INjubRa4H4JcybYLGt-B9VkSAfTgpxfI,13280
|
|
4
4
|
gitcode_api/_base_resource.py,sha256=mlKe1b_1AKcqxhptaCpP-AOjKkLNzCbYG-Pkp1HYWrA,2238
|
|
5
|
-
gitcode_api/_cli_banner.py,sha256=
|
|
5
|
+
gitcode_api/_cli_banner.py,sha256=3DsoJ2qZ-mWWB4yD-cnxDN_osXzrUKabrA5tbV6752M,978
|
|
6
6
|
gitcode_api/_client.py,sha256=bmZxBHdfshM5Kv_EurHUVu8rsEj0k3Up3ATSIPaFrvc,8258
|
|
7
7
|
gitcode_api/_exceptions.py,sha256=T5N8gBGmPSktDkLP5P_hxbzOHw3W378TzxN1xja40pA,1140
|
|
8
8
|
gitcode_api/_models.py,sha256=v-GZzCGAb3_frY6wFiQww9m271U5MigivpEHDHnoDcI,109030
|
|
9
|
-
gitcode_api/cli.py,sha256=
|
|
10
|
-
gitcode_api/
|
|
9
|
+
gitcode_api/cli.py,sha256=DpnyGP54CkMGWwc8Krakt9i8RtAAsV45sN2UfgwMdIA,16631
|
|
10
|
+
gitcode_api/py.typed,sha256=mDShSrm8qg9qjacQc2F-rI8ATllqP6EdgHuEYxuCXZ0,7
|
|
11
|
+
gitcode_api/version.txt,sha256=_it8I3tabkKBiqPk9_xYIPScMiicMsliYO-JqMj209c,6
|
|
12
|
+
gitcode_api/llm/__init__.py,sha256=YLILw5R8ViiaxGUXnlBAFAZQwo7YKAmNO1MOPEuesVI,1294
|
|
13
|
+
gitcode_api/llm/_tool.py,sha256=4C9RbQh2tNJ1Y5V3eom1aOcC0sE4VMhbihHOZE-_c1k,13555
|
|
14
|
+
gitcode_api/llm/mcp.py,sha256=c5qnRcjladcHd-r1ZwtK23-QQaOg5utmK7w0AxMvQHo,3546
|
|
15
|
+
gitcode_api/llm/openai.py,sha256=CcS3tFntzAuN2HMbbQDctb54AnasU3n3a1Jr9LWAHwM,1998
|
|
11
16
|
gitcode_api/resources/__init__.py,sha256=nsCKW0bFDZ5ombJZxLThmO82sOuF7o4OKUMRkAmwbwk,1725
|
|
12
17
|
gitcode_api/resources/_shared.py,sha256=7bCym8bIfs818SiYYrBGI7-ZtiYlxECSDG3RduInu10,5387
|
|
13
18
|
gitcode_api/resources/account.py,sha256=mnc2p7wI-nBnHFNdWPNiHfmZpT6d3RDQC777gewtm4M,38801
|
|
14
19
|
gitcode_api/resources/collaboration.py,sha256=8lyk78GTjVXddiE9fieutsMGovRjteGfTJcAhwLoR0M,101607
|
|
15
20
|
gitcode_api/resources/misc.py,sha256=guDwh4cxbTVsSa7EivaYM3bKMJ8_Op4KucGbKEoayKE,22412
|
|
16
21
|
gitcode_api/resources/repositories.py,sha256=EAK2znZhEsgVUu-NDEQslSEEYJzvb-kHuh4mW57y6sc,78178
|
|
17
|
-
gitcode_api-1.2.
|
|
18
|
-
gitcode_api-1.2.
|
|
19
|
-
gitcode_api-1.2.
|
|
20
|
-
gitcode_api-1.2.
|
|
21
|
-
gitcode_api-1.2.
|
|
22
|
-
gitcode_api-1.2.
|
|
22
|
+
gitcode_api-1.2.5.dist-info/licenses/LICENSE,sha256=gOACXuWhMu6PJKVLr9RQbxX3HULnZIGNXCaMFJIXhoA,1067
|
|
23
|
+
gitcode_api-1.2.5.dist-info/METADATA,sha256=r-j3RgFK_SS8y43bBZi0BXAE0t5UFvhbek5dfnSsT2I,15497
|
|
24
|
+
gitcode_api-1.2.5.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
25
|
+
gitcode_api-1.2.5.dist-info/entry_points.txt,sha256=dIPylJcgohIE2RRIlt3In2WzcwDK8TOdkL_ReKuij4o,53
|
|
26
|
+
gitcode_api-1.2.5.dist-info/top_level.txt,sha256=gIlg0ptyOUHJT64ajOjWIhRPYgIQnMIvnhhnesw9fxU,12
|
|
27
|
+
gitcode_api-1.2.5.dist-info/RECORD,,
|