7zon-cli 0.2.2__py3-none-any.whl

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.
@@ -0,0 +1,341 @@
1
+ Metadata-Version: 2.5
2
+ Name: 7zon-cli
3
+ Version: 0.2.2
4
+ Summary: 7ZON — terminalda ishlaydigan AI yordamchi: buyruq yozadi, xatolarni tuzatadi, tushuntiradi.
5
+ Project-URL: Homepage, https://github.com/7zon-uz/7ZON-CLI
6
+ Project-URL: Issues, https://github.com/7zon-uz/7ZON-CLI/issues
7
+ Author: 7ZON Team
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: ai,assistant,claude,cli,developer-tools,gemini,terminal,uzbek
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Software Development
15
+ Classifier: Topic :: Utilities
16
+ Requires-Python: >=3.10
17
+ Requires-Dist: keyring>=25; sys_platform == 'darwin' or sys_platform == 'win32'
18
+ Requires-Dist: rich>=13
19
+ Requires-Dist: typer<0.29,>=0.15
20
+ Provides-Extra: claude
21
+ Requires-Dist: anthropic>=2.17; extra == 'claude'
22
+ Provides-Extra: dev
23
+ Requires-Dist: anthropic>=2.17; extra == 'dev'
24
+ Requires-Dist: pytest>=8; extra == 'dev'
25
+ Description-Content-Type: text/markdown
26
+
27
+ <div align="center">
28
+
29
+ ```
30
+ ████████████
31
+ ████ 7ZON CLI
32
+ ████
33
+ ████ Terminaldagi AI yordamchingiz
34
+ ████
35
+ ████
36
+ ████████████
37
+ ```
38
+
39
+ # ⚡ 7ZON CLI
40
+
41
+ **Terminalda ishlaydigan AI agent: o'zbek tilida tushunadi, o'zi bajaradi.**
42
+
43
+ Vazifani oddiy so'z bilan ayting: 7ZON buyruqlarni ishga tushiradi, fayl yozadi va tahrirlaydi,
44
+ loyiha bo'ylab qidiradi, rasm va PDF'larni ko'radi, xatolarni tuzatadi. Har bir amaldan oldin ruxsat so'raydi.
45
+
46
+ [![CI](https://github.com/7zon-uz/7ZON-CLI/actions/workflows/ci.yml/badge.svg)](https://github.com/7zon-uz/7ZON-CLI/actions)
47
+ ![Python](https://img.shields.io/badge/python-3.10%2B-blue)
48
+ ![Platformalar](https://img.shields.io/badge/macOS%20·%20Linux%20·%20Windows%20·%20Termux-ishlaydi-orange)
49
+ ![License](https://img.shields.io/badge/license-MIT-green)
50
+
51
+ [O'rnatish](#-ornatish) · [Sozlash](#-sozlash) · [Ishlatish](#-ishlatish) · [Muammolar](#-muammolar-va-yechimlar) · [English](#english)
52
+
53
+ </div>
54
+
55
+ ---
56
+
57
+ ## 📋 Talablar
58
+
59
+ | | |
60
+ |---|---|
61
+ | **Python** | 3.10 yoki yangiroq |
62
+ | **Internet** | AI bilan ishlash uchun |
63
+ | **Gemini API kaliti** | Bepul: [aistudio.google.com/apikey](https://aistudio.google.com/apikey) |
64
+
65
+ O'rnatiladigan paketlar faqat sof Python'da yozilgan (`typer`, `rich`), shuning uchun kompilyatsiya talab qilinmaydi va o'rnatish odatda bir daqiqadan kam vaqt oladi.
66
+
67
+ ---
68
+
69
+ ## 📦 O'rnatish
70
+
71
+ Quyida o'z tizimingizni tanlang. Har bir bo'limda buyruqlarni ketma-ket yozasiz.
72
+
73
+ ### 🍎 macOS (Terminal yoki iTerm)
74
+
75
+ **1. Python bor-yo'qligini tekshiring:**
76
+ ```bash
77
+ python3 --version
78
+ ```
79
+ Python yo'q bo'lsa, Homebrew orqali o'rnating:
80
+ ```bash
81
+ brew install python
82
+ ```
83
+
84
+ **2. 7ZON'ni o'rnating.** Tavsiya etilgan usul `pipx`, u 7ZON'ni alohida muhitga o'rnatadi:
85
+ ```bash
86
+ brew install pipx && pipx ensurepath
87
+ ```
88
+ ```bash
89
+ pipx install https://github.com/7zon-uz/7ZON-CLI/archive/refs/heads/main.zip
90
+ ```
91
+ <details><summary>pipx'siz o'rnatish</summary>
92
+
93
+ ```bash
94
+ python3 -m pip install --user https://github.com/7zon-uz/7ZON-CLI/archive/refs/heads/main.zip
95
+ ```
96
+ </details>
97
+
98
+ **3. Terminalni yopib, qayta oching** va tekshiring:
99
+ ```bash
100
+ 7zon --version
101
+ ```
102
+
103
+ ---
104
+
105
+ ### 🐧 Linux (Ubuntu, Debian, Fedora, Arch va boshqalar)
106
+
107
+ **1. Python va pipx'ni o'rnating:**
108
+
109
+ | Distributiv | Buyruq |
110
+ |---|---|
111
+ | Ubuntu / Debian / Mint | `sudo apt update && sudo apt install -y python3 python3-pip pipx` |
112
+ | Fedora | `sudo dnf install -y python3 pipx` |
113
+ | Arch / Manjaro | `sudo pacman -S python python-pipx` |
114
+
115
+ ```bash
116
+ pipx ensurepath
117
+ ```
118
+
119
+ **2. 7ZON'ni o'rnating:**
120
+ ```bash
121
+ pipx install https://github.com/7zon-uz/7ZON-CLI/archive/refs/heads/main.zip
122
+ ```
123
+
124
+ **3. Terminalni qayta oching** va tekshiring:
125
+ ```bash
126
+ 7zon --version
127
+ ```
128
+
129
+ > Linux'da parollar va tokenlar `~/.7zon/secrets.json` fayliga saqlanadi. Bu faylni faqat siz o'qiy olasiz (ruxsati `600`).
130
+
131
+ ---
132
+
133
+ ### 🪟 Windows (PowerShell yoki Windows Terminal)
134
+
135
+ **1. Python'ni o'rnating.** [python.org/downloads](https://www.python.org/downloads/) dan yuklab oling. O'rnatish oynasida **"Add python.exe to PATH"** belgisini albatta qo'ying.
136
+
137
+ Yoki PowerShell'da bitta buyruq bilan o'rnating:
138
+ ```bash
139
+ winget install --id Python.Python.3.13 -e
140
+ ```
141
+
142
+ **2. PowerShell'ni yopib, qayta oching** va 7ZON'ni o'rnating:
143
+ ```bash
144
+ py -m pip install --user https://github.com/7zon-uz/7ZON-CLI/archive/refs/heads/main.zip
145
+ ```
146
+
147
+ **3. Tekshiring:**
148
+ ```bash
149
+ 7zon --version
150
+ ```
151
+
152
+ > 💡 Eng yaxshi ko'rinish uchun **Windows Terminal**'dan foydalaning (Windows 11'da standart holda bor).
153
+ > 7ZON buyruqlarni **PowerShell**'da bajaradi, parollarni esa **Windows Credential Manager**'da saqlaydi.
154
+
155
+ ---
156
+
157
+ ### 📱 Android (Termux)
158
+
159
+ **1. Termux'ni o'rnating.** Uni [F-Droid](https://f-droid.org/packages/com.termux/) yoki [GitHub](https://github.com/termux/termux-app/releases) dan oling. Google Play'dagi versiya eskirgan.
160
+
161
+ **2. Termux'da yozing:**
162
+ ```bash
163
+ pkg update -y && pkg install -y python
164
+ ```
165
+ ```bash
166
+ pip install https://github.com/7zon-uz/7ZON-CLI/archive/refs/heads/main.zip
167
+ ```
168
+
169
+ Yoki tayyor skript bilan o'rnating:
170
+ ```bash
171
+ curl -fsSL https://raw.githubusercontent.com/7zon-uz/7ZON-CLI/main/install-termux.sh -o install-termux.sh && bash install-termux.sh
172
+ ```
173
+
174
+ **3. Tekshiring:**
175
+ ```bash
176
+ 7zon --version
177
+ ```
178
+
179
+ > 7ZON Termux'ni avtomatik taniydi: paketlarni `pkg install` bilan o'rnatadi, havolalarni `termux-open-url` bilan ochadi.
180
+ > Telefon xotirasiga kirish uchun bir marta `termux-setup-storage` buyrug'ini bering.
181
+
182
+ ---
183
+
184
+ ## 🔑 Sozlash
185
+
186
+ **1. Bepul Gemini kalitini oling:** [aistudio.google.com/apikey](https://aistudio.google.com/apikey) → **Create API key** → nusxalang.
187
+
188
+ **2. Kalitni 7ZON'ga kiriting.** Kalit yozilayotganda ekranda ko'rinmaydi, bu normal holat. Joylab, Enter bosing:
189
+ ```bash
190
+ 7zon config set-key
191
+ ```
192
+
193
+ Yoki muhit o'zgaruvchisi orqali bering:
194
+
195
+ | Tizim | Buyruq |
196
+ |---|---|
197
+ | macOS / Linux / Termux | `export GEMINI_API_KEY="kalitingiz"` |
198
+ | Windows PowerShell | `$env:GEMINI_API_KEY="kalitingiz"` |
199
+
200
+ **3. Ixtiyoriy sozlamalar:**
201
+ ```bash
202
+ 7zon config set lang en # javob tili: uz | en | ru (standart: uz)
203
+ 7zon config set model gemini-3.6-flash # boshqa model (bo'sh qoldirilsa, standart model)
204
+ 7zon config show # joriy sozlamalar
205
+ ```
206
+
207
+ <details><summary>Claude modelidan foydalanish</summary>
208
+
209
+ ```bash
210
+ pipx inject 7zon-cli anthropic # yoki: pip install "7zon-cli[claude]"
211
+ 7zon config set provider claude
212
+ 7zon config set-key # kalitni console.anthropic.com dan oling
213
+ ```
214
+ </details>
215
+
216
+ ---
217
+
218
+ ## 🚀 Ishlatish
219
+
220
+ ### Agent rejimi
221
+ ```bash
222
+ 7zon
223
+ ```
224
+ Logo chiqqandan keyin vazifani oddiy so'z bilan yozing:
225
+
226
+ ```
227
+ Siz › shu papkada calc.py va uning pytest testlarini yarat, keyin testlarni ishga tushir
228
+ Siz › ValueError qaysi fayllarda ishlatilgan?
229
+ Siz › ~/Desktop/xato.png da nima bor? tuzatib ber
230
+ Siz › git o'rnat va githubga kir
231
+ Siz › eslab qol: men pnpm ishlataman
232
+ ```
233
+
234
+ Har bir amaldan oldin 7ZON **↑/↓ strelkali menyu** orqali ruxsat so'raydi:
235
+ ```
236
+ Ruxsat berasizmi? (↑/↓ tanlash, Enter tasdiqlash)
237
+ ❯ Ruxsat
238
+ Barchasiga ruxsat, boshqa so'rama
239
+ Ruxsat emas
240
+ ```
241
+
242
+ | Chat buyrug'i | Vazifasi |
243
+ |---|---|
244
+ | `/help` | Buyruqlar ro'yxati |
245
+ | `/undo` | 7ZON qilgan oxirgi fayl o'zgarishini qaytarish |
246
+ | `/compress` | Uzun suhbatni qisqa xulosaga aylantirish (bu avtomatik ham bajariladi) |
247
+ | `/memory` | Eslab qolingan ma'lumotlar (`7ZON.md`) |
248
+ | `/clear` | Suhbatni tozalash |
249
+ | `/yolo` | Oddiy amallar uchun ruxsat so'ramaslik |
250
+ | `/exit` | Chiqish |
251
+
252
+ ### Tezkor buyruqlar
253
+ | Buyruq | Vazifasi |
254
+ |---|---|
255
+ | `7zon ask "3000-portni band qilgan jarayonni o'chir"` | So'rovdan bitta buyruq yaratadi va tasdiqlasangiz bajaradi |
256
+ | `7zon fix -- npm run build` | Buyruqni ishga tushiradi, xato bo'lsa sababini va yechimini aytadi |
257
+ | `python app.py 2>&1 \| 7zon fix` | Tayyor xato matnini tahlil qiladi |
258
+ | `7zon explain "tar -xzvf a.tar.gz"` | Buyruqni qismlarga bo'lib tushuntiradi |
259
+ | `7zon -p "testlarni ishga tushir" --yolo` | Suhbatsiz bajaradi (skriptlar va CI uchun) |
260
+ | `7zon secret add GITHUB_TOKEN` | Parol yoki tokenni xavfsiz saqlaydi |
261
+
262
+ ### Imkoniyatlar
263
+ - 🛠️ **Asboblar:** buyruq bajarish, fayl o'qish, yozish va tahrirlash, `glob` va `grep` qidiruvi, rasm va PDF ko'rish, internet sahifalarini o'qish.
264
+ - 🧠 **Xotira:** `7ZON.md` faylida saqlanadi. `AGENTS.md`, `CLAUDE.md` va `GEMINI.md` fayllarini ham o'qiydi.
265
+ - 🔐 **Maxfiy ma'lumotlar:** parol yashirin kiritiladi va AI uni ko'rmaydi. Natijada qiymat `****` bo'lib yashiriladi.
266
+ - 🌐 **Kirish:** GitHub, Vercel, Firebase va boshqa xizmatlarga rasmiy CLI orqali brauzerda kiradi.
267
+ - 📸 **Instagram:** rasmiy API orqali post, Reels, story, statistika va izohlar bilan ishlaydi.
268
+ - 🇺🇿 **Tillar:** o'zbek, ingliz va rus tillarida javob beradi.
269
+
270
+ ---
271
+
272
+ ## 🛡️ Xavfsizlik
273
+
274
+ - Buyruq va fayl o'zgarishlari **faqat sizning ruxsatingiz bilan** bajariladi.
275
+ - Xavfli buyruqlarda (`rm -rf /`, `mkfs`, `curl | sh`, `git push --force` va h.k.) qizil ogohlantirish chiqadi. Standart javob "Ruxsat emas" bo'ladi va bu buyruqlar YOLO rejimida ham so'raladi.
276
+ - Parollar quyidagi joylarda saqlanadi:
277
+
278
+ | Tizim | Saqlash joyi |
279
+ |---|---|
280
+ | macOS | **Keychain** |
281
+ | Windows | **Credential Manager** |
282
+ | Linux / Termux | `~/.7zon/secrets.json` (ruxsati `600`) |
283
+
284
+ - AI'ga faqat OS nomi, shell, papka nomi va loyiha fayllarining **nomlari** yuboriladi. Fayl mazmuni faqat siz so'raganda yuboriladi.
285
+ - `/undo` buyrug'i 7ZON qilgan fayl o'zgarishlarini qaytaradi.
286
+
287
+ ---
288
+
289
+ ## 🔄 Yangilash va o'chirish
290
+
291
+ | | Yangilash | O'chirish |
292
+ |---|---|---|
293
+ | pipx (macOS / Linux) | `pipx install --force https://github.com/7zon-uz/7ZON-CLI/archive/refs/heads/main.zip` | `pipx uninstall 7zon-cli` |
294
+ | Windows | `py -m pip install --user --upgrade https://github.com/7zon-uz/7ZON-CLI/archive/refs/heads/main.zip` | `py -m pip uninstall 7zon-cli` |
295
+ | Termux | `pip install --upgrade https://github.com/7zon-uz/7ZON-CLI/archive/refs/heads/main.zip` | `pip uninstall 7zon-cli` |
296
+
297
+ Sozlamalar `~/.config/7zon/` papkasida, ishchi fayllar esa `~/.7zon/` papkasida turadi. 7ZON'ni butunlay o'chirish uchun bu papkalarni ham o'chiring.
298
+
299
+ ---
300
+
301
+ ## 🧯 Muammolar va yechimlar
302
+
303
+ | Muammo | Yechim |
304
+ |---|---|
305
+ | `7zon: command not found` | Terminalni yopib qayta oching. pipx bilan o'rnatgan bo'lsangiz, `pipx ensurepath` ni bajaring |
306
+ | Windows: `'7zon' is not recognized` | Python o'rnatilayotganda **Add to PATH** belgilanmagan. Python'ni qayta o'rnating yoki `py -m zon7` deb ishga tushiring |
307
+ | `error: externally-managed-environment` | `pip` o'rniga `pipx` dan foydalaning |
308
+ | Termux: o'rnatish uzoq davom etadi yoki xato beradi | Avval `pkg update -y && pkg upgrade -y` ni bajaring, keyin qayta urinib ko'ring |
309
+ | `Gemini bepul tarifining kunlik limiti tugadi` | Bepul tarifda har bir model uchun kunlik limit bor. Ertaga urinib ko'ring yoki AI Studio'da billing ulang |
310
+ | `Gemini serveri hozir band (503)` | 7ZON o'zi boshqa modelga o'tadi. Bir daqiqadan keyin yana urinib ko'ring |
311
+ | `API kalit noto'g'ri` | `7zon config set-key` bilan kalitni qaytadan kiriting |
312
+
313
+ ---
314
+
315
+ ## 🤝 Hissa qo'shish
316
+
317
+ ```bash
318
+ git clone https://github.com/7zon-uz/7ZON-CLI && cd 7ZON-CLI
319
+ python3 -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\Activate.ps1
320
+ pip install -e ".[dev]"
321
+ pytest
322
+ ```
323
+
324
+ Xato topsangiz yoki taklifingiz bo'lsa, [Issue oching](https://github.com/7zon-uz/7ZON-CLI/issues).
325
+
326
+ ---
327
+
328
+ ## English
329
+
330
+ **7ZON CLI** is an AI agent for your terminal. Describe a task in plain words (Uzbek, English or Russian) and it runs commands, writes and edits files, searches your project, looks at images and PDFs, and fixes errors. It asks before every action using an arrow-key menu, and secrets are typed into a hidden prompt the AI never sees. It works on macOS, Linux, Windows (PowerShell) and Android (Termux), and needs only pure-Python dependencies.
331
+
332
+ ```bash
333
+ pipx install https://github.com/7zon-uz/7ZON-CLI/archive/refs/heads/main.zip # Windows: py -m pip install --user <same URL>
334
+ 7zon config set-key # free Gemini key: https://aistudio.google.com/apikey
335
+ 7zon config set lang en
336
+ 7zon # start the agent
337
+ ```
338
+
339
+ ## License
340
+
341
+ [MIT](LICENSE) © 7ZON Team
@@ -0,0 +1,24 @@
1
+ zon7/__init__.py,sha256=m6kyaNpwBcP1XYcqrelX2oS3PJuOnElOcRdBa9pEb8c,22
2
+ zon7/__main__.py,sha256=0hqCHL3cuxz_yM4PFKH8Hj7fIj0PmJde4Gfi-W2mZuM,34
3
+ zon7/ai.py,sha256=QbGwQPO1MEkvEJ8RkiswQP4KCXyh4F_Sl9koSsWgePE,1516
4
+ zon7/banner.py,sha256=W0_l2UZQyNIvEGBt4Or-lLLtX4Yq7kvgLEI7bMUU10I,2656
5
+ zon7/cli.py,sha256=2-eiITo0elZ7k92LGpkFRoEIKgUlZpvns_lfU9acgpo,19241
6
+ zon7/common.py,sha256=CCaUlRTpEefnO2YQU6vU_sLMmJBbV328TURIWhzFp4w,444
7
+ zon7/config.py,sha256=ImxHIrHKu-absB-H48Ym1sXf565-lRY5HfCnBZfxrd8,2411
8
+ zon7/context.py,sha256=xEB1cCfS7PPxWbjz77nxYfoZ_-_yEQvxBFlqd1h-SEk,3475
9
+ zon7/instagram.py,sha256=Pxa9JnZ6f6FqPl1drZCf4n7xKmeVy3hi_CvAxex2XHk,9810
10
+ zon7/memory.py,sha256=cl1y299n1nEG-ZMIk5oESRUlMPRI-aJqxZBR4Z8Lixw,2227
11
+ zon7/menu.py,sha256=I1xO6uoj_4T_cQhELU0AY6L-0va80Mh6-cDjPnMTMDI,4910
12
+ zon7/prompts.py,sha256=kBlXSEVSc8G8WNWOfmG2s7BRMVqHi7bbJZaSjWLpxEg,13068
13
+ zon7/safety.py,sha256=fOwE1V4XUYE77CVCkYvF2E7ThZhHvP-Gf8jPON-RWt8,2799
14
+ zon7/secrets.py,sha256=YxW88oc-98BQId-Um1VpyCa3NjU_RnoGR0zJD5cpyew,3622
15
+ zon7/shell.py,sha256=RvtQVTC1yyBJNrywSeMN5E-ZKbgu_LdkjbVfB3La8cU,2466
16
+ zon7/tools.py,sha256=Rtqh-cDlRCrCabBGLtPhNcCaD297H0xjmD6A_DUfuME,40418
17
+ zon7/providers/__init__.py,sha256=NkpcZ6z7xPUWLxIg2Ac_9E9DnmfZMJDY8UgFlnsefUQ,24
18
+ zon7/providers/claude.py,sha256=CzS2Bf56whFT5RYkWSXEejWPS-3kEfMnrDpliGcwkVE,9229
19
+ zon7/providers/gemini.py,sha256=Cn8ASiHpuO1xQEaf-PiPn23v9JnoaHO8kg5Klbxy0NQ,15701
20
+ 7zon_cli-0.2.2.dist-info/METADATA,sha256=jZERL4ri60lN6QSZXR2F-BMKMUI4sMNHZfFyFuf4F-w,12189
21
+ 7zon_cli-0.2.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
22
+ 7zon_cli-0.2.2.dist-info/entry_points.txt,sha256=L1zDg9XJyR3wgQ7p53C2QK7OY5OmHbNr9j_9jvJN5cQ,39
23
+ 7zon_cli-0.2.2.dist-info/licenses/LICENSE,sha256=M11EByscLdoNyzaep0ZqLHF4dS82jeDGBQx4ItOdB4A,1066
24
+ 7zon_cli-0.2.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ 7zon = zon7.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 7ZON Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
zon7/__init__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "0.2.2"
zon7/__main__.py ADDED
@@ -0,0 +1,3 @@
1
+ from zon7.cli import main
2
+
3
+ main()
zon7/ai.py ADDED
@@ -0,0 +1,45 @@
1
+ """AI provayderini tanlaydigan qatlam: gemini (standart) yoki claude."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ from collections.abc import Callable
7
+ from types import ModuleType
8
+ from typing import Any
9
+
10
+ from zon7.common import COMMAND_SCHEMA, AIError
11
+
12
+ __all__ = ["AIError", "COMMAND_SCHEMA", "PROVIDERS", "provider", "suggest_command", "stream_answer", "make_agent"]
13
+
14
+ PROVIDERS = ("gemini", "claude")
15
+
16
+
17
+ def provider(cfg: dict[str, Any]) -> ModuleType:
18
+ name = cfg.get("provider", "gemini")
19
+ if name not in PROVIDERS:
20
+ raise AIError(f"Noma'lum provayder: {name}. Mavjudlari: {', '.join(PROVIDERS)}")
21
+ # Faqat tanlangan provayderning kodi yuklanadi
22
+ try:
23
+ return importlib.import_module(f"zon7.providers.{name}")
24
+ except ImportError:
25
+ raise AIError(
26
+ f"{name} provayderi uchun qo'shimcha paket kerak: pip install '7zon-cli[{name}]'"
27
+ ) from None
28
+
29
+
30
+ def suggest_command(request: str, env: str, system: str, cfg: dict[str, Any]) -> dict[str, str]:
31
+ return provider(cfg).suggest_command(request, env, system, cfg)
32
+
33
+
34
+ def stream_answer(
35
+ system: str,
36
+ messages: list[dict[str, Any]],
37
+ cfg: dict[str, Any],
38
+ on_text: Callable[[str], None],
39
+ ) -> str:
40
+ return provider(cfg).stream_answer(system, messages, cfg, on_text)
41
+
42
+
43
+ def make_agent(system: str, cfg: dict[str, Any], tool_specs: list[dict[str, Any]]) -> Any:
44
+ """Asboblardan foydalanadigan suhbat agenti (chat rejimi uchun)."""
45
+ return provider(cfg).Agent(system, cfg, tool_specs)
zon7/banner.py ADDED
@@ -0,0 +1,74 @@
1
+ """7ZON logosi: to'q sariq "7" va ostida oq chiziq (terminal uchun piksel uslubida)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from typing import Any
7
+
8
+ from rich.console import Console
9
+ from rich.table import Table
10
+ from rich.text import Text
11
+
12
+ # Logo shakli: "7" o'ng yuqoridan chap pastga qiya tushadi.
13
+ # Diagonal chap chetda (0-ustun) tugaydi va oq chiziq aynan shu joydan boshlanib,
14
+ # "7" ga yopishgan holda uning yuqori qismi bilan bir xil kenglikda davom etadi.
15
+ LOGO_7 = [
16
+ "████████████",
17
+ " ████",
18
+ " ████ ",
19
+ " ████ ",
20
+ " ████ ",
21
+ "████ ",
22
+ ]
23
+ LOGO_BAR = "████████████"
24
+
25
+ # Logodagi kabi yorqin sariqdan to'q sariqqa o'tuvchi rang
26
+ ORANGE = ["#FFC76B", "#FFBA52", "#FFAC3C", "#F99D27", "#F2901A", "#EA840F"]
27
+ WHITE = "#F2F4F8"
28
+ NAVY_DIM = "#7C8DB5"
29
+
30
+
31
+ def logo() -> Text:
32
+ text = Text()
33
+ for row, color in zip(LOGO_7, ORANGE):
34
+ text.append(row + "\n", style=f"bold {color}")
35
+ text.append(LOGO_BAR, style=f"bold {WHITE}")
36
+ return text
37
+
38
+
39
+ def status_line(cfg: dict[str, Any], provider_mod: Any) -> Text:
40
+ has_key = any(os.environ.get(n) for n in provider_mod.ENV_KEYS) or bool(
41
+ cfg.get({"gemini": "gemini_api_key", "claude": "anthropic_api_key"}[cfg["provider"]])
42
+ )
43
+ line = Text()
44
+ if has_key:
45
+ line.append("● ", style="bold green")
46
+ line.append("7ZON AI · tayyor", style=NAVY_DIM)
47
+ else:
48
+ line.append("● ", style="bold red")
49
+ line.append("API kalit ulanmagan: ", style=NAVY_DIM)
50
+ line.append("7zon config set-key", style="bold cyan")
51
+ return line
52
+
53
+
54
+ def render(console: Console, version: str, cfg: dict[str, Any], provider_mod: Any) -> None:
55
+ info = Text()
56
+ info.append("\n7ZON CLI", style=f"bold {WHITE}")
57
+ info.append(f" v{version}\n\n", style=NAVY_DIM)
58
+ info.append("Terminaldagi AI yordamchingiz\n", style=ORANGE[1])
59
+ info.append_text(status_line(cfg, provider_mod))
60
+
61
+ grid = Table.grid(padding=(0, 4))
62
+ grid.add_column(no_wrap=True)
63
+ grid.add_column()
64
+ grid.add_row(logo(), info)
65
+ console.print()
66
+ console.print(grid)
67
+ console.print()
68
+
69
+
70
+ def tips(console: Console) -> None:
71
+ console.print("[bold]Boshlash uchun:[/]")
72
+ console.print(f" [{ORANGE[2]}]1.[/] Savolingizni yozing, masalan: [dim]docker konteynerlarni qanday tozalayman?[/]")
73
+ console.print(f" [{ORANGE[2]}]2.[/] Buyruq kerak bo'lsa: [cyan]7zon ask \"...\"[/] Xato bo'lsa: [cyan]7zon fix -- <buyruq>[/]")
74
+ console.print(f" [{ORANGE[2]}]3.[/] Chat buyruqlari: [cyan]/help[/] Chiqish: [cyan]exit[/] yoki Ctrl+D")