-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9709369
commit ce733aa
Showing
15 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# GitHub Sentinel | ||
|
||
GitHub Sentinel is an open-source tool AI Agent designed for developers and project managers. It automatically retrieves and aggregates updates from subscribed GitHub repositories on a regular basis (daily/weekly). Key features include subscription management, update retrieval, notification system, and report generation. | ||
|
||
## Features | ||
- Subscription management | ||
- Update retrieval | ||
- Notification system | ||
- Report generation | ||
|
||
## Getting Started | ||
1. Install dependencies: | ||
```sh | ||
pip install -r requirements.txt | ||
``` | ||
|
||
2. Configure the application by editing `config.json`. | ||
|
||
3. Run the application: | ||
```sh | ||
python src/main.py | ||
``` | ||
|
||
## Configuration | ||
The configuration file `config.json` should contain the following settings: | ||
```json | ||
{ | ||
"github_token": "your_github_token", | ||
"notification_settings": { | ||
"email": "[email protected]", | ||
"slack_webhook_url": "your_slack_webhook_url" | ||
}, | ||
"subscriptions_file": "subscriptions.json", | ||
"update_interval": 86400 | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import json | ||
|
||
class Config: | ||
def __init__(self): | ||
self.load_config() | ||
|
||
def load_config(self): | ||
with open('config.json', 'r') as f: | ||
config = json.load(f) | ||
self.github_token = config.get('github_token') | ||
self.notification_settings = config.get('notification_settings') | ||
self.subscriptions_file = config.get('subscriptions_file') | ||
self.update_interval = config.get('update_interval', 24 * 60 * 60) # Default to 24 hours |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import requests | ||
|
||
class GitHubClient: | ||
def __init__(self, token): | ||
self.token = token | ||
|
||
def fetch_updates(self, subscriptions): | ||
headers = { | ||
'Authorization': f'token {self.token}' | ||
} | ||
updates = {} | ||
for repo in subscriptions: | ||
response = requests.get(f'https://api.github.com/repos/{repo}/events', headers=headers) | ||
if response.status_code == 200: | ||
updates[repo] = response.json() | ||
return updates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from config import Config | ||
from scheduler import Scheduler | ||
from github_client import GitHubClient | ||
from notifier import Notifier | ||
from report_generator import ReportGenerator | ||
from subscription_manager import SubscriptionManager | ||
|
||
def main(): | ||
config = Config() | ||
github_client = GitHubClient(config.github_token) | ||
notifier = Notifier(config.notification_settings) | ||
report_generator = ReportGenerator() | ||
subscription_manager = SubscriptionManager(config.subscriptions_file) | ||
|
||
scheduler = Scheduler( | ||
github_client=github_client, | ||
notifier=notifier, | ||
report_generator=report_generator, | ||
subscription_manager=subscription_manager, | ||
interval=config.update_interval | ||
) | ||
|
||
scheduler.start() | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Notifier: | ||
def __init__(self, settings): | ||
self.settings = settings | ||
|
||
def notify(self, report): | ||
# Implement notification logic, e.g., send email or Slack message | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class ReportGenerator: | ||
def generate(self, updates): | ||
# Implement report generation logic | ||
report = "" | ||
for repo, events in updates.items(): | ||
report += f"Repository: {repo}\n" | ||
for event in events: | ||
report += f"- {event['type']} at {event['created_at']}\n" | ||
return report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import time | ||
import threading | ||
|
||
class Scheduler: | ||
def __init__(self, github_client, notifier, report_generator, subscription_manager, interval): | ||
self.github_client = github_client | ||
self.notifier = notifier | ||
self.report_generator = report_generator | ||
self.subscription_manager = subscription_manager | ||
self.interval = interval | ||
|
||
def start(self): | ||
while True: | ||
self.run() | ||
time.sleep(self.interval) | ||
|
||
def run(self): | ||
subscriptions = self.subscription_manager.get_subscriptions() | ||
updates = self.github_client.fetch_updates(subscriptions) | ||
report = self.report_generator.generate(updates) | ||
self.notifier.notify(report) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import json | ||
|
||
class SubscriptionManager: | ||
def __init__(self, subscriptions_file): | ||
self.subscriptions_file = subscriptions_file | ||
|
||
def get_subscriptions(self): | ||
with open(self.subscriptions_file, 'r') as f: | ||
return json.load(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Add utility functions as needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import unittest | ||
from src.github_client import GitHubClient | ||
|
||
class TestGitHubClient(unittest.TestCase): | ||
def test_fetch_updates(self): | ||
# Add test cases for GitHubClient | ||
pass | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import unittest | ||
from src.notifier import Notifier | ||
|
||
class TestNotifier(unittest.TestCase): | ||
def test_notify(self): | ||
# Add test cases for Notifier | ||
pass | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import unittest | ||
from src.report_generator import ReportGenerator | ||
|
||
class TestReportGenerator(unittest.TestCase): | ||
def test_generate(self): | ||
# Add test cases for ReportGenerator | ||
pass | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import unittest | ||
from src.subscription_manager import SubscriptionManager | ||
|
||
class TestSubscriptionManager(unittest.TestCase): | ||
def test_get_subscriptions(self): | ||
# Add test cases for SubscriptionManager | ||
pass | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import unittest | ||
# Add imports for utility functions to test | ||
|
||
class TestUtils(unittest.TestCase): | ||
# Add test cases for utility functions | ||
pass | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |