anixcode 0.11.0__tar.gz → 0.12.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.
- {anixcode-0.11.0 → anixcode-0.12.0}/PKG-INFO +1 -1
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/__init__.py +1 -1
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/i18n_en.py +118 -0
- anixcode-0.12.0/anixcode/providers.py +90 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tui/app.py +135 -17
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tui/app.tcss +92 -1
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tui/screens.py +126 -10
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tui/widgets.py +87 -6
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode.egg-info/PKG-INFO +1 -1
- {anixcode-0.11.0 → anixcode-0.12.0}/pyproject.toml +1 -1
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_v011_features.py +19 -1
- anixcode-0.11.0/anixcode/providers.py +0 -71
- {anixcode-0.11.0 → anixcode-0.12.0}/LICENSE +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/README.md +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/__main__.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/agent.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/airpc.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/browser.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/checkpoints.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/cli.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/commands.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/compaction.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/danger.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/i18n.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/images.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/llm.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/mcp.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/mentions.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/projects.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/prompts.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/settings.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/storage.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tools/__init__.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tools/base.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tools/browser.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tools/files.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tools/search.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tools/shell.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tools/todo.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tools/web.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tui/__init__.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode/tui/anim.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode.egg-info/SOURCES.txt +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode.egg-info/dependency_links.txt +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode.egg-info/entry_points.txt +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode.egg-info/requires.txt +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/anixcode.egg-info/top_level.txt +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/setup.cfg +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_agent.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_commands.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_i18n.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_images.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_llm.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_mcp.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_projects.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_providers.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_reliability.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_safety_mentions.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_settings.py +0 -0
- {anixcode-0.11.0 → anixcode-0.12.0}/tests/test_tools.py +0 -0
|
@@ -408,4 +408,122 @@ EN: dict[str, str] = {
|
|
|
408
408
|
'🧭 Встроенный headless-браузер — введите адрес или /browser <url>':
|
|
409
409
|
'🧭 Built-in headless browser — enter a URL or /browser <url>',
|
|
410
410
|
'🧭 Загружаю {0}…': '🧭 Loading {0}…',
|
|
411
|
+
# v0.12: beginner-friendly TUI, welcome dashboard, quick bar, visual menu, 3-step setup
|
|
412
|
+
'\nНажмите Enter — разрешить · Esc — отклонить · или напишите словами, как сделать иначе':
|
|
413
|
+
'\nPress Enter — allow · Esc — deny · or type in plain words what to do instead',
|
|
414
|
+
' Всегда в сессии ': ' Always this session ',
|
|
415
|
+
' ☰ Меню ': ' ☰ Menu ',
|
|
416
|
+
' 🧭 Браузер ': ' 🧭 Browser ',
|
|
417
|
+
'1. Модель: {0}': '1. Model: {0}',
|
|
418
|
+
'1. Подключить модель →': '1. Connect a model →',
|
|
419
|
+
'1. Провайдер': '1. Provider',
|
|
420
|
+
'2. API-ключ': '2. API key',
|
|
421
|
+
'2. Выбрать папку проекта →': '2. Pick a project folder →',
|
|
422
|
+
'2. Проект: {0}': '2. Project: {0}',
|
|
423
|
+
'3. Изучить проект (/init)': '3. Study project (/init)',
|
|
424
|
+
'3. Модель (уже выбрана рекомендуемая)': '3. Model (recommended default pre-filled)',
|
|
425
|
+
'3. Правила: AGENTS.md': '3. Rules: AGENTS.md',
|
|
426
|
+
'? Помощь': '? Help',
|
|
427
|
+
'Enter — разрешить · Esc — отклонить · или напишите словами, как сделать иначе…':
|
|
428
|
+
'Enter — allow · Esc — deny · or type what to do instead…',
|
|
429
|
+
'GPT-4.1 / GPT-4o / o3 — стабильное качество и быстрые правки':
|
|
430
|
+
'GPT-4.1 / GPT-4o / o3 — reliable quality and fast edits',
|
|
431
|
+
'Агент работает… Напишите следующее сообщение (в очередь) или /btw <вопрос>…':
|
|
432
|
+
'Agent is working… Type your next message (queued) or /btw <question>…',
|
|
433
|
+
'Адрес сервера (обычно менять не нужно)': 'Server URL (usually no need to change)',
|
|
434
|
+
'Бесплатно и офлайн на вашем ПК — нажмите «Список моделей»':
|
|
435
|
+
'Free & offline on your PC — click “Model list”',
|
|
436
|
+
'Быстрый старт (нажмите на любой шаг):': 'Quick start (click any step):',
|
|
437
|
+
'Где взять ключ бесплатно/в кабинете: {0}': 'Where to get an API key: {0}',
|
|
438
|
+
'ИИ-помощник для кода: просто опишите задачу обычными словами или нажмите кнопку ниже.':
|
|
439
|
+
'AI coding assistant: describe your task in plain words or click a button below.',
|
|
440
|
+
'Изменить файл': 'Edit file',
|
|
441
|
+
'Ключ не нужен — работает локально на вашем компьютере': 'No API key needed — runs locally on your machine',
|
|
442
|
+
'Локальные модели из LM Studio — ключ не нужен': 'Local models from LM Studio — no key needed',
|
|
443
|
+
'Локальный роутер ANIX — ключ не нужен': 'Local ANIX Router — no key needed',
|
|
444
|
+
'Локальный роутер бесплатных API — ключ не нужен': 'Local free-tier API router — no key needed',
|
|
445
|
+
'Любой совместимый сервер или прокси с адресом /v1': 'Any OpenAI-compatible server or proxy with a /v1 URL',
|
|
446
|
+
'Мгновенная скорость ответов, есть бесплатный лимит': 'Ultra-fast responses with a generous free tier',
|
|
447
|
+
'Меню': 'Menu',
|
|
448
|
+
'Модели Grok с большим контекстом': 'Grok models with a large context window',
|
|
449
|
+
'Напишите задачу (Enter — отправить · / — команды · @ — файлы · Alt+V — скриншот)…':
|
|
450
|
+
'Describe a task (Enter — send · / — commands · @ — files · Alt+V — screenshot)…',
|
|
451
|
+
'Нативный API с автоматическим кэшированием промптов (экономит токены)':
|
|
452
|
+
'Native API with automatic prompt caching (saves tokens & cost)',
|
|
453
|
+
'Недорого и отлично подходит для старта с кодом': 'Affordable and great for getting started with code',
|
|
454
|
+
'Огромный контекст 1M токенов, есть бесплатный тариф в AI Studio':
|
|
455
|
+
'Huge 1M token context with a free tier in AI Studio',
|
|
456
|
+
'Один ключ для сотен моделей (Claude, GPT, DeepSeek, бесплатные модели)':
|
|
457
|
+
'One key for hundreds of models (Claude, GPT, DeepSeek, free models)',
|
|
458
|
+
'Откройте любой сайт или локальное приложение (например localhost:3000).\nВсё открывается прямо здесь — внешний браузер не всплывёт.':
|
|
459
|
+
'Open any website or local app (e.g. localhost:3000).\nEverything renders right here — no external browser pops up.',
|
|
460
|
+
'Подключение ИИ-модели': 'Connect an AI Model',
|
|
461
|
+
'Поиск действия (например: браузер, цель, тест, тема, откат)…':
|
|
462
|
+
'Search actions (e.g. browser, goal, test, theme, undo)…',
|
|
463
|
+
'Популярные действия — просто нажмите или напишите задачу внизу:':
|
|
464
|
+
'Popular actions — click one or type your task below:',
|
|
465
|
+
'Проверить связь': 'Test connection',
|
|
466
|
+
'Проверяю подключение…': 'Testing connection…',
|
|
467
|
+
'Прочитать секретный файл': 'Read sensitive file',
|
|
468
|
+
'Сохранить и начать': 'Save & start',
|
|
469
|
+
'Шаг 1: выберите провайдера → Шаг 2: вставьте ключ (если нужен) → Шаг 3: нажмите «Сохранить».':
|
|
470
|
+
'Step 1: pick a provider → Step 2: paste your key (if needed) → Step 3: click “Save & start”.',
|
|
471
|
+
'автономная работа до полной проверки': 'autonomous work until fully verified',
|
|
472
|
+
'агент разберёт код и создаст AGENTS.md': 'study the project and create AGENTS.md',
|
|
473
|
+
'вернуть файлы к состоянию до ответа': 'revert files to before the last answer',
|
|
474
|
+
'вернуться к предыдущему диалогу': 'resume a previous conversation',
|
|
475
|
+
'включить/выключить запросы подтверждений': 'toggle approval prompts on/off',
|
|
476
|
+
'все горячие клавиши и команды': 'all shortcuts and commands',
|
|
477
|
+
'вставьте ваш API-ключ (sk-…)': 'paste your API key (sk-…)',
|
|
478
|
+
'выбрать провайдера, ключ и модель': 'pick provider, API key, and model',
|
|
479
|
+
'найти тесты, прогнать и починить': 'find, run, and fix failing tests',
|
|
480
|
+
'начать чистый диалог в этом проекте': 'start a fresh chat in this project',
|
|
481
|
+
'не обязателен для локальной модели': 'optional for local models',
|
|
482
|
+
'открыть папку или склонировать с GitHub': 'open a folder or clone from GitHub',
|
|
483
|
+
'открыть сайт/localhost прямо в окне': 'open a site or localhost right inside the app',
|
|
484
|
+
'переключить Русский / English': 'switch between Russian & English',
|
|
485
|
+
'повторить откаченные правки': 're-apply reverted edits',
|
|
486
|
+
'подготовить и закоммитить изменения': 'stage and commit changes cleanly',
|
|
487
|
+
'поиск багов и рисков в текущем коде': 'check uncommitted changes for bugs and risks',
|
|
488
|
+
'править код или только читать/планировать': 'edit code or read/plan only',
|
|
489
|
+
'прикрепить изображение из буфера обмена': 'attach an image from clipboard',
|
|
490
|
+
'проверить модель, git, ripgrep, браузер': 'check model, git, ripgrep, and browser',
|
|
491
|
+
'сменить цвета интерфейса с предпросмотром': 'change interface colors with live preview',
|
|
492
|
+
'спросить без изменения истории диалога': 'ask without modifying conversation history',
|
|
493
|
+
'↑↓ или клик — выбрать · Enter — выполнить · Esc — закрыть':
|
|
494
|
+
'↑↓ or click — pick · Enter — run · Esc — close',
|
|
495
|
+
'↶ Откат': '↶ Undo',
|
|
496
|
+
'↶ Откатить правки': '↶ Undo edits',
|
|
497
|
+
'↷ Вернуть правки': '↷ Redo edits',
|
|
498
|
+
'⌘ Команды': '⌘ Commands',
|
|
499
|
+
'☰ Быстрое меню действий': '☰ Quick Action Menu',
|
|
500
|
+
'⚠ Модель не подключена — нажмите здесь': '⚠ Model not connected — click here',
|
|
501
|
+
'✎ Режим Build / Plan': '✎ Build / Plan mode',
|
|
502
|
+
'✓ Подключение работает! Найдено моделей: {0}. Можно нажимать «Сохранить и начать».':
|
|
503
|
+
'✓ Connection works! Found {0} models. Click “Save & start”.',
|
|
504
|
+
'✨ Новая сессия': '✨ New session',
|
|
505
|
+
'❓ Как пользоваться': '❓ How to use',
|
|
506
|
+
'❓ Справка': '❓ Help',
|
|
507
|
+
'🌐 Сменить язык': '🌐 Change language',
|
|
508
|
+
'🎨 Выбрать тему': '🎨 Pick theme',
|
|
509
|
+
'🎨 Сменить тему': '🎨 Change theme',
|
|
510
|
+
'🎯 Поставить цель': '🎯 Set a goal',
|
|
511
|
+
'🎯 Цель': '🎯 Goal',
|
|
512
|
+
'🐛 Проверить изменения': '🐛 Review changes',
|
|
513
|
+
'🐛 Проверить код': '🐛 Review code',
|
|
514
|
+
'💬 Быстрый вопрос': '💬 Quick question',
|
|
515
|
+
'💬 Вопрос': '💬 Ask /btw',
|
|
516
|
+
'💾 Сделать коммит': '💾 Commit changes',
|
|
517
|
+
'📁 Файл': '📁 File',
|
|
518
|
+
'📂 Выбрать проект': '📂 Switch project',
|
|
519
|
+
'🔍 Изучить проект': '🔍 Study project',
|
|
520
|
+
'🔓 Полный доступ': '🔓 Full access',
|
|
521
|
+
'🕘 Прошлые сессии': '🕘 Past sessions',
|
|
522
|
+
'🖼 Вставить скриншот': '🖼 Paste screenshot',
|
|
523
|
+
'🖼 Фото': '🖼 Image',
|
|
524
|
+
'🤖 Подключить модель': '🤖 Connect model',
|
|
525
|
+
'🧪 Запустить тесты': '🧪 Run tests',
|
|
526
|
+
'🧭 Встроенный браузер': '🧭 Built-in browser',
|
|
527
|
+
'🧭 Открыть браузер': '🧭 Open browser',
|
|
528
|
+
'🩺 Проверка системы': '🩺 System check',
|
|
411
529
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""Known OpenAI-compatible providers, plus the user's own ones (stored in settings.json)."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
from .i18n import tr
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import TYPE_CHECKING
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from .settings import Settings
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class Provider:
|
|
15
|
+
id: str
|
|
16
|
+
name: str
|
|
17
|
+
base_url: str
|
|
18
|
+
needs_key: bool = True
|
|
19
|
+
default_model: str = ""
|
|
20
|
+
key_url: str = "" # where to get a key
|
|
21
|
+
hint: str = "" # short plain-language note for beginners
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def is_user(self) -> bool:
|
|
25
|
+
return self.id.startswith("user:")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
PROVIDERS: tuple[Provider, ...] = (
|
|
29
|
+
Provider("deepseek", "DeepSeek", "https://api.deepseek.com/v1", default_model="deepseek-chat",
|
|
30
|
+
key_url="https://platform.deepseek.com/api_keys",
|
|
31
|
+
hint=tr("Недорого и отлично подходит для старта с кодом")),
|
|
32
|
+
Provider("openai", "OpenAI", "https://api.openai.com/v1", default_model="gpt-4.1",
|
|
33
|
+
key_url="https://platform.openai.com/api-keys",
|
|
34
|
+
hint=tr("GPT-4.1 / GPT-4o / o3 — стабильное качество и быстрые правки")),
|
|
35
|
+
Provider("anthropic", "Anthropic (Claude)", "https://api.anthropic.com/v1/",
|
|
36
|
+
default_model="claude-sonnet-4-20250514",
|
|
37
|
+
key_url="https://console.anthropic.com/settings/keys",
|
|
38
|
+
hint=tr("Нативный API с автоматическим кэшированием промптов (экономит токены)")),
|
|
39
|
+
Provider("gemini", "Google Gemini", "https://generativelanguage.googleapis.com/v1beta/openai/",
|
|
40
|
+
default_model="gemini-2.5-flash",
|
|
41
|
+
key_url="https://aistudio.google.com/apikey",
|
|
42
|
+
hint=tr("Огромный контекст 1M токенов, есть бесплатный тариф в AI Studio")),
|
|
43
|
+
Provider("groq", "Groq", "https://api.groq.com/openai/v1", default_model="llama-3.3-70b-versatile",
|
|
44
|
+
key_url="https://console.groq.com/keys",
|
|
45
|
+
hint=tr("Мгновенная скорость ответов, есть бесплатный лимит")),
|
|
46
|
+
Provider("openrouter", "OpenRouter", "https://openrouter.ai/api/v1", default_model="anthropic/claude-sonnet-4",
|
|
47
|
+
key_url="https://openrouter.ai/keys",
|
|
48
|
+
hint=tr("Один ключ для сотен моделей (Claude, GPT, DeepSeek, бесплатные модели)")),
|
|
49
|
+
Provider("xai", "xAI (Grok)", "https://api.x.ai/v1", default_model="grok-3",
|
|
50
|
+
key_url="https://console.x.ai",
|
|
51
|
+
hint=tr("Модели Grok с большим контекстом")),
|
|
52
|
+
Provider("anix", tr("ANIX Router (локально)"), "http://localhost:3001/v1", needs_key=False,
|
|
53
|
+
hint=tr("Локальный роутер ANIX — ключ не нужен")),
|
|
54
|
+
Provider("zero-bill", tr("Zero-Bill Router (локально)"), "http://localhost:8787/v1", needs_key=False,
|
|
55
|
+
hint=tr("Локальный роутер бесплатных API — ключ не нужен")),
|
|
56
|
+
Provider("ollama", tr("Ollama (локально)"), "http://localhost:11434/v1", needs_key=False,
|
|
57
|
+
default_model="qwen2.5-coder:7b",
|
|
58
|
+
hint=tr("Бесплатно и офлайн на вашем ПК — нажмите «Список моделей»")),
|
|
59
|
+
Provider("lmstudio", tr("LM Studio (локально)"), "http://localhost:1234/v1", needs_key=False,
|
|
60
|
+
hint=tr("Локальные модели из LM Studio — ключ не нужен")),
|
|
61
|
+
Provider("custom", tr("Свой сервер (OpenAI-совместимый)"), "", needs_key=False,
|
|
62
|
+
hint=tr("Любой совместимый сервер или прокси с адресом /v1")),
|
|
63
|
+
)
|
|
64
|
+
BY_ID = {p.id: p for p in PROVIDERS}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def user_providers(settings: Settings | None) -> list[Provider]:
|
|
68
|
+
if settings is None:
|
|
69
|
+
return []
|
|
70
|
+
return [Provider(d["id"], d["name"], d["base_url"], needs_key=False) for d in settings.custom_providers]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def all_providers(settings: Settings | None) -> list[Provider]:
|
|
74
|
+
"""The user's own providers first, then the built-in ones."""
|
|
75
|
+
return [*user_providers(settings), *PROVIDERS]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def get(provider_id: str, settings: Settings | None = None) -> Provider:
|
|
79
|
+
for p in user_providers(settings):
|
|
80
|
+
if p.id == provider_id:
|
|
81
|
+
return p
|
|
82
|
+
return BY_ID.get(provider_id) or BY_ID["custom"]
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def make_id(name: str, existing: set[str]) -> str:
|
|
86
|
+
slug = re.sub(r"[^a-z0-9]+", "-", name.lower()).strip("-") or "provider"
|
|
87
|
+
candidate, n = f"user:{slug}", 2
|
|
88
|
+
while candidate in existing:
|
|
89
|
+
candidate, n = f"user:{slug}-{n}", n + 1
|
|
90
|
+
return candidate
|
|
@@ -37,10 +37,10 @@ from ..settings import Credentials, Settings, config_dir, load_auth, load_projec
|
|
|
37
37
|
from ..storage import Session, Store
|
|
38
38
|
from ..tools import ToolContext, ToolResult, default_tools
|
|
39
39
|
from .anim import THEME_LABELS, ActivityIndicator, AnimatedLogo, Gradient, make_themes, palette
|
|
40
|
-
from .screens import HelpScreen, ProjectScreen, SessionsScreen, SetupScreen, ThemeScreen
|
|
40
|
+
from .screens import HelpScreen, ProjectScreen, QuickMenuScreen, SessionsScreen, SetupScreen, ThemeScreen
|
|
41
41
|
from .widgets import (
|
|
42
42
|
AssistantMessage, AttachmentBar, BrowserPane, BtwCard, Chip, ErrorMessage, MentionList, Notice, PermissionBar,
|
|
43
|
-
PromptInput, ReasoningBlock, TodoBar, ToolCard, UserMessage,
|
|
43
|
+
PromptInput, QuickActionBar, ReasoningBlock, TodoBar, ToolCard, UserMessage, WelcomePanel,
|
|
44
44
|
)
|
|
45
45
|
|
|
46
46
|
def _tokens(n: int) -> str:
|
|
@@ -68,6 +68,7 @@ class AnixApp(App):
|
|
|
68
68
|
Binding("ctrl+n", "new_session", tr("Новая"), show=False),
|
|
69
69
|
Binding("ctrl+s", "sessions", tr("Сессии"), show=False),
|
|
70
70
|
Binding("ctrl+t", "cycle_theme", tr("Тема"), show=False),
|
|
71
|
+
Binding("ctrl+k", "quick_menu", tr("Меню"), priority=True, show=False),
|
|
71
72
|
Binding("ctrl+b", "toggle_browser", tr("Браузер"), show=False),
|
|
72
73
|
Binding("alt+v", "paste_image", tr("Вставить фото"), priority=True, show=False),
|
|
73
74
|
Binding("f1", "help", tr("Помощь"), show=False),
|
|
@@ -102,14 +103,15 @@ class AnixApp(App):
|
|
|
102
103
|
def compose(self) -> ComposeResult:
|
|
103
104
|
with Horizontal(id="header"):
|
|
104
105
|
yield Brand(id="brand")
|
|
105
|
-
yield Chip("
|
|
106
|
-
yield
|
|
106
|
+
yield Chip(tr(" ☰ Меню "), self.action_quick_menu, id="menu-chip")
|
|
107
|
+
yield Chip(tr(" 🧭 Браузер "), self.action_toggle_browser, id="browser-chip")
|
|
108
|
+
yield Chip("BUILD", self.action_toggle_mode, id="mode")
|
|
107
109
|
with Horizontal(id="workspace"):
|
|
108
110
|
with VerticalScroll(id="chat"):
|
|
109
111
|
yield self._welcome()
|
|
110
112
|
yield BrowserPane(
|
|
111
113
|
self._browser_open_url, self._browser_back, self._browser_reload, self._browser_hide,
|
|
112
|
-
id="browser-pane",
|
|
114
|
+
on_click_link=self._browser_open_url, id="browser-pane",
|
|
113
115
|
)
|
|
114
116
|
with Vertical(id="composer"):
|
|
115
117
|
yield TodoBar(id="todos")
|
|
@@ -117,18 +119,69 @@ class AnixApp(App):
|
|
|
117
119
|
yield PermissionBar(self._resolve_permission, id="permission")
|
|
118
120
|
yield AttachmentBar(self._remove_image, id="attachments")
|
|
119
121
|
yield MentionList(id="mentions")
|
|
122
|
+
yield QuickActionBar([
|
|
123
|
+
(tr("⌘ Команды"), lambda: self._prefill("/")),
|
|
124
|
+
(tr("📁 Файл"), lambda: self._prefill("@")),
|
|
125
|
+
(tr("🖼 Фото"), self.action_paste_image),
|
|
126
|
+
(tr("🎯 Цель"), lambda: self._prefill("/goal ")),
|
|
127
|
+
(tr("💬 Вопрос"), lambda: self._prefill("/btw ")),
|
|
128
|
+
(tr("↶ Откат"), self.action_undo),
|
|
129
|
+
(tr("? Помощь"), self.action_help),
|
|
130
|
+
], id="quick-bar")
|
|
120
131
|
yield PromptInput(id="prompt")
|
|
121
132
|
with Horizontal(id="statusbar"):
|
|
122
|
-
yield
|
|
133
|
+
yield Chip("", self.action_connect, id="status-model")
|
|
123
134
|
yield Static(id="status-usage")
|
|
124
135
|
yield Chip("", self.action_toggle_access, id="status-access")
|
|
125
136
|
|
|
126
|
-
def
|
|
137
|
+
def _prefill(self, text: str) -> None:
|
|
138
|
+
"""Put a starter prefix into the prompt box and focus it (for 1-click beginner buttons)."""
|
|
139
|
+
prompt = self.query_one(PromptInput)
|
|
140
|
+
if text == "@" and prompt.text and not prompt.text.endswith(" "):
|
|
141
|
+
prompt.insert(" @")
|
|
142
|
+
elif text == "@":
|
|
143
|
+
prompt.insert("@")
|
|
144
|
+
else:
|
|
145
|
+
prompt.text = text
|
|
146
|
+
prompt.move_cursor(prompt.document.end)
|
|
147
|
+
prompt.focus()
|
|
148
|
+
self._update_mentions()
|
|
149
|
+
|
|
150
|
+
def _run_starter_command(self, cmd: str) -> None:
|
|
151
|
+
if self._agent_busy:
|
|
152
|
+
self.notify(tr("Агент ещё работает. Esc — остановить."), severity="warning")
|
|
153
|
+
return
|
|
154
|
+
self._command(cmd)
|
|
155
|
+
|
|
156
|
+
def _welcome(self) -> WelcomePanel:
|
|
127
157
|
footer = Text()
|
|
128
|
-
footer.append(f"v{__version__}\n
|
|
129
|
-
footer.append(tr("
|
|
130
|
-
|
|
131
|
-
|
|
158
|
+
footer.append(f"v{__version__}\n", style="dim")
|
|
159
|
+
footer.append(tr("ИИ-помощник для кода: просто опишите задачу обычными словами или нажмите кнопку ниже."), style="dim")
|
|
160
|
+
logo = AnimatedLogo(footer, animate=self.settings.animations)
|
|
161
|
+
proj_ok = not projects.is_unsuitable(self.project_root)
|
|
162
|
+
rules_ok = (self.project_root / "AGENTS.md").exists()
|
|
163
|
+
steps = [
|
|
164
|
+
(self.settings.ready,
|
|
165
|
+
tr("1. Модель: {0}", self.settings.model[:22]) if self.settings.ready else tr("1. Подключить модель →"),
|
|
166
|
+
self.action_connect),
|
|
167
|
+
(proj_ok,
|
|
168
|
+
tr("2. Проект: {0}", self.project_root.name[:20]) if proj_ok else tr("2. Выбрать папку проекта →"),
|
|
169
|
+
self.action_projects),
|
|
170
|
+
(rules_ok,
|
|
171
|
+
tr("3. Правила: AGENTS.md") if rules_ok else tr("3. Изучить проект (/init)"),
|
|
172
|
+
lambda: self._run_starter_command("/init")),
|
|
173
|
+
]
|
|
174
|
+
starters = [
|
|
175
|
+
(tr("🔍 Изучить проект"), lambda: self._run_starter_command("/init")),
|
|
176
|
+
(tr("🐛 Проверить код"), lambda: self._run_starter_command("/review")),
|
|
177
|
+
(tr("🧪 Запустить тесты"), lambda: self._run_starter_command("/test")),
|
|
178
|
+
(tr("🎯 Поставить цель"), lambda: self._prefill("/goal ")),
|
|
179
|
+
(tr("💬 Быстрый вопрос"), lambda: self._prefill("/btw ")),
|
|
180
|
+
(tr("🧭 Открыть браузер"), self.action_toggle_browser),
|
|
181
|
+
(tr("🎨 Сменить тему"), self.action_cycle_theme),
|
|
182
|
+
(tr("❓ Как пользоваться"), self.action_help),
|
|
183
|
+
]
|
|
184
|
+
return WelcomePanel(logo, steps, starters, id="welcome")
|
|
132
185
|
|
|
133
186
|
def on_mount(self) -> None:
|
|
134
187
|
import contextlib
|
|
@@ -217,6 +270,7 @@ class AnixApp(App):
|
|
|
217
270
|
bar.show(req)
|
|
218
271
|
prompt = self.query_one(PromptInput)
|
|
219
272
|
prompt.permission_handler = self._resolve_permission
|
|
273
|
+
prompt.set_hint(tr("Enter — разрешить · Esc — отклонить · или напишите словами, как сделать иначе…"))
|
|
220
274
|
prompt.focus()
|
|
221
275
|
indicator = self.query_one(ActivityIndicator)
|
|
222
276
|
indicator.set_phase(tr("Ждёт разрешения: Enter / Esc"), paused=True)
|
|
@@ -226,6 +280,7 @@ class AnixApp(App):
|
|
|
226
280
|
finally:
|
|
227
281
|
self._pending = None
|
|
228
282
|
prompt.permission_handler = None
|
|
283
|
+
self._sync_prompt_hint()
|
|
229
284
|
bar.hide()
|
|
230
285
|
indicator.set_phase(tr('Выполняет: {0}', req.title))
|
|
231
286
|
|
|
@@ -252,20 +307,31 @@ class AnixApp(App):
|
|
|
252
307
|
if self.settings.full_access and self._pending is not None:
|
|
253
308
|
self._resolve_permission("once")
|
|
254
309
|
|
|
310
|
+
def _sync_prompt_hint(self) -> None:
|
|
311
|
+
try:
|
|
312
|
+
prompt = self.query_one(PromptInput)
|
|
313
|
+
except Exception:
|
|
314
|
+
return
|
|
315
|
+
if self._agent_busy:
|
|
316
|
+
prompt.set_hint(tr("Агент работает… Напишите следующее сообщение (в очередь) или /btw <вопрос>…"))
|
|
317
|
+
else:
|
|
318
|
+
prompt.set_hint(tr("Напишите задачу (Enter — отправить · / — команды · @ — файлы · Alt+V — скриншот)…"))
|
|
319
|
+
|
|
255
320
|
def _refresh_bars(self) -> None:
|
|
256
321
|
self._pulse_brand(force=True)
|
|
322
|
+
self._sync_prompt_hint()
|
|
257
323
|
mode = self.agent.mode if self.agent else self._agent_mode
|
|
258
324
|
goal_on = bool(self.agent and self.agent.active_goal)
|
|
259
|
-
badge = self.query_one("#mode",
|
|
260
|
-
badge.update("GOAL" if goal_on else ("PLAN" if mode == "plan" else "BUILD"))
|
|
325
|
+
badge = self.query_one("#mode", Chip)
|
|
326
|
+
badge.update(" 🎯 GOAL " if goal_on else (" 👁 PLAN " if mode == "plan" else " ✎ BUILD "))
|
|
261
327
|
badge.set_class(mode == "plan" and not goal_on, "plan")
|
|
262
328
|
badge.set_class(goal_on, "goal")
|
|
263
329
|
if self.settings.ready:
|
|
264
|
-
model = Text(self.settings.model, style="bold")
|
|
330
|
+
model = Text("🤖 " + self.settings.model, style="bold")
|
|
265
331
|
if self.settings.reasoning_effort:
|
|
266
332
|
model.append(f" · {self.settings.reasoning_effort}", style="dim")
|
|
267
333
|
else:
|
|
268
|
-
model = Text(tr("
|
|
334
|
+
model = Text(tr("⚠ Модель не подключена — нажмите здесь"), style="bold yellow")
|
|
269
335
|
s = self.session
|
|
270
336
|
usage = Text(f"↑{_tokens(s.tokens_in)} ↓{_tokens(s.tokens_out)}", style="dim")
|
|
271
337
|
if s.tokens_cached:
|
|
@@ -277,7 +343,7 @@ class AnixApp(App):
|
|
|
277
343
|
pct = int(self.agent.context_usage(s) * 100)
|
|
278
344
|
usage.append(tr(" контекст "), style="dim")
|
|
279
345
|
usage.append(f"{pct}%", style="bold red" if pct >= 80 else "bold yellow" if pct >= 60 else "dim")
|
|
280
|
-
self.query_one("#status-model",
|
|
346
|
+
self.query_one("#status-model", Chip).update(model)
|
|
281
347
|
self.query_one("#status-usage", Static).update(usage)
|
|
282
348
|
access = self.query_one("#status-access", Chip)
|
|
283
349
|
if self.settings.full_access:
|
|
@@ -759,7 +825,7 @@ class AnixApp(App):
|
|
|
759
825
|
if page.url:
|
|
760
826
|
chip.update(Text(" 🧭 " + (page.title or page.url)[:18] + " ", style="bold"))
|
|
761
827
|
else:
|
|
762
|
-
chip.update(" 🧭 ")
|
|
828
|
+
chip.update(tr(" 🧭 Браузер "))
|
|
763
829
|
except Exception:
|
|
764
830
|
pass
|
|
765
831
|
|
|
@@ -1213,6 +1279,7 @@ class AnixApp(App):
|
|
|
1213
1279
|
self._build_agent()
|
|
1214
1280
|
self.session.model = self.settings.model
|
|
1215
1281
|
self._refresh_bars()
|
|
1282
|
+
self.run_worker(self._refresh_welcome_if_empty())
|
|
1216
1283
|
self.notify(tr('Подключено: {0}', self.settings.model), timeout=3)
|
|
1217
1284
|
self.query_one(PromptInput).focus()
|
|
1218
1285
|
if self._pick_project:
|
|
@@ -1220,6 +1287,57 @@ class AnixApp(App):
|
|
|
1220
1287
|
|
|
1221
1288
|
self.push_screen(SetupScreen(self.settings, self.auth, self.config_base), done)
|
|
1222
1289
|
|
|
1290
|
+
async def _refresh_welcome_if_empty(self) -> None:
|
|
1291
|
+
chat = self.query_one("#chat", VerticalScroll)
|
|
1292
|
+
welcomes = list(chat.query("#welcome"))
|
|
1293
|
+
if welcomes and not self.session.messages:
|
|
1294
|
+
for w in welcomes:
|
|
1295
|
+
await w.remove()
|
|
1296
|
+
await chat.mount(self._welcome())
|
|
1297
|
+
|
|
1298
|
+
def action_quick_menu(self) -> None:
|
|
1299
|
+
if isinstance(self.screen, QuickMenuScreen):
|
|
1300
|
+
return
|
|
1301
|
+
items = [
|
|
1302
|
+
("connect", tr("🤖 Подключить модель"), tr("выбрать провайдера, ключ и модель"), "Ctrl+O"),
|
|
1303
|
+
("project", tr("📂 Выбрать проект"), tr("открыть папку или склонировать с GitHub"), "Ctrl+P"),
|
|
1304
|
+
("init", tr("🔍 Изучить проект"), tr("агент разберёт код и создаст AGENTS.md"), "/init"),
|
|
1305
|
+
("goal", tr("🎯 Поставить цель"), tr("автономная работа до полной проверки"), "/goal"),
|
|
1306
|
+
("btw", tr("💬 Быстрый вопрос"), tr("спросить без изменения истории диалога"), "/btw"),
|
|
1307
|
+
("browser", tr("🧭 Встроенный браузер"), tr("открыть сайт/localhost прямо в окне"), "Ctrl+B"),
|
|
1308
|
+
("review", tr("🐛 Проверить изменения"), tr("поиск багов и рисков в текущем коде"), "/review"),
|
|
1309
|
+
("test", tr("🧪 Запустить тесты"), tr("найти тесты, прогнать и починить"), "/test"),
|
|
1310
|
+
("commit", tr("💾 Сделать коммит"), tr("подготовить и закоммитить изменения"), "/commit"),
|
|
1311
|
+
("undo", tr("↶ Откатить правки"), tr("вернуть файлы к состоянию до ответа"), "/undo"),
|
|
1312
|
+
("redo", tr("↷ Вернуть правки"), tr("повторить откаченные правки"), "/redo"),
|
|
1313
|
+
("mode", tr("✎ Режим Build / Plan"), tr("править код или только читать/планировать"), "Tab"),
|
|
1314
|
+
("permissions", tr("🔓 Полный доступ"), tr("включить/выключить запросы подтверждений"), "F2"),
|
|
1315
|
+
("image", tr("🖼 Вставить скриншот"), tr("прикрепить изображение из буфера обмена"), "Alt+V"),
|
|
1316
|
+
("sessions", tr("🕘 Прошлые сессии"), tr("вернуться к предыдущему диалогу"), "Ctrl+S"),
|
|
1317
|
+
("new", tr("✨ Новая сессия"), tr("начать чистый диалог в этом проекте"), "Ctrl+N"),
|
|
1318
|
+
("theme", tr("🎨 Выбрать тему"), tr("сменить цвета интерфейса с предпросмотром"), "Ctrl+T"),
|
|
1319
|
+
("language", tr("🌐 Сменить язык"), tr("переключить Русский / English"), "/language"),
|
|
1320
|
+
("doctor", tr("🩺 Проверка системы"), tr("проверить модель, git, ripgrep, браузер"), "/doctor"),
|
|
1321
|
+
("help", tr("❓ Справка"), tr("все горячие клавиши и команды"), "F1"),
|
|
1322
|
+
]
|
|
1323
|
+
|
|
1324
|
+
def done(choice: str | None) -> None:
|
|
1325
|
+
if not choice:
|
|
1326
|
+
self.query_one(PromptInput).focus()
|
|
1327
|
+
return
|
|
1328
|
+
if choice == "goal":
|
|
1329
|
+
self._prefill("/goal ")
|
|
1330
|
+
elif choice == "btw":
|
|
1331
|
+
self._prefill("/btw ")
|
|
1332
|
+
elif choice == "browser":
|
|
1333
|
+
self.action_toggle_browser()
|
|
1334
|
+
elif choice in ("init", "review", "test", "commit"):
|
|
1335
|
+
self._run_starter_command(f"/{choice}")
|
|
1336
|
+
else:
|
|
1337
|
+
self._command(f"/{choice}")
|
|
1338
|
+
|
|
1339
|
+
self.push_screen(QuickMenuScreen(items), done)
|
|
1340
|
+
|
|
1223
1341
|
async def _reset_chat(self) -> None:
|
|
1224
1342
|
chat = self.query_one("#chat", VerticalScroll)
|
|
1225
1343
|
await chat.remove_children()
|
|
@@ -23,13 +23,104 @@ Screen {
|
|
|
23
23
|
background: $warning;
|
|
24
24
|
color: $background;
|
|
25
25
|
}
|
|
26
|
-
#browser-chip {
|
|
26
|
+
#browser-chip, #menu-chip {
|
|
27
27
|
width: auto;
|
|
28
28
|
margin-right: 1;
|
|
29
29
|
padding: 0 1;
|
|
30
30
|
background: $surface;
|
|
31
31
|
color: $text-muted;
|
|
32
32
|
}
|
|
33
|
+
#browser-chip:hover, #menu-chip:hover, #mode:hover {
|
|
34
|
+
text-style: bold reverse;
|
|
35
|
+
}
|
|
36
|
+
#welcome-panel {
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: auto;
|
|
39
|
+
align-horizontal: center;
|
|
40
|
+
}
|
|
41
|
+
#welcome-box {
|
|
42
|
+
width: 96;
|
|
43
|
+
max-width: 96%;
|
|
44
|
+
height: auto;
|
|
45
|
+
margin: 0 0 1 0;
|
|
46
|
+
padding: 1 2;
|
|
47
|
+
background: $surface;
|
|
48
|
+
border: round $panel;
|
|
49
|
+
}
|
|
50
|
+
.welcome-section {
|
|
51
|
+
color: $text-muted;
|
|
52
|
+
margin-top: 1;
|
|
53
|
+
}
|
|
54
|
+
.welcome-row {
|
|
55
|
+
height: auto;
|
|
56
|
+
margin: 0 0 1 0;
|
|
57
|
+
}
|
|
58
|
+
.chip.step.done {
|
|
59
|
+
background: $success 20%;
|
|
60
|
+
color: $success;
|
|
61
|
+
margin-left: 0;
|
|
62
|
+
margin-right: 1;
|
|
63
|
+
}
|
|
64
|
+
.chip.step.pending {
|
|
65
|
+
background: $warning 25%;
|
|
66
|
+
color: $warning;
|
|
67
|
+
margin-left: 0;
|
|
68
|
+
margin-right: 1;
|
|
69
|
+
}
|
|
70
|
+
.chip.starter {
|
|
71
|
+
background: $panel;
|
|
72
|
+
color: $text;
|
|
73
|
+
margin-left: 0;
|
|
74
|
+
margin-right: 1;
|
|
75
|
+
}
|
|
76
|
+
.chip.starter:hover {
|
|
77
|
+
background: $primary;
|
|
78
|
+
color: $background;
|
|
79
|
+
}
|
|
80
|
+
#quick-bar {
|
|
81
|
+
height: 1;
|
|
82
|
+
padding: 0 1;
|
|
83
|
+
margin-bottom: 0;
|
|
84
|
+
}
|
|
85
|
+
.chip.quick {
|
|
86
|
+
background: transparent;
|
|
87
|
+
color: $text-muted;
|
|
88
|
+
text-style: none;
|
|
89
|
+
margin-left: 0;
|
|
90
|
+
margin-right: 1;
|
|
91
|
+
}
|
|
92
|
+
.chip.quick:hover {
|
|
93
|
+
background: $panel;
|
|
94
|
+
color: $text;
|
|
95
|
+
text-style: bold;
|
|
96
|
+
}
|
|
97
|
+
.chip.always {
|
|
98
|
+
background: $primary 25%;
|
|
99
|
+
color: $primary;
|
|
100
|
+
}
|
|
101
|
+
#browser-links {
|
|
102
|
+
display: none;
|
|
103
|
+
height: 1;
|
|
104
|
+
padding: 0 1;
|
|
105
|
+
}
|
|
106
|
+
.setup-guide {
|
|
107
|
+
padding: 0 1;
|
|
108
|
+
margin-bottom: 1;
|
|
109
|
+
border-left: thick $primary;
|
|
110
|
+
background: $panel;
|
|
111
|
+
color: $text;
|
|
112
|
+
}
|
|
113
|
+
#advanced-box {
|
|
114
|
+
height: auto;
|
|
115
|
+
}
|
|
116
|
+
#menu-list {
|
|
117
|
+
height: auto;
|
|
118
|
+
max-height: 18;
|
|
119
|
+
margin: 1 0;
|
|
120
|
+
}
|
|
121
|
+
#status-model:hover {
|
|
122
|
+
text-style: bold underline;
|
|
123
|
+
}
|
|
33
124
|
#workspace {
|
|
34
125
|
height: 1fr;
|
|
35
126
|
}
|