-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (49 loc) · 1.79 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import threading
import shlex
from argparse import ArgumentError
from config import Config
from scheduler import Scheduler
from github_client import GitHubClient
from core.notifier import Notifier
from core.report_generator import ReportGenerator
from llm import LLM
from core.subscription_manager import SubscriptionManager
from command_handler import CommandHandler
def run_scheduler(scheduler):
scheduler.start()
def main():
config = Config()
github_client = GitHubClient(config.github_token)
notifier = Notifier(config.notification_settings)
llm = LLM(config)
report_generator = ReportGenerator(llm)
subscription_manager = SubscriptionManager(config.subscriptions_file)
command_handler = CommandHandler(github_client, subscription_manager, report_generator)
scheduler = Scheduler(
github_client=github_client,
notifier=notifier,
report_generator=report_generator,
subscription_manager=subscription_manager,
interval=config.update_interval
)
scheduler_thread = threading.Thread(target=run_scheduler, args=(scheduler,))
scheduler_thread.daemon = True
scheduler_thread.start()
parser = command_handler.parser
command_handler.print_help()
while True:
try:
user_input = input("Github agent> ")
if user_input in ['exit', 'quit']:
break
try:
args = parser.parse_args(shlex.split(user_input))
if args.command is None:
continue
args.func(args)
except SystemExit as e:
print("Invalid command. Type 'help' to see the list of available commands.")
except Exception as e:
print(f"Unexpected error: {e}")
if __name__ == '__main__':
main()