anixcode 0.12.3__tar.gz → 0.12.4__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.12.3 → anixcode-0.12.4}/PKG-INFO +1 -1
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/__init__.py +1 -1
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tui/app.py +4 -90
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tui/app.tcss +5 -29
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tui/screens.py +10 -126
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tui/widgets.py +4 -30
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode.egg-info/PKG-INFO +1 -1
- {anixcode-0.12.3 → anixcode-0.12.4}/pyproject.toml +1 -1
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_v011_features.py +2 -14
- {anixcode-0.12.3 → anixcode-0.12.4}/LICENSE +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/README.md +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/__main__.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/agent.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/airpc.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/browser.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/checkpoints.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/cli.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/commands.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/compaction.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/danger.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/i18n.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/i18n_en.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/images.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/llm.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/mcp.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/mentions.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/projects.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/prompts.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/providers.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/settings.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/storage.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tools/__init__.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tools/base.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tools/browser.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tools/files.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tools/search.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tools/shell.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tools/todo.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tools/web.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tui/__init__.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode/tui/anim.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode.egg-info/SOURCES.txt +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode.egg-info/dependency_links.txt +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode.egg-info/entry_points.txt +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode.egg-info/requires.txt +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/anixcode.egg-info/top_level.txt +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/setup.cfg +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_agent.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_commands.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_i18n.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_images.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_llm.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_mcp.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_projects.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_providers.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_reliability.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_safety_mentions.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_settings.py +0 -0
- {anixcode-0.12.3 → anixcode-0.12.4}/tests/test_tools.py +0 -0
|
@@ -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,
|
|
40
|
+
from .screens import HelpScreen, ProjectScreen, SessionsScreen, SetupScreen, ThemeScreen
|
|
41
41
|
from .widgets import (
|
|
42
42
|
AssistantMessage, AttachmentBar, BrowserPane, BtwCard, Chip, ErrorMessage, MentionList, Notice, PermissionBar,
|
|
43
|
-
PromptInput,
|
|
43
|
+
PromptInput, ReasoningBlock, TodoBar, ToolCard, UserMessage,
|
|
44
44
|
)
|
|
45
45
|
|
|
46
46
|
def _tokens(n: int) -> str:
|
|
@@ -68,7 +68,6 @@ 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),
|
|
72
71
|
Binding("ctrl+b", "toggle_browser", tr("Браузер"), show=False),
|
|
73
72
|
Binding("alt+v", "paste_image", tr("Вставить фото"), priority=True, show=False),
|
|
74
73
|
Binding("f1", "help", tr("Помощь"), show=False),
|
|
@@ -103,7 +102,6 @@ class AnixApp(App):
|
|
|
103
102
|
def compose(self) -> ComposeResult:
|
|
104
103
|
with Horizontal(id="header"):
|
|
105
104
|
yield Brand(id="brand")
|
|
106
|
-
yield Chip(tr(" ≡ Меню "), self.action_quick_menu, id="menu-chip")
|
|
107
105
|
yield Chip(tr(" Браузер "), self.action_toggle_browser, id="browser-chip")
|
|
108
106
|
yield Chip("BUILD", self.action_toggle_mode, id="mode")
|
|
109
107
|
with Horizontal(id="workspace"):
|
|
@@ -119,45 +117,17 @@ class AnixApp(App):
|
|
|
119
117
|
yield PermissionBar(self._resolve_permission, id="permission")
|
|
120
118
|
yield AttachmentBar(self._remove_image, id="attachments")
|
|
121
119
|
yield MentionList(id="mentions")
|
|
122
|
-
yield QuickActionBar([
|
|
123
|
-
(tr("/ Команды"), lambda: self._prefill("/")),
|
|
124
|
-
(tr("@ Файл"), lambda: self._prefill("@")),
|
|
125
|
-
(tr("+ Фото"), self.action_paste_image),
|
|
126
|
-
("/goal", lambda: self._prefill("/goal ")),
|
|
127
|
-
("/btw", lambda: self._prefill("/btw ")),
|
|
128
|
-
(tr("↶ Откат"), self.action_undo),
|
|
129
|
-
(tr("? Помощь"), self.action_help),
|
|
130
|
-
], id="quick-bar")
|
|
131
120
|
yield PromptInput(id="prompt")
|
|
132
121
|
with Horizontal(id="statusbar"):
|
|
133
122
|
yield Chip("", self.action_connect, id="status-model")
|
|
134
123
|
yield Static(id="status-usage")
|
|
135
124
|
yield Chip("", self.action_toggle_access, id="status-access")
|
|
136
125
|
|
|
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
126
|
def _welcome(self) -> Static:
|
|
157
127
|
footer = Text()
|
|
158
128
|
footer.append(f"v{__version__}\n\n", style="dim")
|
|
159
129
|
footer.append(tr("Опишите задачу: агент сам прочитает код, внесёт правки и запустит команды.\n"), style="dim")
|
|
160
|
-
footer.append(tr("
|
|
130
|
+
footer.append(tr("Tab: Build/Plan · Ctrl+O: модель · F1: все клавиши"), style="dim")
|
|
161
131
|
return AnimatedLogo(footer, animate=self.settings.animations, id="welcome")
|
|
162
132
|
|
|
163
133
|
def on_mount(self) -> None:
|
|
@@ -247,7 +217,6 @@ class AnixApp(App):
|
|
|
247
217
|
bar.show(req)
|
|
248
218
|
prompt = self.query_one(PromptInput)
|
|
249
219
|
prompt.permission_handler = self._resolve_permission
|
|
250
|
-
prompt.set_hint(tr("Enter — разрешить · Esc — отклонить · или напишите словами, как сделать иначе…"))
|
|
251
220
|
prompt.focus()
|
|
252
221
|
indicator = self.query_one(ActivityIndicator)
|
|
253
222
|
indicator.set_phase(tr("Ждёт разрешения: Enter / Esc"), paused=True)
|
|
@@ -257,7 +226,6 @@ class AnixApp(App):
|
|
|
257
226
|
finally:
|
|
258
227
|
self._pending = None
|
|
259
228
|
prompt.permission_handler = None
|
|
260
|
-
self._sync_prompt_hint()
|
|
261
229
|
bar.hide()
|
|
262
230
|
indicator.set_phase(tr('Выполняет: {0}', req.title))
|
|
263
231
|
|
|
@@ -284,19 +252,8 @@ class AnixApp(App):
|
|
|
284
252
|
if self.settings.full_access and self._pending is not None:
|
|
285
253
|
self._resolve_permission("once")
|
|
286
254
|
|
|
287
|
-
def _sync_prompt_hint(self) -> None:
|
|
288
|
-
try:
|
|
289
|
-
prompt = self.query_one(PromptInput)
|
|
290
|
-
except Exception:
|
|
291
|
-
return
|
|
292
|
-
if self._agent_busy:
|
|
293
|
-
prompt.set_hint(tr("Агент работает… Напишите следующее сообщение (в очередь) или /btw <вопрос>…"))
|
|
294
|
-
else:
|
|
295
|
-
prompt.set_hint(tr("Напишите задачу (Enter — отправить · / — команды · @ — файлы · Alt+V — скриншот)…"))
|
|
296
|
-
|
|
297
255
|
def _refresh_bars(self) -> None:
|
|
298
256
|
self._pulse_brand(force=True)
|
|
299
|
-
self._sync_prompt_hint()
|
|
300
257
|
mode = self.agent.mode if self.agent else self._agent_mode
|
|
301
258
|
goal_on = bool(self.agent and self.agent.active_goal)
|
|
302
259
|
badge = self.query_one("#mode", Chip)
|
|
@@ -308,7 +265,7 @@ class AnixApp(App):
|
|
|
308
265
|
if self.settings.reasoning_effort:
|
|
309
266
|
model.append(f" · {self.settings.reasoning_effort}", style="dim")
|
|
310
267
|
else:
|
|
311
|
-
model = Text(tr("
|
|
268
|
+
model = Text(tr("модель не подключена · ctrl+o"), style="dim")
|
|
312
269
|
s = self.session
|
|
313
270
|
usage = Text(f"↑{_tokens(s.tokens_in)} ↓{_tokens(s.tokens_out)}", style="dim")
|
|
314
271
|
if s.tokens_cached:
|
|
@@ -1263,49 +1220,6 @@ class AnixApp(App):
|
|
|
1263
1220
|
|
|
1264
1221
|
self.push_screen(SetupScreen(self.settings, self.auth, self.config_base), done)
|
|
1265
1222
|
|
|
1266
|
-
def action_quick_menu(self) -> None:
|
|
1267
|
-
if isinstance(self.screen, QuickMenuScreen):
|
|
1268
|
-
return
|
|
1269
|
-
items = [
|
|
1270
|
-
("connect", tr("Подключить модель"), tr("выбрать провайдера, ключ и модель"), "Ctrl+O"),
|
|
1271
|
-
("project", tr("Выбрать проект"), tr("открыть папку или склонировать с GitHub"), "Ctrl+P"),
|
|
1272
|
-
("init", tr("Изучить проект"), tr("агент разберёт код и создаст AGENTS.md"), "/init"),
|
|
1273
|
-
("goal", tr("Поставить цель"), tr("автономная работа до полной проверки"), "/goal"),
|
|
1274
|
-
("btw", tr("Быстрый вопрос"), tr("спросить без изменения истории диалога"), "/btw"),
|
|
1275
|
-
("browser", tr("Встроенный браузер"), tr("открыть сайт/localhost прямо в окне"), "Ctrl+B"),
|
|
1276
|
-
("review", tr("Проверить изменения"), tr("поиск багов и рисков в текущем коде"), "/review"),
|
|
1277
|
-
("test", tr("Запустить тесты"), tr("найти тесты, прогнать и починить"), "/test"),
|
|
1278
|
-
("commit", tr("Сделать коммит"), tr("подготовить и закоммитить изменения"), "/commit"),
|
|
1279
|
-
("undo", tr("Откатить правки"), tr("вернуть файлы к состоянию до ответа"), "/undo"),
|
|
1280
|
-
("redo", tr("Вернуть правки"), tr("повторить откаченные правки"), "/redo"),
|
|
1281
|
-
("mode", tr("Режим Build / Plan"), tr("править код или только читать/планировать"), "Tab"),
|
|
1282
|
-
("permissions", tr("Полный доступ"), tr("включить/выключить запросы подтверждений"), "F2"),
|
|
1283
|
-
("image", tr("Вставить скриншот"), tr("прикрепить изображение из буфера обмена"), "Alt+V"),
|
|
1284
|
-
("sessions", tr("Прошлые сессии"), tr("вернуться к предыдущему диалогу"), "Ctrl+S"),
|
|
1285
|
-
("new", tr("Новая сессия"), tr("начать чистый диалог в этом проекте"), "Ctrl+N"),
|
|
1286
|
-
("theme", tr("Выбрать тему"), tr("сменить цвета интерфейса с предпросмотром"), "Ctrl+T"),
|
|
1287
|
-
("language", tr("Сменить язык"), tr("переключить Русский / English"), "/language"),
|
|
1288
|
-
("doctor", tr("Проверка системы"), tr("проверить модель, git, ripgrep, браузер"), "/doctor"),
|
|
1289
|
-
("help", tr("Справка"), tr("все горячие клавиши и команды"), "F1"),
|
|
1290
|
-
]
|
|
1291
|
-
|
|
1292
|
-
def done(choice: str | None) -> None:
|
|
1293
|
-
if not choice:
|
|
1294
|
-
self.query_one(PromptInput).focus()
|
|
1295
|
-
return
|
|
1296
|
-
if choice == "goal":
|
|
1297
|
-
self._prefill("/goal ")
|
|
1298
|
-
elif choice == "btw":
|
|
1299
|
-
self._prefill("/btw ")
|
|
1300
|
-
elif choice == "browser":
|
|
1301
|
-
self.action_toggle_browser()
|
|
1302
|
-
elif choice in ("init", "review", "test", "commit"):
|
|
1303
|
-
self._run_starter_command(f"/{choice}")
|
|
1304
|
-
else:
|
|
1305
|
-
self._command(f"/{choice}")
|
|
1306
|
-
|
|
1307
|
-
self.push_screen(QuickMenuScreen(items), done)
|
|
1308
|
-
|
|
1309
1223
|
async def _reset_chat(self) -> None:
|
|
1310
1224
|
chat = self.query_one("#chat", VerticalScroll)
|
|
1311
1225
|
await chat.remove_children()
|
|
@@ -23,57 +23,33 @@ Screen {
|
|
|
23
23
|
background: $warning;
|
|
24
24
|
color: $background;
|
|
25
25
|
}
|
|
26
|
-
#browser-chip
|
|
26
|
+
#browser-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, #
|
|
33
|
+
#browser-chip:hover, #mode:hover {
|
|
34
34
|
text-style: bold reverse;
|
|
35
35
|
}
|
|
36
|
-
#
|
|
36
|
+
#browser-links {
|
|
37
|
+
display: none;
|
|
37
38
|
height: 1;
|
|
38
39
|
padding: 0 1;
|
|
39
|
-
margin-bottom: 0;
|
|
40
40
|
}
|
|
41
41
|
.chip.quick {
|
|
42
42
|
background: transparent;
|
|
43
43
|
color: $text-muted;
|
|
44
44
|
text-style: none;
|
|
45
45
|
margin-left: 0;
|
|
46
|
-
margin-right:
|
|
46
|
+
margin-right: 1;
|
|
47
47
|
}
|
|
48
48
|
.chip.quick:hover {
|
|
49
49
|
background: $panel;
|
|
50
50
|
color: $text;
|
|
51
51
|
text-style: bold;
|
|
52
52
|
}
|
|
53
|
-
.chip.always {
|
|
54
|
-
background: $primary 25%;
|
|
55
|
-
color: $primary;
|
|
56
|
-
}
|
|
57
|
-
#browser-links {
|
|
58
|
-
display: none;
|
|
59
|
-
height: 1;
|
|
60
|
-
padding: 0 1;
|
|
61
|
-
}
|
|
62
|
-
.setup-guide {
|
|
63
|
-
padding: 0 1;
|
|
64
|
-
margin-bottom: 1;
|
|
65
|
-
border-left: thick $primary;
|
|
66
|
-
background: $panel;
|
|
67
|
-
color: $text;
|
|
68
|
-
}
|
|
69
|
-
#advanced-box {
|
|
70
|
-
height: auto;
|
|
71
|
-
}
|
|
72
|
-
#menu-list {
|
|
73
|
-
height: auto;
|
|
74
|
-
max-height: 18;
|
|
75
|
-
margin: 1 0;
|
|
76
|
-
}
|
|
77
53
|
#status-model:hover {
|
|
78
54
|
text-style: bold underline;
|
|
79
55
|
}
|
|
@@ -94,7 +94,7 @@ class ProviderEditScreen(ModalScreen[dict | None]):
|
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
class SetupScreen(ModalScreen[bool]):
|
|
97
|
-
"""
|
|
97
|
+
"""Pick a provider, paste a key, choose a model."""
|
|
98
98
|
|
|
99
99
|
BINDINGS = [("escape", "cancel", tr("Отмена"))]
|
|
100
100
|
|
|
@@ -104,7 +104,6 @@ class SetupScreen(ModalScreen[bool]):
|
|
|
104
104
|
self.auth = auth
|
|
105
105
|
self.base = base
|
|
106
106
|
self._model_ids: list[str] = []
|
|
107
|
-
self._show_advanced = False
|
|
108
107
|
|
|
109
108
|
def _options(self) -> list[tuple[str, str]]:
|
|
110
109
|
return [(("★ " if p.is_user else "") + p.name, p.id) for p in providers.all_providers(self.settings)]
|
|
@@ -113,33 +112,25 @@ class SetupScreen(ModalScreen[bool]):
|
|
|
113
112
|
ids = {p.id for p in providers.all_providers(self.settings)}
|
|
114
113
|
current = self.settings.provider if self.settings.provider in ids else "deepseek"
|
|
115
114
|
with Vertical(id="dialog"):
|
|
116
|
-
yield Label(tr("Подключение
|
|
117
|
-
yield
|
|
118
|
-
tr("Шаг 1: выберите провайдера → Шаг 2: вставьте ключ (если нужен) → Шаг 3: нажмите «Сохранить»."),
|
|
119
|
-
classes="setup-guide",
|
|
120
|
-
)
|
|
121
|
-
yield Label(tr("1. Провайдер"))
|
|
115
|
+
yield Label(tr("Подключение модели"), classes="dialog-title")
|
|
116
|
+
yield Label(tr("Провайдер"))
|
|
122
117
|
with Horizontal(id="provider-row"):
|
|
123
118
|
yield Select(self._options(), value=current, allow_blank=False, id="provider")
|
|
124
119
|
yield Button(tr("+ Свой"), id="add-provider")
|
|
125
120
|
yield Button(tr("Удалить"), id="del-provider", variant="error")
|
|
126
|
-
yield
|
|
127
|
-
yield Label(tr("2. API-ключ"), id="key-label")
|
|
121
|
+
yield Label(tr("API-ключ"))
|
|
128
122
|
yield Input(password=True, id="key")
|
|
129
123
|
yield Static(id="key-hint", classes="hint")
|
|
130
|
-
yield Label(tr("
|
|
124
|
+
yield Label(tr("Адрес сервера"))
|
|
125
|
+
yield Input(id="base-url")
|
|
126
|
+
yield Label(tr("Модель"))
|
|
131
127
|
with Horizontal(id="model-row"):
|
|
132
128
|
yield Input(id="model", placeholder=tr("название модели"))
|
|
133
129
|
yield Button(tr("Список моделей"), id="fetch")
|
|
134
130
|
yield OptionList(id="models")
|
|
135
|
-
with Vertical(id="advanced-box"):
|
|
136
|
-
yield Label(tr("Адрес сервера (обычно менять не нужно)"))
|
|
137
|
-
yield Input(id="base-url")
|
|
138
131
|
yield Static(id="setup-error", classes="error")
|
|
139
132
|
with Horizontal(classes="buttons"):
|
|
140
|
-
yield Button(tr("Сохранить
|
|
141
|
-
yield Button(tr("Проверить связь"), id="test-conn")
|
|
142
|
-
yield Button(tr("Адрес сервера"), id="toggle-adv")
|
|
133
|
+
yield Button(tr("Сохранить"), id="save", variant="primary")
|
|
143
134
|
yield Button(tr("Отмена"), id="cancel")
|
|
144
135
|
|
|
145
136
|
def on_mount(self) -> None:
|
|
@@ -156,15 +147,10 @@ class SetupScreen(ModalScreen[bool]):
|
|
|
156
147
|
def _fill(self, pid: str) -> None:
|
|
157
148
|
p = providers.get(pid, self.settings)
|
|
158
149
|
cred = self.auth.get(pid, Credentials())
|
|
159
|
-
self.query_one("#provider-hint", Static).update(p.hint or "")
|
|
160
150
|
key = self.query_one("#key", Input)
|
|
161
151
|
key.value = ""
|
|
162
|
-
key.placeholder = tr('сохранён: {0}', mask(cred.api_key)) if cred.api_key else (
|
|
163
|
-
|
|
164
|
-
)
|
|
165
|
-
hint = tr('Где взять ключ бесплатно/в кабинете: {0}', p.key_url) if p.key_url else (
|
|
166
|
-
tr("Ключ не нужен — работает локально на вашем компьютере") if not p.needs_key else ""
|
|
167
|
-
)
|
|
152
|
+
key.placeholder = tr('сохранён: {0}', mask(cred.api_key)) if cred.api_key else ("sk-…" if p.needs_key else tr("не обязателен"))
|
|
153
|
+
hint = tr('Где взять ключ: {0}', p.key_url) if p.key_url else (tr("Ключ не нужен") if not p.needs_key else "")
|
|
168
154
|
self.query_one("#key-hint", Static).update(hint)
|
|
169
155
|
self.query_one("#base-url", Input).value = cred.base_url or p.base_url
|
|
170
156
|
model = self.settings.model if self.settings.provider == pid else p.default_model
|
|
@@ -172,37 +158,6 @@ class SetupScreen(ModalScreen[bool]):
|
|
|
172
158
|
self.query_one("#models", OptionList).remove_class("visible")
|
|
173
159
|
self.query_one("#setup-error", Static).update("")
|
|
174
160
|
self.query_one("#del-provider", Button).display = p.is_user
|
|
175
|
-
# Hide technical server URL for standard providers unless custom/overridden/toggled
|
|
176
|
-
need_url = pid == "custom" or p.is_user or bool(cred.base_url) or self._show_advanced
|
|
177
|
-
self.query_one("#advanced-box", Vertical).display = need_url
|
|
178
|
-
|
|
179
|
-
@on(Button.Pressed, "#toggle-adv")
|
|
180
|
-
def _toggle_advanced(self) -> None:
|
|
181
|
-
self._show_advanced = not self._show_advanced
|
|
182
|
-
self.query_one("#advanced-box", Vertical).display = self._show_advanced
|
|
183
|
-
|
|
184
|
-
@on(Button.Pressed, "#test-conn")
|
|
185
|
-
def _test_conn_pressed(self) -> None:
|
|
186
|
-
self.test_connection()
|
|
187
|
-
|
|
188
|
-
@work(exclusive=True, group="setup-test")
|
|
189
|
-
async def test_connection(self) -> None:
|
|
190
|
-
status = self.query_one("#setup-error", Static)
|
|
191
|
-
base_url = self.query_one("#base-url", Input).value.strip()
|
|
192
|
-
if not base_url.startswith(("http://", "https://")):
|
|
193
|
-
status.update(Text(tr("Укажите адрес сервера, начиная с http:// или https://"), style="red"))
|
|
194
|
-
return
|
|
195
|
-
status.update(Text(tr("Проверяю подключение…"), style="yellow"))
|
|
196
|
-
client = make_client(base_url, self._current_key(), provider=self.provider_id)
|
|
197
|
-
try:
|
|
198
|
-
models = await client.list_models()
|
|
199
|
-
except LLMError as e:
|
|
200
|
-
status.update(Text(str(e), style="red"))
|
|
201
|
-
return
|
|
202
|
-
finally:
|
|
203
|
-
await client.aclose()
|
|
204
|
-
status.update(Text(tr("✓ Подключение работает! Найдено моделей: {0}. Можно нажимать «Сохранить и начать».", len(models)),
|
|
205
|
-
style="green"))
|
|
206
161
|
|
|
207
162
|
def _reload_options(self, select_id: str) -> None:
|
|
208
163
|
select = self.query_one("#provider", Select)
|
|
@@ -451,77 +406,6 @@ class HelpScreen(ModalScreen[None]):
|
|
|
451
406
|
self.dismiss(None)
|
|
452
407
|
|
|
453
408
|
|
|
454
|
-
class QuickMenuScreen(ModalScreen[str | None]):
|
|
455
|
-
"""Beginner-friendly visual command & action menu (Ctrl+K or ☰ Menu button)."""
|
|
456
|
-
|
|
457
|
-
BINDINGS = [("escape", "close", tr("Закрыть"))]
|
|
458
|
-
|
|
459
|
-
def __init__(self, items: list[tuple[str, str, str, str]]) -> None:
|
|
460
|
-
"""items: list of (action_key, icon_title, description, shortcut)."""
|
|
461
|
-
super().__init__()
|
|
462
|
-
self._all_items = items
|
|
463
|
-
self._filtered = list(items)
|
|
464
|
-
|
|
465
|
-
def compose(self) -> ComposeResult:
|
|
466
|
-
with Vertical(id="dialog"):
|
|
467
|
-
yield Label(tr("Меню действий"), classes="dialog-title")
|
|
468
|
-
yield Input(placeholder=tr("Поиск действия (например: браузер, цель, тест, тема, откат)…"), id="menu-search")
|
|
469
|
-
yield OptionList(id="menu-list")
|
|
470
|
-
yield Label(tr("↑↓ или клик — выбрать · Enter — выполнить · Esc — закрыть"), classes="hint")
|
|
471
|
-
|
|
472
|
-
def on_mount(self) -> None:
|
|
473
|
-
self._render_list("")
|
|
474
|
-
self.query_one("#menu-search", Input).focus()
|
|
475
|
-
|
|
476
|
-
def _render_list(self, query: str) -> None:
|
|
477
|
-
q = query.strip().lower()
|
|
478
|
-
self._filtered = [
|
|
479
|
-
it for it in self._all_items
|
|
480
|
-
if not q or q in it[0].lower() or q in it[1].lower() or q in it[2].lower()
|
|
481
|
-
]
|
|
482
|
-
box = self.query_one("#menu-list", OptionList)
|
|
483
|
-
box.clear_options()
|
|
484
|
-
for _key, title, desc, shortcut in self._filtered:
|
|
485
|
-
row = Text()
|
|
486
|
-
row.append(f"{title:<30}", style="bold")
|
|
487
|
-
row.append(f" {desc}", style="dim")
|
|
488
|
-
if shortcut:
|
|
489
|
-
row.append(f" [{shortcut}]", style="italic")
|
|
490
|
-
box.add_option(row)
|
|
491
|
-
if self._filtered:
|
|
492
|
-
box.highlighted = 0
|
|
493
|
-
|
|
494
|
-
@on(Input.Changed, "#menu-search")
|
|
495
|
-
def _search_changed(self, event: Input.Changed) -> None:
|
|
496
|
-
self._render_list(event.value)
|
|
497
|
-
|
|
498
|
-
@on(Input.Submitted, "#menu-search")
|
|
499
|
-
def _search_submitted(self) -> None:
|
|
500
|
-
box = self.query_one("#menu-list", OptionList)
|
|
501
|
-
if self._filtered:
|
|
502
|
-
idx = box.highlighted if box.highlighted is not None and box.highlighted < len(self._filtered) else 0
|
|
503
|
-
self.dismiss(self._filtered[idx][0])
|
|
504
|
-
|
|
505
|
-
@on(OptionList.OptionSelected, "#menu-list")
|
|
506
|
-
def _picked(self, event: OptionList.OptionSelected) -> None:
|
|
507
|
-
if 0 <= event.option_index < len(self._filtered):
|
|
508
|
-
self.dismiss(self._filtered[event.option_index][0])
|
|
509
|
-
|
|
510
|
-
def on_key(self, event) -> None:
|
|
511
|
-
if event.key in ("down", "up"):
|
|
512
|
-
box = self.query_one("#menu-list", OptionList)
|
|
513
|
-
if self._filtered:
|
|
514
|
-
if event.key == "down":
|
|
515
|
-
box.action_cursor_down()
|
|
516
|
-
else:
|
|
517
|
-
box.action_cursor_up()
|
|
518
|
-
event.stop()
|
|
519
|
-
event.prevent_default()
|
|
520
|
-
|
|
521
|
-
def action_close(self) -> None:
|
|
522
|
-
self.dismiss(None)
|
|
523
|
-
|
|
524
|
-
|
|
525
409
|
CUSTOM_HELP = tr("""\
|
|
526
410
|
## Свои команды
|
|
527
411
|
|
|
@@ -41,37 +41,34 @@ class Chip(Static):
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
class PermissionBar(Horizontal):
|
|
44
|
-
"""One line above the prompt: "Выполнить: rm -rf build [Разрешить ⏎] [
|
|
44
|
+
"""One line above the prompt: "Выполнить: rm -rf build [Разрешить ⏎] [Отклонить esc] [Полный доступ]"."""
|
|
45
45
|
|
|
46
46
|
def __init__(self, on_decide, **kwargs) -> None:
|
|
47
47
|
super().__init__(**kwargs)
|
|
48
48
|
self.perm_text = Static(id="perm-text")
|
|
49
49
|
self.perm_decide = on_decide
|
|
50
50
|
self.perm_ok = Chip(tr(" Разрешить ⏎ "), lambda: self.perm_decide("once"), classes="chip ok")
|
|
51
|
-
self.perm_always = Chip(tr(" Всегда в сессии "), lambda: self.perm_decide("always"), classes="chip always")
|
|
52
51
|
self.perm_no = Chip(tr(" Отклонить esc "), lambda: self.perm_decide("deny"), classes="chip no")
|
|
53
52
|
self.perm_full = Chip(tr(" Полный доступ "), lambda: self.perm_decide("full"), classes="chip full")
|
|
54
53
|
|
|
55
54
|
def compose(self):
|
|
56
55
|
yield self.perm_text
|
|
57
56
|
yield self.perm_ok
|
|
58
|
-
yield self.perm_always
|
|
59
57
|
yield self.perm_no
|
|
60
58
|
yield self.perm_full
|
|
61
59
|
|
|
62
60
|
def show(self, req) -> None:
|
|
63
61
|
text = Text()
|
|
64
|
-
verb = tr("Изменить
|
|
62
|
+
verb = tr("Изменить") if req.kind == "edit" else tr("Выполнить")
|
|
65
63
|
text.append(f"{verb}: ", style="bold")
|
|
66
64
|
text.append(req.title, style="bold red" if req.dangerous else "bold")
|
|
67
65
|
for why in req.danger:
|
|
68
66
|
text.append(f" · {why}", style="red")
|
|
69
67
|
for why in req.warnings:
|
|
70
68
|
text.append(f" · {why}", style="yellow")
|
|
71
|
-
text.append(tr("\
|
|
69
|
+
text.append(tr("\nEnter — разрешить · Esc — отклонить · напишите текст и Enter — отклонить с пояснением"),
|
|
72
70
|
style="dim")
|
|
73
71
|
self.perm_text.update(text)
|
|
74
|
-
self.perm_always.display = not req.dangerous
|
|
75
72
|
self.set_class(req.dangerous, "danger")
|
|
76
73
|
self.display = True
|
|
77
74
|
|
|
@@ -79,18 +76,6 @@ class PermissionBar(Horizontal):
|
|
|
79
76
|
self.display = False
|
|
80
77
|
|
|
81
78
|
|
|
82
|
-
class QuickActionBar(Horizontal):
|
|
83
|
-
"""1-line clickable toolbar above the input so beginners never have to memorize slash commands."""
|
|
84
|
-
|
|
85
|
-
def __init__(self, actions: list[tuple[str, Callable[[], None]]], **kwargs) -> None:
|
|
86
|
-
super().__init__(**kwargs)
|
|
87
|
-
self._actions = actions
|
|
88
|
-
|
|
89
|
-
def compose(self):
|
|
90
|
-
for label, cb in self._actions:
|
|
91
|
-
yield Chip(label, cb, classes="chip quick")
|
|
92
|
-
|
|
93
|
-
|
|
94
79
|
class AttachmentBar(Horizontal):
|
|
95
80
|
"""Pending image attachments shown above the prompt. Click a chip to remove it."""
|
|
96
81
|
|
|
@@ -163,24 +148,13 @@ class PromptInput(TextArea):
|
|
|
163
148
|
pass
|
|
164
149
|
|
|
165
150
|
def __init__(self, **kwargs) -> None:
|
|
166
|
-
|
|
167
|
-
super().__init__(
|
|
168
|
-
soft_wrap=True, show_line_numbers=False, tab_behavior="focus",
|
|
169
|
-
placeholder=tr("Напишите задачу (Enter — отправить · / — команды · @ — файлы · Alt+V — скриншот)…"),
|
|
170
|
-
**kwargs,
|
|
171
|
-
)
|
|
172
|
-
except TypeError: # older Textual without TextArea.placeholder
|
|
173
|
-
super().__init__(soft_wrap=True, show_line_numbers=False, tab_behavior="focus", **kwargs)
|
|
151
|
+
super().__init__(soft_wrap=True, show_line_numbers=False, tab_behavior="focus", **kwargs)
|
|
174
152
|
self._prompt_history: list[str] = []
|
|
175
153
|
self._prompt_pos = 0
|
|
176
154
|
self.mention_list: MentionList | None = None
|
|
177
155
|
self.permission_handler = None # set while the agent waits for approval
|
|
178
156
|
self.has_attachments: Callable[[], bool] | None = None
|
|
179
157
|
|
|
180
|
-
def set_hint(self, text: str) -> None:
|
|
181
|
-
if hasattr(self, "placeholder"):
|
|
182
|
-
self.placeholder = text
|
|
183
|
-
|
|
184
158
|
def suggestion_query(self) -> tuple[str, str] | None:
|
|
185
159
|
"""('command', 'rev') while typing '/rev' at the start, ('mention', 'src/a') after '@', else None."""
|
|
186
160
|
row, col = self.cursor_location
|
|
@@ -305,17 +305,15 @@ def test_project_mcp_skills_global_rules_and_wal(tmp_path):
|
|
|
305
305
|
|
|
306
306
|
def test_tui_boots_with_browser_pane_and_todo_bar(tmp_path):
|
|
307
307
|
from anixcode.tui.app import AnixApp
|
|
308
|
-
from anixcode.tui.screens import
|
|
309
|
-
from anixcode.tui.widgets import BrowserPane,
|
|
308
|
+
from anixcode.tui.screens import SetupScreen
|
|
309
|
+
from anixcode.tui.widgets import BrowserPane, TodoBar
|
|
310
310
|
|
|
311
311
|
async def go():
|
|
312
312
|
store = Store(tmp_path / "tui.db")
|
|
313
313
|
app = AnixApp(tmp_path, Settings(provider="deepseek", model="deepseek-chat", animations=False),
|
|
314
314
|
store, base=tmp_path)
|
|
315
315
|
async with app.run_test() as pilot:
|
|
316
|
-
# Centered logo & QuickActionBar are visible on start
|
|
317
316
|
assert app.query_one("#welcome") is not None
|
|
318
|
-
assert app.query_one(QuickActionBar) is not None
|
|
319
317
|
pane = app.query_one(BrowserPane)
|
|
320
318
|
todos = app.query_one(TodoBar)
|
|
321
319
|
assert not pane.display and not todos.display
|
|
@@ -328,16 +326,6 @@ def test_tui_boots_with_browser_pane_and_todo_bar(tmp_path):
|
|
|
328
326
|
app.action_reasoning("medium")
|
|
329
327
|
await pilot.pause()
|
|
330
328
|
assert app.settings.reasoning_effort == "medium"
|
|
331
|
-
# Prefill helper fills /goal cleanly for beginners
|
|
332
|
-
app._prefill("/goal ")
|
|
333
|
-
assert app.query_one(PromptInput).text == "/goal "
|
|
334
|
-
# Quick menu (Ctrl+K) opens and closes cleanly
|
|
335
|
-
app.action_quick_menu()
|
|
336
|
-
await pilot.pause()
|
|
337
|
-
assert isinstance(app.screen, QuickMenuScreen)
|
|
338
|
-
app.screen.action_close()
|
|
339
|
-
await pilot.pause()
|
|
340
|
-
# Setup wizard opens cleanly with pre-filled defaults
|
|
341
329
|
app.action_connect()
|
|
342
330
|
await pilot.pause()
|
|
343
331
|
assert isinstance(app.screen, SetupScreen)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|