Source code for tools.gitea_integration

"""Gitea shortcuts for smk/stargazer-v3 on git.neko.li (delegates to shared credentials)."""

from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from tool_context import ToolContext

DEFAULT_OWNER = "smk"
DEFAULT_REPO = "stargazer-v3"


[docs] async def gitea_open_issue( title: str, body: str, ctx: ToolContext | None = None ) -> str: """Open a new issue on the canonical ``smk/stargazer-v3`` Gitea repo. Convenience shortcut that hardcodes the owner/repo (``DEFAULT_OWNER`` / ``DEFAULT_REPO``) so callers need only supply the issue ``title`` and ``body``. It lazily imports and delegates to ``tools.gitea_tools.gitea_create_issue``, which performs the authenticated HTTP ``POST`` against the Gitea API on ``git.neko.li`` using the shared repo credentials; all network access and error handling live in that shared helper. The ``ctx`` is forwarded so the underlying tool can resolve credentials and platform state. This coroutine is registered as the ``gitea_open_issue`` handler in this module's ``TOOLS`` list (and appears in ``classifiers/tool_prefix_groups.py`` for routing), so it is invoked via the tool-dispatch layer rather than by direct internal calls; no direct by-name callers were found. Args: title: The issue title. body: The issue body in Markdown. ctx: Tool execution context forwarded to the shared Gitea helper for credential/platform resolution. Returns: The string result produced by ``gitea_create_issue`` (typically a success/summary message or serialized issue details). """ from tools.gitea_tools import gitea_create_issue as _create return await _create(DEFAULT_OWNER, DEFAULT_REPO, title, body=body, ctx=ctx)
[docs] async def gitea_comment_issue( issue_id: int, body: str, ctx: ToolContext | None = None ) -> str: """Post a comment on an existing issue in ``smk/stargazer-v3``. Convenience shortcut that pins the owner/repo (``DEFAULT_OWNER`` / ``DEFAULT_REPO``) and lazily delegates to ``tools.gitea_tools.gitea_create_issue_comment``, which issues the authenticated HTTP ``POST`` to the Gitea API on ``git.neko.li`` using the shared repo credentials. All network I/O and error handling are owned by that shared helper; ``ctx`` is forwarded for credential/platform resolution. Registered as the ``gitea_comment_issue`` handler in this module's ``TOOLS`` list (and listed in ``classifiers/tool_prefix_groups.py`` for routing), so it is reached through the tool-dispatch layer; no direct by-name internal callers were found. Args: issue_id: The numeric id (issue number) of the target issue. body: The comment text in Markdown. ctx: Tool execution context forwarded to the shared Gitea helper. Returns: The string result produced by ``gitea_create_issue_comment`` (typically a success/summary message or serialized comment details). """ from tools.gitea_tools import gitea_create_issue_comment as _comment return await _comment(DEFAULT_OWNER, DEFAULT_REPO, issue_id, body, ctx=ctx)
[docs] async def gitea_close_issue(issue_id: int, ctx: ToolContext | None = None) -> str: """Close an existing issue in ``smk/stargazer-v3``. Convenience shortcut that pins the owner/repo (``DEFAULT_OWNER`` / ``DEFAULT_REPO``) and lazily delegates to ``tools.gitea_tools.gitea_update_issue`` with ``state="closed"``. That shared helper performs the authenticated HTTP ``PATCH`` against the Gitea API on ``git.neko.li`` using the shared repo credentials and owns all network I/O and error handling; ``ctx`` is forwarded for credential/platform resolution. Registered as the ``gitea_close_issue`` handler in this module's ``TOOLS`` list (and listed in ``classifiers/tool_prefix_groups.py`` for routing), so it is invoked through the tool-dispatch layer; no direct by-name internal callers were found. Args: issue_id: The numeric id (issue number) of the issue to close. ctx: Tool execution context forwarded to the shared Gitea helper. Returns: The string result produced by ``gitea_update_issue`` (typically a success/summary message or serialized issue details). """ from tools.gitea_tools import gitea_update_issue as _update return await _update(DEFAULT_OWNER, DEFAULT_REPO, issue_id, state="closed", ctx=ctx)
TOOLS = [ { "name": "gitea_open_issue", "description": "Open a new issue on smk/stargazer-v3 on git.neko.li (shortcut).", "parameters": { "type": "object", "properties": { "title": {"type": "string"}, "body": {"type": "string", "description": "Issue body (markdown)"}, }, "required": ["title", "body"], }, "handler": gitea_open_issue, }, { "name": "gitea_comment_issue", "description": "Comment on an issue on smk/stargazer-v3 (shortcut).", "parameters": { "type": "object", "properties": { "issue_id": {"type": "integer"}, "body": {"type": "string"}, }, "required": ["issue_id", "body"], }, "handler": gitea_comment_issue, }, { "name": "gitea_close_issue", "description": "Close an issue on smk/stargazer-v3 (shortcut).", "parameters": { "type": "object", "properties": {"issue_id": {"type": "integer"}}, "required": ["issue_id"], }, "handler": gitea_close_issue, }, ]