cortexflow-github 0.1.0__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.
@@ -0,0 +1,7 @@
1
+ """cortexflow-github — example CortexFlow plugin: GitHub repo events."""
2
+
3
+ from cortexflow_github.plugin import GitHubPlugin
4
+ from cortexflow_github.tool import GitHubEventsTool
5
+
6
+ __all__ = ["GitHubEventsTool", "GitHubPlugin"]
7
+ __version__ = "0.1.0"
@@ -0,0 +1,28 @@
1
+ """GitHubPlugin — registers GitHubEventsTool with the CortexFlow gateway."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+
7
+ from cortexflow_sdk import Plugin, PluginMetadata
8
+
9
+ from cortexflow_github.tool import GitHubEventsTool
10
+
11
+
12
+ class GitHubPlugin(Plugin):
13
+ """Adds a github_events tool. Reads GITHUB_TOKEN from the environment."""
14
+
15
+ metadata = PluginMetadata(
16
+ name="cortexflow-github",
17
+ version="0.1.0",
18
+ plugin_type="tool",
19
+ description="List recent GitHub repository events (pushes, PRs, issues).",
20
+ permissions=["network"],
21
+ homepage="https://github.com/TheAmitChandra/CortexFlow",
22
+ )
23
+
24
+ def __init__(self) -> None:
25
+ self._token = os.getenv("GITHUB_TOKEN")
26
+
27
+ def get_tools(self):
28
+ return [GitHubEventsTool(token=self._token)]
@@ -0,0 +1,56 @@
1
+ """GitHubEventsTool — lists recent public events for a GitHub repository."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from cortexflow_sdk import Tool, ToolResult
6
+
7
+ _API_URL = "https://api.github.com/repos/{owner}/{repo}/events"
8
+
9
+
10
+ class GitHubEventsTool(Tool):
11
+ """Fetches recent events (pushes, PRs, issues, stars) for a repo."""
12
+
13
+ name = "github_events"
14
+ description = "List recent GitHub events (pushes, PRs, issues) for a repository."
15
+ parameters = {
16
+ "owner": {"type": "str", "description": "Repository owner/org", "required": True},
17
+ "repo": {"type": "str", "description": "Repository name", "required": True},
18
+ "limit": {"type": "int", "description": "Max events to return (default 10)", "required": False},
19
+ }
20
+ permissions = ["network"]
21
+
22
+ def __init__(self, token: str | None = None) -> None:
23
+ self._token = token
24
+
25
+ async def execute(self, owner: str, repo: str, limit: int = 10, **_) -> ToolResult:
26
+ try:
27
+ import httpx
28
+ except ImportError:
29
+ return ToolResult(tool=self.name, output=None, error="pip install httpx")
30
+
31
+ headers = {"Authorization": f"Bearer {self._token}"} if self._token else {}
32
+ url = _API_URL.format(owner=owner, repo=repo)
33
+
34
+ try:
35
+ async with httpx.AsyncClient() as client:
36
+ resp = await client.get(
37
+ url, headers=headers, params={"per_page": min(limit, 100)}, timeout=10.0,
38
+ )
39
+ resp.raise_for_status()
40
+ events = resp.json()
41
+ except Exception as exc:
42
+ return ToolResult(tool=self.name, output=None, error=str(exc))
43
+
44
+ formatted = [
45
+ {
46
+ "type": e.get("type", "Unknown"),
47
+ "actor": (e.get("actor") or {}).get("login", "unknown"),
48
+ "created_at": e.get("created_at", ""),
49
+ }
50
+ for e in events[:limit]
51
+ ]
52
+ return ToolResult(
53
+ tool=self.name,
54
+ output=formatted,
55
+ metadata={"repo": f"{owner}/{repo}", "count": len(formatted)},
56
+ )
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: cortexflow-github
3
+ Version: 0.1.0
4
+ Summary: CortexFlow plugin — list recent GitHub repository events (pushes, PRs, issues).
5
+ Author-email: Amit Chandra <amit.vervebot@gmail.com>
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: cortexflow-sdk>=0.1.0
11
+ Requires-Dist: httpx>=0.27.0
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=8.2.0; extra == "dev"
14
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
15
+ Dynamic: license-file
16
+
17
+ # cortexflow-github
18
+
19
+ Example CortexFlow plugin: a `github_events` tool that lists recent events
20
+ (pushes, PRs, issues) for a GitHub repository via the public REST API.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install -e ./cortexflow-sdk # not yet on PyPI
26
+ pip install -e examples/plugins/cortexflow-github
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ Set `GITHUB_TOKEN` in your environment for authenticated requests (raises the
32
+ rate limit from 60/hr to 5000/hr) — optional, the tool works without it.
33
+
34
+ ```python
35
+ from cortexflow_github import GitHubEventsTool
36
+
37
+ tool = GitHubEventsTool()
38
+ result = await tool.execute(owner="TheAmitChandra", repo="CortexFlow", limit=5)
39
+ print(result.output)
40
+ ```
41
+
42
+ Once installed alongside the CortexFlow gateway, `cortex plugin add
43
+ cortexflow-github` (or simply having it installed in the same environment)
44
+ makes `PluginRegistry.discover()` find it via the `cortexflow.plugins` entry
45
+ point declared in `pyproject.toml`.
@@ -0,0 +1,9 @@
1
+ cortexflow_github/__init__.py,sha256=KwW66nD2xqit5ByDhZwoXX_ZW61xBEq-9AUEEiMucFI,248
2
+ cortexflow_github/plugin.py,sha256=aNPtDylQ_wJ97_PQBWctU9luVh7olUWrwvm82csf_4w,804
3
+ cortexflow_github/tool.py,sha256=ss6Fa2F7B9Iz5bicVPVnlTqVUW6d9KkZR8MmXfhfbLw,2098
4
+ cortexflow_github-0.1.0.dist-info/licenses/LICENSE,sha256=7Dz5G7L1S2nxC1KQDChyyWKVx4NDmJJDf-KNruUtrHk,1069
5
+ cortexflow_github-0.1.0.dist-info/METADATA,sha256=Qs8DOfKrbzOHAKuJ3v9m8OS_Rwo1s1pkWNFAct0kJ1U,1422
6
+ cortexflow_github-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
7
+ cortexflow_github-0.1.0.dist-info/entry_points.txt,sha256=yceQiBvaq0TE9OExqdHmo_CZkjtaxZFB27VCYiJLtzg,79
8
+ cortexflow_github-0.1.0.dist-info/top_level.txt,sha256=2UxMN6RVw_3YgLXu0mS76X9qOouHr7nFCBFR6J0V9oQ,18
9
+ cortexflow_github-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [cortexflow.plugins]
2
+ cortexflow-github = cortexflow_github.plugin:GitHubPlugin
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Amit Chandra
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 @@
1
+ cortexflow_github