feat: Add powerful CLI for account management (#115)

* feat: Add powerful CLI for account management

- 18 commands for quota monitoring, switching, validation
- Interactive mode with keyboard navigation
- Smart auto-switch based on quotas
- Alias support for quick access
- Token auto-refresh and diagnostics
- Full documentation in cli/README.md"

* fix: Address code review issues - Add SQLite transactions for atomicity\n- Add input validation for import_accounts\n- Add per-account error handling in bulk operations\n- Add graceful error handling in interactive mode\n- Add validation for varint encoding (negative values)\n- Improve user feedback on partial failures
This commit is contained in:
Angelooooo authored and GitHub committed 2026-02-19 19:19:25 +08:00
1 parent 1e59a1c901
commit b9497648c6
10 files changed
+1997 -1

No files matched your search

+102
View File
@@ -0,0 +1,102 @@
# CLI Feature - Pull Request Summary
## What This PR Adds
A complete **Command-Line Interface (CLI)** for Antigravity Manager with 18+ commands for power users.
## Key Features
- 📊 **Live Quota Monitoring** - Real-time tracking for Gemini & Claude models
- 🔄 **Account Switching** - Seamless switching without manual token management
- ✅ **Token Validation** - Auto-refresh expired tokens
- 🎯 **Smart Auto-Switch** - Automatically pick best account by quota
- 🏷️ **Aliases** - Shortcut names for accounts (`work`, `personal`)
- 💾 **Backup/Restore** - Export/import account configurations
- 🎮 **Interactive Mode** - Keyboard-navigated menus for beginners
- 🩺 **Diagnostics** - System health checks
## Technical Highlights
- **Zero Hardcoded Paths**: Intelligently discovers database and executable locations
- **Cross-Platform Ready**: Uses environment variables and checks for Windows/Mac/Linux
- **Secure**: Leverages existing DPAPI + AES-256-GCM encryption (same as GUI)
- **Extensible**: Clean separation between core logic (`core.py`) and commands (`main.py`)
## File Structure
```
cli/
├── README.md # Full documentation
├── requirements.txt # Python dependencies
├── core.py # Database, encryption, API logic
├── main.py # CLI commands and interactive UI
└── proto_utils.py # Protobuf encoding helpers
```
## Usage Examples
```powershell
# Interactive mode
agm
# Quick status
agm status
# Switch accounts
agm switch work
# Auto-switch to best account
agm auto-switch --model claude --min-quota 50
# Live monitoring
agm watch
```
## Testing
- ✅ Tested on Windows 10/11
- ✅ No hardcoded paths (uses standard Windows env vars)
- ✅ Works with both installed and development builds
- ✅ Database encryption/decryption verified
## Dependencies
All Python dependencies are self-contained in `cli/requirements.txt`:
- `typer` - CLI framework
- `rich` - Beautiful terminal output
- `questionary` - Interactive menus
- `pywin32` - Windows DPAPI support
- `cryptography` - AES-256-GCM encryption
- `httpx` - Async HTTP client
- `psutil` - Process management
- `protobuf` - Google API protocol buffers
## Platform Support
- **Windows**: Full support (tested)
- **macOS/Linux**: Partial support (no DPAPI, but core features work)
## Breaking Changes
None. This is a pure addition—no changes to existing GUI code.
## Future Enhancements
- OAuth flow for adding new accounts via CLI
- TUI (Terminal UI) with live dashboard
- Scheduled auto-refresh via Windows Task Scheduler
- Config file for user preferences
## Checklist
- [x] Code follows existing style
- [x] All commands have help text
- [x] No hardcoded paths/credentials
- [x] README with examples
- [x] Dependencies in requirements.txt
- [x] .gitignore updated for Python
- [x] Works with fresh installs
---
**Ready to merge!** 🚀