gemini-manager 20.0.0__tar.gz

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.
Files changed (84) hide show
  1. gemini_manager-20.0.0/PKG-INFO +213 -0
  2. gemini_manager-20.0.0/README.md +187 -0
  3. gemini_manager-20.0.0/pyproject.toml +85 -0
  4. gemini_manager-20.0.0/setup.cfg +4 -0
  5. gemini_manager-20.0.0/src/__init__.py +2 -0
  6. gemini_manager-20.0.0/src/gemini_manager/__init__.py +2 -0
  7. gemini_manager-20.0.0/src/gemini_manager/args.py +255 -0
  8. gemini_manager-20.0.0/src/gemini_manager/b2.py +124 -0
  9. gemini_manager-20.0.0/src/gemini_manager/backup.py +321 -0
  10. gemini_manager-20.0.0/src/gemini_manager/banner.py +194 -0
  11. gemini_manager-20.0.0/src/gemini_manager/chat.py +204 -0
  12. gemini_manager-20.0.0/src/gemini_manager/check_b2.py +41 -0
  13. gemini_manager-20.0.0/src/gemini_manager/cli.py +112 -0
  14. gemini_manager-20.0.0/src/gemini_manager/cloud_factory.py +29 -0
  15. gemini_manager-20.0.0/src/gemini_manager/cloud_s3.py +79 -0
  16. gemini_manager-20.0.0/src/gemini_manager/cloud_storage.py +33 -0
  17. gemini_manager-20.0.0/src/gemini_manager/config.py +42 -0
  18. gemini_manager-20.0.0/src/gemini_manager/cooldown.py +505 -0
  19. gemini_manager-20.0.0/src/gemini_manager/credentials.py +150 -0
  20. gemini_manager-20.0.0/src/gemini_manager/doctor.py +73 -0
  21. gemini_manager-20.0.0/src/gemini_manager/history.py +73 -0
  22. gemini_manager-20.0.0/src/gemini_manager/integrity.py +100 -0
  23. gemini_manager-20.0.0/src/gemini_manager/list_backups.py +381 -0
  24. gemini_manager-20.0.0/src/gemini_manager/login.py +103 -0
  25. gemini_manager-20.0.0/src/gemini_manager/logout.py +28 -0
  26. gemini_manager-20.0.0/src/gemini_manager/metadata.py +264 -0
  27. gemini_manager-20.0.0/src/gemini_manager/profile.py +121 -0
  28. gemini_manager-20.0.0/src/gemini_manager/project_config.py +74 -0
  29. gemini_manager-20.0.0/src/gemini_manager/prune.py +155 -0
  30. gemini_manager-20.0.0/src/gemini_manager/recommend.py +346 -0
  31. gemini_manager-20.0.0/src/gemini_manager/reset_helpers.py +662 -0
  32. gemini_manager-20.0.0/src/gemini_manager/restore.py +689 -0
  33. gemini_manager-20.0.0/src/gemini_manager/session.py +43 -0
  34. gemini_manager-20.0.0/src/gemini_manager/settings.py +49 -0
  35. gemini_manager-20.0.0/src/gemini_manager/settings_cli.py +95 -0
  36. gemini_manager-20.0.0/src/gemini_manager/stats.py +77 -0
  37. gemini_manager-20.0.0/src/gemini_manager/status.py +181 -0
  38. gemini_manager-20.0.0/src/gemini_manager/sync.py +101 -0
  39. gemini_manager-20.0.0/src/gemini_manager/ui.py +109 -0
  40. gemini_manager-20.0.0/src/gemini_manager/update.py +131 -0
  41. gemini_manager-20.0.0/src/gemini_manager/utils.py +37 -0
  42. gemini_manager-20.0.0/src/gemini_manager/wizard.py +35 -0
  43. gemini_manager-20.0.0/src/gemini_manager.egg-info/PKG-INFO +213 -0
  44. gemini_manager-20.0.0/src/gemini_manager.egg-info/SOURCES.txt +82 -0
  45. gemini_manager-20.0.0/src/gemini_manager.egg-info/dependency_links.txt +1 -0
  46. gemini_manager-20.0.0/src/gemini_manager.egg-info/entry_points.txt +3 -0
  47. gemini_manager-20.0.0/src/gemini_manager.egg-info/requires.txt +22 -0
  48. gemini_manager-20.0.0/src/gemini_manager.egg-info/top_level.txt +2 -0
  49. gemini_manager-20.0.0/tests/test_auto_restore.py +97 -0
  50. gemini_manager-20.0.0/tests/test_b2.py +232 -0
  51. gemini_manager-20.0.0/tests/test_backup.py +270 -0
  52. gemini_manager-20.0.0/tests/test_banner.py +44 -0
  53. gemini_manager-20.0.0/tests/test_chat.py +248 -0
  54. gemini_manager-20.0.0/tests/test_check_b2.py +46 -0
  55. gemini_manager-20.0.0/tests/test_cleanup.py +114 -0
  56. gemini_manager-20.0.0/tests/test_cli.py +301 -0
  57. gemini_manager-20.0.0/tests/test_cloud_s3.py +179 -0
  58. gemini_manager-20.0.0/tests/test_commands.py +115 -0
  59. gemini_manager-20.0.0/tests/test_cooldown.py +368 -0
  60. gemini_manager-20.0.0/tests/test_cooldown_integration.py +21 -0
  61. gemini_manager-20.0.0/tests/test_credentials.py +209 -0
  62. gemini_manager-20.0.0/tests/test_doctor.py +68 -0
  63. gemini_manager-20.0.0/tests/test_encrypted_backup.py +114 -0
  64. gemini_manager-20.0.0/tests/test_history.py +216 -0
  65. gemini_manager-20.0.0/tests/test_integrity.py +114 -0
  66. gemini_manager-20.0.0/tests/test_list_backups.py +118 -0
  67. gemini_manager-20.0.0/tests/test_logout.py +28 -0
  68. gemini_manager-20.0.0/tests/test_metadata.py +109 -0
  69. gemini_manager-20.0.0/tests/test_profile.py +203 -0
  70. gemini_manager-20.0.0/tests/test_project_config.py +81 -0
  71. gemini_manager-20.0.0/tests/test_prune.py +203 -0
  72. gemini_manager-20.0.0/tests/test_recommend.py +342 -0
  73. gemini_manager-20.0.0/tests/test_reset_helpers.py +613 -0
  74. gemini_manager-20.0.0/tests/test_restore.py +851 -0
  75. gemini_manager-20.0.0/tests/test_session.py +62 -0
  76. gemini_manager-20.0.0/tests/test_settings.py +66 -0
  77. gemini_manager-20.0.0/tests/test_settings_cli.py +123 -0
  78. gemini_manager-20.0.0/tests/test_stats.py +74 -0
  79. gemini_manager-20.0.0/tests/test_status.py +132 -0
  80. gemini_manager-20.0.0/tests/test_sync.py +142 -0
  81. gemini_manager-20.0.0/tests/test_ui.py +50 -0
  82. gemini_manager-20.0.0/tests/test_update.py +254 -0
  83. gemini_manager-20.0.0/tests/test_utils.py +87 -0
  84. gemini_manager-20.0.0/tests/test_wizard.py +100 -0
@@ -0,0 +1,213 @@
1
+ Metadata-Version: 2.4
2
+ Name: gemini-manager
3
+ Version: 20.0.0
4
+ Summary: Gemini AI CLI Tool for automation
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: b2sdk>=1.18.0
8
+ Requires-Dist: boto3>=1.28.0
9
+ Requires-Dist: freezegun>=1.5.5
10
+ Requires-Dist: rich>=10.0.0
11
+ Requires-Dist: tomli>=2.0.0; python_version < "3.11"
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
14
+ Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
15
+ Requires-Dist: pytest-timeout>=2.2.0; extra == "dev"
16
+ Requires-Dist: pytest-json-report>=1.5.0; extra == "dev"
17
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
18
+ Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
19
+ Requires-Dist: pyfakefs>=5.0.0; extra == "dev"
20
+ Requires-Dist: ruff>=0.6.0; extra == "dev"
21
+ Requires-Dist: black>=24.3.0; extra == "dev"
22
+ Requires-Dist: mypy>=1.11.0; extra == "dev"
23
+ Requires-Dist: PyYAML>=6.0; extra == "dev"
24
+ Requires-Dist: types-PyYAML>=6.0; extra == "dev"
25
+ Requires-Dist: freezegun>=1.2.0; extra == "dev"
26
+
27
+ # GM AI Automation Tool
28
+
29
+ <div align="center">
30
+ <img src="https://raw.githubusercontent.com/dhruv13x/gemini-manager/main/gemini-manager_logo.png" alt="gemini-manager logo" width="200"/>
31
+ </div>
32
+
33
+ <div align="center">
34
+
35
+ [![Build status](https://github.com/dhruv13x/gemini-manager/actions/workflows/publish.yml/badge.svg)](https://github.com/dhruv13x/gemini-manager/actions/workflows/publish.yml)
36
+ [![PyPI version](https://img.shields.io/pypi/v/gemini-manager.svg)](https://pypi.org/project/gemini-manager/)
37
+ [![Python](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/)
38
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
39
+ [![Ruff](https://img.shields.io/badge/linting-ruff-yellow.svg)](https://github.com/astral-sh/ruff)
40
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
41
+ [![Maintenance](https://img.shields.io/badge/maintenance-active-green.svg)](https://github.com/dhruv13x/gemini-manager/graphs/commit-activity)
42
+
43
+ </div>
44
+
45
+ **The Swiss Army Knife for GM AI Automation - Backups, Cloud Sync, and Account Management.**
46
+
47
+ `gemini-manager` is a powerful, "batteries-included" command-line interface designed to supercharge your GM AI experience. It handles backups (Local, S3, B2), synchronizes data across devices, manages multiple profiles, and intelligently tracks account usage to bypass rate limits.
48
+
49
+ ---
50
+
51
+ ## ⚡ Quick Start (The "5-Minute Rule")
52
+
53
+ ### Prerequisites
54
+ - **Python**: 3.8 or higher
55
+ - **Optional**: [AWS CLI](https://aws.amazon.com/cli/) or [Backblaze B2 CLI](https://www.backblaze.com/b2/docs/quick_command_line.html) for credentials management.
56
+
57
+ ### Installation
58
+
59
+ ```bash
60
+ # Install from PyPI
61
+ pip install gemini-manager
62
+
63
+ # Or install from source
64
+ pip install .
65
+ ```
66
+
67
+ ### Get Started Immediately
68
+
69
+ Copy and paste this snippet to configure your first profile, backup to the cloud, and verify your system health.
70
+
71
+ ```bash
72
+ # 1. Run the interactive setup wizard
73
+ gm config --init
74
+
75
+ # 2. Run your first local backup
76
+ gm backup
77
+
78
+ # 3. Push your backup to the cloud (requires configured credentials)
79
+ gm sync push
80
+
81
+ # 4. Check the account dashboard
82
+ gm cooldown --cloud
83
+
84
+ # 5. Get a smart account recommendation
85
+ gm recommend
86
+ ```
87
+
88
+ ---
89
+
90
+ ## ✨ Features
91
+
92
+ ### Core Capabilities
93
+ * **🛡️ God Level Backups**: Securely backup your configuration and chat history to **Local**, **AWS S3**, or **Backblaze B2** storage. Supports **GPG Encryption** for sensitive data.
94
+ * **🌍 Machine-Time Adaptive**: Automatically detects and uses your system's local timezone for all calculations and displays. No more manual IST/UTC conversions.
95
+ * **☁️ Unified Cloud Sync**: Seamlessly `push` and `pull` backups between your local machine and the cloud.
96
+
97
+ ### Smart Automation
98
+ * **⏱️ Smart Session Tracking**: Tracks "First Used" timestamps to accurately predict GM's 24-hour rolling quota resets.
99
+ * **🧠 Intelligent Rotation**: Automatically recommends the "healthiest" account based on session start times and Least Recently Used (LRU) logic.
100
+ * **🛡️ Accident Protection**: Safeguards your session data by preventing accidental account switches from resetting your 24-hour quota clock.
101
+
102
+ ### Diagnostics & Management
103
+ * **📊 Visual Analytics**: View beautiful, terminal-based bar charts of your usage history and account health.
104
+ * **🩺 Doctor Mode**: Built-in diagnostic tool to validate your environment, dependencies, and configuration health.
105
+ * **🧹 Auto-Pruning**: Automatically cleans up old backups and temporary files to keep your storage efficient.
106
+
107
+ ---
108
+
109
+ ## 🛠️ Configuration
110
+
111
+ You can configure `gemini-manager` using **Environment Variables**, **CLI Arguments**, or the **Interactive Config** (`gm config --init`).
112
+
113
+ **Priority Order**: CLI Arguments > Environment Variables > `.env` / Doppler > Saved Config (`~/.gemini-manager/settings.json`)
114
+
115
+ ### Backup Naming Convention
116
+
117
+ `gemini-manager` uses a strict naming convention for backups to enable automatic discovery and account rotation.
118
+
119
+ * **Archives**: `YYYY-MM-DD_HHMMSS-email@example.com.gemini-manager.tar.gz`
120
+ * **Encrypted Archives**: `...tar.gz.gpg`
121
+ * **Metadata**: `YYYY-MM-DD_HHMMSS-email@example.com.gemini-manager.metadata.json`
122
+
123
+ The timestamp in the filename is typically the **scheduled reset time** (in your local timezone) for that account, allowing the tool to quickly identify which backup belongs to which session window.
124
+
125
+ ### Environment Variables
126
+
127
+ | Variable | Description | Default | Required |
128
+ | :--- | :--- | :--- | :--- |
129
+ | `GEMINI_AWS_ACCESS_KEY_ID` | AWS Access Key ID for S3. | None | No (for S3) |
130
+ | `GEMINI_AWS_SECRET_ACCESS_KEY` | AWS Secret Access Key for S3. | None | No (for S3) |
131
+ | `GEMINI_S3_BUCKET` | AWS S3 Bucket Name. | None | No (for S3) |
132
+ | `GEMINI_S3_REGION` | AWS Region. | `us-east-1` | No |
133
+ | `GEMINI_B2_KEY_ID` | Backblaze B2 Application Key ID. | None | No (for B2) |
134
+ | `GEMINI_B2_APP_KEY` | Backblaze B2 Application Key. | None | No (for B2) |
135
+ | `GEMINI_B2_BUCKET` | Backblaze B2 Bucket Name. | None | No (for B2) |
136
+ | `GEMINI_BACKUP_PASSWORD` | Password for GPG encryption. | None | No (for `--encrypt`) |
137
+ | `DOPPLER_TOKEN` | Token for Doppler secrets management. | None | No |
138
+
139
+ ### Key CLI Arguments
140
+
141
+ | Command | Flag | Description |
142
+ | :--- | :--- | :--- |
143
+ | `backup` | `--encrypt` | Encrypt the backup archive using GPG. |
144
+ | `restore` | `--auto` | Automatically select and restore the latest backup for the best available account. |
145
+ | `prune` | `--cloud-only` | Only remove old backups from cloud storage, keeping local copies. |
146
+ | `config` | `--force` | Force overwrite existing configuration values. |
147
+ | `cooldown` | `--reset-all` | **DANGER**: Wipe all cooldown data (local and cloud). |
148
+
149
+ ---
150
+
151
+ ## 🏗️ Architecture
152
+
153
+ The `gemini-manager` is built with modularity and extensibility in mind.
154
+
155
+ ```text
156
+ src/gemini_manager/
157
+ ├── cli.py # 🚀 Entry Point & Argument Routing
158
+ ├── config.py # ⚙️ Global Constants & Paths
159
+ ├── backup.py # 📦 Backup Logic (Local & Cloud dispatch)
160
+ ├── restore.py # ♻️ Restore Logic (Auto-selection & Session logs)
161
+ ├── cooldown.py # ❄️ Master Dashboard & Adaptive Time Logic
162
+ ├── recommend.py # 🧠 Recommendation Engine (Session-aware)
163
+ ├── sync.py # 🔄 Unified Sync (Push/Pull)
164
+ ├── cloud_factory.py # ☁️ Cloud Provider Abstract Factory
165
+ └── stats.py # 📊 Visualization Module
166
+ ```
167
+
168
+ ### Data Flow
169
+ 1. **User Input**: CLI args are parsed by `args.py` and routed by `cli.py`.
170
+ 2. **Configuration**: Settings are loaded from `settings_cli.py` (merging Env, CLI, and Config).
171
+ 3. **Action**:
172
+ - **Backup**: Compresses `~/.gemini-manager`, encrypts (optional), and uploads via `CloudFactory`.
173
+ - **Restore**: Fetches list from cloud/local, decrypts, and extracts to `~/.gemini-manager`.
174
+ - **Recommendation**: Queries `cooldown.py` for account status and selects the LRU "Ready" account.
175
+ 4. **Persistence**: Usage stats and cooldowns are saved to JSON files in `~/.gemini-manager`.
176
+
177
+ ---
178
+
179
+ ## 🐞 Troubleshooting
180
+
181
+ | Error Message | Possible Cause | Solution |
182
+ | :--- | :--- | :--- |
183
+ | `ModuleNotFoundError: No module named 'gemini_manager'` | Installation issue. | Run `pip install -e .` or ensure you are in the correct venv. |
184
+ | `gpg: decryption failed: No secret key` | Missing GPG key or wrong password. | Ensure `GEMINI_BACKUP_PASSWORD` is set or the GPG key is imported. |
185
+ | `ClientError: An error occurred (403) ...` | AWS/B2 Credentials invalid. | Check your `GEMINI_*` env vars or `~/.aws/credentials`. |
186
+ | `Permission denied: '~/.gemini-manager'` | File permission issues. | Run `chown -R $USER ~/.gemini-manager` or check directory permissions. |
187
+
188
+ **Debug Mode**: Currently, you can increase verbosity by inspecting the logs or running with standard python tracebacks enabled (default).
189
+
190
+ ---
191
+
192
+ ## 🤝 Contributing
193
+
194
+ We welcome contributions! Whether it's reporting a bug, suggesting a feature, or writing code.
195
+
196
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed instructions.
197
+
198
+ 1. **Setup Dev Environment**: `pip install -e .[dev]`
199
+ 2. **Run Tests**: `pytest tests/`
200
+ 3. **Submit PR**: Follow the guidelines in the contributing guide.
201
+
202
+ ---
203
+
204
+ ## 🗺️ Roadmap
205
+
206
+ * **Phase 1 (Completed)**: Core Backup/Restore, Multi-Cloud (S3/B2), Sync, Auto-Updates.
207
+ * **Phase 2 (Completed)**: Machine-Time Adaptation, Session Tracking, Smart Rotation.
208
+ * **Phase 3 (Upcoming)**:
209
+ * 🔔 **Webhooks**: Slack/Discord notifications for backup status.
210
+ * 🐍 **Python SDK**: Import `gemini_manager` as a library in your own scripts.
211
+ * **Phase 4 (Vision)**: AI-driven anomaly detection and self-healing infrastructure.
212
+
213
+ See [ROADMAP.md](ROADMAP.md) for the full detailed vision.
@@ -0,0 +1,187 @@
1
+ # GM AI Automation Tool
2
+
3
+ <div align="center">
4
+ <img src="https://raw.githubusercontent.com/dhruv13x/gemini-manager/main/gemini-manager_logo.png" alt="gemini-manager logo" width="200"/>
5
+ </div>
6
+
7
+ <div align="center">
8
+
9
+ [![Build status](https://github.com/dhruv13x/gemini-manager/actions/workflows/publish.yml/badge.svg)](https://github.com/dhruv13x/gemini-manager/actions/workflows/publish.yml)
10
+ [![PyPI version](https://img.shields.io/pypi/v/gemini-manager.svg)](https://pypi.org/project/gemini-manager/)
11
+ [![Python](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/)
12
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
13
+ [![Ruff](https://img.shields.io/badge/linting-ruff-yellow.svg)](https://github.com/astral-sh/ruff)
14
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
15
+ [![Maintenance](https://img.shields.io/badge/maintenance-active-green.svg)](https://github.com/dhruv13x/gemini-manager/graphs/commit-activity)
16
+
17
+ </div>
18
+
19
+ **The Swiss Army Knife for GM AI Automation - Backups, Cloud Sync, and Account Management.**
20
+
21
+ `gemini-manager` is a powerful, "batteries-included" command-line interface designed to supercharge your GM AI experience. It handles backups (Local, S3, B2), synchronizes data across devices, manages multiple profiles, and intelligently tracks account usage to bypass rate limits.
22
+
23
+ ---
24
+
25
+ ## ⚡ Quick Start (The "5-Minute Rule")
26
+
27
+ ### Prerequisites
28
+ - **Python**: 3.8 or higher
29
+ - **Optional**: [AWS CLI](https://aws.amazon.com/cli/) or [Backblaze B2 CLI](https://www.backblaze.com/b2/docs/quick_command_line.html) for credentials management.
30
+
31
+ ### Installation
32
+
33
+ ```bash
34
+ # Install from PyPI
35
+ pip install gemini-manager
36
+
37
+ # Or install from source
38
+ pip install .
39
+ ```
40
+
41
+ ### Get Started Immediately
42
+
43
+ Copy and paste this snippet to configure your first profile, backup to the cloud, and verify your system health.
44
+
45
+ ```bash
46
+ # 1. Run the interactive setup wizard
47
+ gm config --init
48
+
49
+ # 2. Run your first local backup
50
+ gm backup
51
+
52
+ # 3. Push your backup to the cloud (requires configured credentials)
53
+ gm sync push
54
+
55
+ # 4. Check the account dashboard
56
+ gm cooldown --cloud
57
+
58
+ # 5. Get a smart account recommendation
59
+ gm recommend
60
+ ```
61
+
62
+ ---
63
+
64
+ ## ✨ Features
65
+
66
+ ### Core Capabilities
67
+ * **🛡️ God Level Backups**: Securely backup your configuration and chat history to **Local**, **AWS S3**, or **Backblaze B2** storage. Supports **GPG Encryption** for sensitive data.
68
+ * **🌍 Machine-Time Adaptive**: Automatically detects and uses your system's local timezone for all calculations and displays. No more manual IST/UTC conversions.
69
+ * **☁️ Unified Cloud Sync**: Seamlessly `push` and `pull` backups between your local machine and the cloud.
70
+
71
+ ### Smart Automation
72
+ * **⏱️ Smart Session Tracking**: Tracks "First Used" timestamps to accurately predict GM's 24-hour rolling quota resets.
73
+ * **🧠 Intelligent Rotation**: Automatically recommends the "healthiest" account based on session start times and Least Recently Used (LRU) logic.
74
+ * **🛡️ Accident Protection**: Safeguards your session data by preventing accidental account switches from resetting your 24-hour quota clock.
75
+
76
+ ### Diagnostics & Management
77
+ * **📊 Visual Analytics**: View beautiful, terminal-based bar charts of your usage history and account health.
78
+ * **🩺 Doctor Mode**: Built-in diagnostic tool to validate your environment, dependencies, and configuration health.
79
+ * **🧹 Auto-Pruning**: Automatically cleans up old backups and temporary files to keep your storage efficient.
80
+
81
+ ---
82
+
83
+ ## 🛠️ Configuration
84
+
85
+ You can configure `gemini-manager` using **Environment Variables**, **CLI Arguments**, or the **Interactive Config** (`gm config --init`).
86
+
87
+ **Priority Order**: CLI Arguments > Environment Variables > `.env` / Doppler > Saved Config (`~/.gemini-manager/settings.json`)
88
+
89
+ ### Backup Naming Convention
90
+
91
+ `gemini-manager` uses a strict naming convention for backups to enable automatic discovery and account rotation.
92
+
93
+ * **Archives**: `YYYY-MM-DD_HHMMSS-email@example.com.gemini-manager.tar.gz`
94
+ * **Encrypted Archives**: `...tar.gz.gpg`
95
+ * **Metadata**: `YYYY-MM-DD_HHMMSS-email@example.com.gemini-manager.metadata.json`
96
+
97
+ The timestamp in the filename is typically the **scheduled reset time** (in your local timezone) for that account, allowing the tool to quickly identify which backup belongs to which session window.
98
+
99
+ ### Environment Variables
100
+
101
+ | Variable | Description | Default | Required |
102
+ | :--- | :--- | :--- | :--- |
103
+ | `GEMINI_AWS_ACCESS_KEY_ID` | AWS Access Key ID for S3. | None | No (for S3) |
104
+ | `GEMINI_AWS_SECRET_ACCESS_KEY` | AWS Secret Access Key for S3. | None | No (for S3) |
105
+ | `GEMINI_S3_BUCKET` | AWS S3 Bucket Name. | None | No (for S3) |
106
+ | `GEMINI_S3_REGION` | AWS Region. | `us-east-1` | No |
107
+ | `GEMINI_B2_KEY_ID` | Backblaze B2 Application Key ID. | None | No (for B2) |
108
+ | `GEMINI_B2_APP_KEY` | Backblaze B2 Application Key. | None | No (for B2) |
109
+ | `GEMINI_B2_BUCKET` | Backblaze B2 Bucket Name. | None | No (for B2) |
110
+ | `GEMINI_BACKUP_PASSWORD` | Password for GPG encryption. | None | No (for `--encrypt`) |
111
+ | `DOPPLER_TOKEN` | Token for Doppler secrets management. | None | No |
112
+
113
+ ### Key CLI Arguments
114
+
115
+ | Command | Flag | Description |
116
+ | :--- | :--- | :--- |
117
+ | `backup` | `--encrypt` | Encrypt the backup archive using GPG. |
118
+ | `restore` | `--auto` | Automatically select and restore the latest backup for the best available account. |
119
+ | `prune` | `--cloud-only` | Only remove old backups from cloud storage, keeping local copies. |
120
+ | `config` | `--force` | Force overwrite existing configuration values. |
121
+ | `cooldown` | `--reset-all` | **DANGER**: Wipe all cooldown data (local and cloud). |
122
+
123
+ ---
124
+
125
+ ## 🏗️ Architecture
126
+
127
+ The `gemini-manager` is built with modularity and extensibility in mind.
128
+
129
+ ```text
130
+ src/gemini_manager/
131
+ ├── cli.py # 🚀 Entry Point & Argument Routing
132
+ ├── config.py # ⚙️ Global Constants & Paths
133
+ ├── backup.py # 📦 Backup Logic (Local & Cloud dispatch)
134
+ ├── restore.py # ♻️ Restore Logic (Auto-selection & Session logs)
135
+ ├── cooldown.py # ❄️ Master Dashboard & Adaptive Time Logic
136
+ ├── recommend.py # 🧠 Recommendation Engine (Session-aware)
137
+ ├── sync.py # 🔄 Unified Sync (Push/Pull)
138
+ ├── cloud_factory.py # ☁️ Cloud Provider Abstract Factory
139
+ └── stats.py # 📊 Visualization Module
140
+ ```
141
+
142
+ ### Data Flow
143
+ 1. **User Input**: CLI args are parsed by `args.py` and routed by `cli.py`.
144
+ 2. **Configuration**: Settings are loaded from `settings_cli.py` (merging Env, CLI, and Config).
145
+ 3. **Action**:
146
+ - **Backup**: Compresses `~/.gemini-manager`, encrypts (optional), and uploads via `CloudFactory`.
147
+ - **Restore**: Fetches list from cloud/local, decrypts, and extracts to `~/.gemini-manager`.
148
+ - **Recommendation**: Queries `cooldown.py` for account status and selects the LRU "Ready" account.
149
+ 4. **Persistence**: Usage stats and cooldowns are saved to JSON files in `~/.gemini-manager`.
150
+
151
+ ---
152
+
153
+ ## 🐞 Troubleshooting
154
+
155
+ | Error Message | Possible Cause | Solution |
156
+ | :--- | :--- | :--- |
157
+ | `ModuleNotFoundError: No module named 'gemini_manager'` | Installation issue. | Run `pip install -e .` or ensure you are in the correct venv. |
158
+ | `gpg: decryption failed: No secret key` | Missing GPG key or wrong password. | Ensure `GEMINI_BACKUP_PASSWORD` is set or the GPG key is imported. |
159
+ | `ClientError: An error occurred (403) ...` | AWS/B2 Credentials invalid. | Check your `GEMINI_*` env vars or `~/.aws/credentials`. |
160
+ | `Permission denied: '~/.gemini-manager'` | File permission issues. | Run `chown -R $USER ~/.gemini-manager` or check directory permissions. |
161
+
162
+ **Debug Mode**: Currently, you can increase verbosity by inspecting the logs or running with standard python tracebacks enabled (default).
163
+
164
+ ---
165
+
166
+ ## 🤝 Contributing
167
+
168
+ We welcome contributions! Whether it's reporting a bug, suggesting a feature, or writing code.
169
+
170
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed instructions.
171
+
172
+ 1. **Setup Dev Environment**: `pip install -e .[dev]`
173
+ 2. **Run Tests**: `pytest tests/`
174
+ 3. **Submit PR**: Follow the guidelines in the contributing guide.
175
+
176
+ ---
177
+
178
+ ## 🗺️ Roadmap
179
+
180
+ * **Phase 1 (Completed)**: Core Backup/Restore, Multi-Cloud (S3/B2), Sync, Auto-Updates.
181
+ * **Phase 2 (Completed)**: Machine-Time Adaptation, Session Tracking, Smart Rotation.
182
+ * **Phase 3 (Upcoming)**:
183
+ * 🔔 **Webhooks**: Slack/Discord notifications for backup status.
184
+ * 🐍 **Python SDK**: Import `gemini_manager` as a library in your own scripts.
185
+ * **Phase 4 (Vision)**: AI-driven anomaly detection and self-healing infrastructure.
186
+
187
+ See [ROADMAP.md](ROADMAP.md) for the full detailed vision.
@@ -0,0 +1,85 @@
1
+ [project]
2
+ name = "gemini-manager"
3
+ version = "20.0.0"
4
+ description = "Gemini AI CLI Tool for automation"
5
+ readme = "README.md"
6
+ requires-python = ">=3.8"
7
+ dependencies = [
8
+ "b2sdk>=1.18.0",
9
+ "boto3>=1.28.0",
10
+ "freezegun>=1.5.5",
11
+ "rich>=10.0.0",
12
+ "tomli>=2.0.0; python_version < '3.11'",
13
+ ]
14
+
15
+ [project.scripts]
16
+ gm = "gemini_manager.cli:main"
17
+ gemini-manager = "gemini_manager.cli:main"
18
+
19
+ [build-system]
20
+ requires = ["setuptools", "wheel"]
21
+ build-backend = "setuptools.build_meta"
22
+
23
+
24
+
25
+
26
+ [project.optional-dependencies]
27
+ dev = [
28
+ "pytest>=8.0.0",
29
+ "pytest-cov>=5.0.0",
30
+ "pytest-timeout>=2.2.0",
31
+ "pytest-json-report>=1.5.0",
32
+ "pytest-asyncio>=0.23.0",
33
+ "pytest-mock>=3.10.0",
34
+ "pyfakefs>=5.0.0",
35
+ "ruff>=0.6.0",
36
+ "black>=24.3.0",
37
+ "mypy>=1.11.0",
38
+ "PyYAML>=6.0",
39
+ "types-PyYAML>=6.0",
40
+ "freezegun>=1.2.0"
41
+ ]
42
+
43
+ [tool.pytest.ini_options]
44
+ # All projects use src/ layout
45
+ pythonpath = ["src"]
46
+
47
+ # All tests live under tests/
48
+ testpaths = ["tests"]
49
+
50
+ # Async projects are common in your stack
51
+ asyncio_mode = "auto"
52
+
53
+ # Global pytest options
54
+ addopts = [
55
+ "-v",
56
+ "-ra",
57
+ "--strict-config",
58
+ "--strict-markers",
59
+ "--tb=short",
60
+ "--showlocals",
61
+ "--import-mode=importlib",
62
+
63
+ # Time & perf
64
+ "--timeout=10",
65
+ "--durations=10",
66
+
67
+ # Coverage: target the real package
68
+ "--cov=src/gemini_manager",
69
+ "--cov-report=term-missing:skip-covered",
70
+ "--cov-report=html",
71
+ "--cov-report=xml",
72
+ "--cov-fail-under=85",
73
+ ]
74
+
75
+ log_cli = true
76
+ log_cli_level = "INFO"
77
+
78
+ [tool.coverage.run]
79
+ branch = true
80
+ source = ["src/gemini_manager"]
81
+
82
+ [tool.coverage.report]
83
+ fail_under = 85
84
+ show_missing = true
85
+ skip_covered = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,2 @@
1
+ # src/__init__.py
2
+
@@ -0,0 +1,2 @@
1
+ # src/gemini_manager/__init__.py
2
+