-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·142 lines (112 loc) · 4.83 KB
/
main.py
File metadata and controls
executable file
·142 lines (112 loc) · 4.83 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env python3
"""
Mac Cleaner - Free up disk space on your Mac
An AI-powered cleanup assistant using GitHub Copilot SDK
Usage:
python main.py # Interactive mode
python main.py scan # Full system scan
python main.py quick # Quick safe cleanup
python main.py status # Show disk space
python main.py browsers # Clean browser caches
python main.py dev # Clean developer tool caches
"""
import asyncio
import sys
from agent import MacCleanerAgent
from tui import CleanerTUI
async def interactive_mode():
"""Main interactive TUI mode with beautiful interface."""
tui = CleanerTUI()
agent = MacCleanerAgent()
try:
tui.clear()
tui.show_banner()
# Show loading
tui.print("[dim]⏳ Starting agent...[/dim]", justify="center")
await agent.start()
tui.clear()
# Show full interface
tui.show_banner()
tui.show_commands()
tui.show_welcome()
while True:
try:
user_input = tui.read_input("You")
if not user_input.strip():
continue
# Handle local commands (no agent needed)
cmd = user_input.strip().lower()
if cmd in ["exit", "quit", "q"]:
tui.print()
tui.print("[bold green]👋 Goodbye! Your Mac thanks you.[/bold green]", justify="center")
tui.print()
break
elif cmd == "help":
tui.print()
tui.show_commands()
continue
elif cmd == "clear":
tui.clear()
tui.show_banner()
continue
# Map commands to natural language prompts
command_prompts = {
"scan": "Do a full system scan and show me everything that can be cleaned, organized by category. Show sizes and risk levels.",
"status": "Show me my current disk space status with a summary.",
"clean": "Help me clean up my Mac. Show me what's available and guide me through choosing what to clean.",
"quick": "Run a quick safe cleanup now - only remove safe items like caches and logs.",
"browsers": "Clean all my browser caches (Chrome, Firefox, Safari).",
"dev": "Clean all developer tool caches (Xcode, npm, pip, Homebrew, etc.).",
"large": "Find large files on my Mac that I haven't used in a while.",
"purge": "Find project build artifacts like node_modules, target, build, venv, __pycache__ that I can delete.",
"uninstall": "I want to uninstall an app. Ask me which app name to search for, then find all its files.",
}
if cmd in command_prompts:
user_input = command_prompts[cmd]
# Send to agent
tui.print()
await agent.chat(user_input)
tui.print()
except KeyboardInterrupt:
tui.print("\n\n[dim]Interrupted. Goodbye![/dim]")
break
finally:
await agent.stop()
async def run_command(command: str):
"""Run a single command and exit."""
tui = CleanerTUI()
agent = MacCleanerAgent()
try:
tui.show_banner()
tui.print("[dim]⏳ Starting...[/dim]", justify="center")
await agent.start()
tui.print()
prompts = {
"scan": "Do a full system scan and show me everything that can be cleaned, organized by category.",
"status": "Show me my current disk space status.",
"quick": "Run a quick safe cleanup now - only remove safe items like caches and logs. Execute it.",
"browsers": "Clean all browser caches now. Execute it.",
"dev": "Clean all developer tool caches now. Execute it.",
"large": "Find large files on my Mac that I haven't used in a while.",
}
prompt = prompts.get(command, command)
await agent.chat(prompt)
tui.print()
finally:
await agent.stop()
async def main():
"""Main entry point."""
if len(sys.argv) > 1:
command = sys.argv[1].lower()
if command in ["--help", "-h"]:
print(__doc__)
return
await run_command(command)
else:
await interactive_mode()
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
print("\n👋 Goodbye!")
sys.exit(0)