anixcode 0.12.3__tar.gz → 0.12.5__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 (59) hide show
  1. {anixcode-0.12.3 → anixcode-0.12.5}/PKG-INFO +1 -1
  2. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/__init__.py +1 -1
  3. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/commands.py +4 -4
  4. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/i18n_en.py +12 -0
  5. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tui/app.py +41 -91
  6. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tui/app.tcss +9 -29
  7. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tui/screens.py +121 -126
  8. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tui/widgets.py +4 -30
  9. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode.egg-info/PKG-INFO +1 -1
  10. {anixcode-0.12.3 → anixcode-0.12.5}/pyproject.toml +1 -1
  11. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_v011_features.py +23 -13
  12. {anixcode-0.12.3 → anixcode-0.12.5}/LICENSE +0 -0
  13. {anixcode-0.12.3 → anixcode-0.12.5}/README.md +0 -0
  14. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/__main__.py +0 -0
  15. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/agent.py +0 -0
  16. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/airpc.py +0 -0
  17. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/browser.py +0 -0
  18. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/checkpoints.py +0 -0
  19. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/cli.py +0 -0
  20. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/compaction.py +0 -0
  21. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/danger.py +0 -0
  22. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/i18n.py +0 -0
  23. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/images.py +0 -0
  24. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/llm.py +0 -0
  25. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/mcp.py +0 -0
  26. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/mentions.py +0 -0
  27. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/projects.py +0 -0
  28. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/prompts.py +0 -0
  29. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/providers.py +0 -0
  30. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/settings.py +0 -0
  31. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/storage.py +0 -0
  32. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tools/__init__.py +0 -0
  33. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tools/base.py +0 -0
  34. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tools/browser.py +0 -0
  35. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tools/files.py +0 -0
  36. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tools/search.py +0 -0
  37. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tools/shell.py +0 -0
  38. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tools/todo.py +0 -0
  39. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tools/web.py +0 -0
  40. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tui/__init__.py +0 -0
  41. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode/tui/anim.py +0 -0
  42. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode.egg-info/SOURCES.txt +0 -0
  43. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode.egg-info/dependency_links.txt +0 -0
  44. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode.egg-info/entry_points.txt +0 -0
  45. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode.egg-info/requires.txt +0 -0
  46. {anixcode-0.12.3 → anixcode-0.12.5}/anixcode.egg-info/top_level.txt +0 -0
  47. {anixcode-0.12.3 → anixcode-0.12.5}/setup.cfg +0 -0
  48. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_agent.py +0 -0
  49. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_commands.py +0 -0
  50. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_i18n.py +0 -0
  51. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_images.py +0 -0
  52. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_llm.py +0 -0
  53. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_mcp.py +0 -0
  54. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_projects.py +0 -0
  55. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_providers.py +0 -0
  56. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_reliability.py +0 -0
  57. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_safety_mentions.py +0 -0
  58. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_settings.py +0 -0
  59. {anixcode-0.12.3 → anixcode-0.12.5}/tests/test_tools.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anixcode
3
- Version: 0.12.3
3
+ Version: 0.12.5
4
4
  Summary: AI coding agent for the terminal. Bring your own API key.
5
5
  Author: an1zy
6
6
  License-Expression: MIT
@@ -1,3 +1,3 @@
1
1
  """ANIX Code: an AI coding agent for your terminal. Bring your own API key."""
2
2
 
3
- __version__ = "0.12.3"
3
+ __version__ = "0.12.5"
@@ -79,9 +79,8 @@ ACTIONS: tuple[Command, ...] = (
79
79
  Command("undo", tr("откатить правки файлов из последнего ответа"), action="undo"),
80
80
  Command("redo", tr("вернуть то, что откатили /undo"), action="redo"),
81
81
  Command("compact", tr("сжать историю, чтобы освободить контекст"), action="compact"),
82
- Command("model", tr("модель, провайдер и API-ключ"), action="connect"),
83
- Command("models", tr("модель, провайдер и API-ключ"), action="connect"),
84
- Command("connect", tr("подключить провайдера"), action="connect"),
82
+ Command("model", tr("быстро переключить модель текущего провайдера"), action="model", args_hint=tr("[имя]")),
83
+ Command("connect", tr("подключить провайдера и API-ключ"), action="connect"),
85
84
  Command("project", tr("выбрать проект или склонировать репозиторий"), action="project"),
86
85
  Command("theme", tr("выбрать тему"), action="theme"),
87
86
  Command("themes", tr("выбрать тему"), action="theme"),
@@ -159,7 +158,8 @@ def all_commands(root: Path | None = None, config_dir: Path | None = None) -> li
159
158
 
160
159
 
161
160
  def find(name: str, commands: list[Command]) -> Command | None:
162
- return next((c for c in commands if c.name == name.lower()), None)
161
+ target = "model" if name.lower() == "models" else name.lower()
162
+ return next((c for c in commands if c.name == target), None)
163
163
 
164
164
 
165
165
  def parse(text: str) -> tuple[str, str]:
@@ -529,4 +529,16 @@ EN: dict[str, str] = {
529
529
  '✓ Подключение работает! Найдено моделей: {0}. Можно нажимать «Сохранить и начать».':
530
530
  '✓ Connection works! Found {0} models. Click “Save & start”.',
531
531
  '✓ Цель достигнута ({0}/{1})': '✓ Goal achieved ({0}/{1})',
532
+ # v0.12.5: quick model picker (/model & clicking model in statusbar)
533
+ '[имя]': '[name]',
534
+ 'Выбрать': 'Select',
535
+ 'Моделей: {0} · ↑↓ и Enter для выбора': 'Models: {0} · ↑↓ and Enter to pick',
536
+ 'Модель · {0}': 'Model · {0}',
537
+ 'Модель: {0}': 'Model: {0}',
538
+ 'Поиск или название модели…': 'Search or enter a model name…',
539
+ 'Провайдер и ключ': 'Provider & key',
540
+ 'Сервер не вернул список — введите название модели и нажмите Enter.':
541
+ 'Server returned no list — type a model name and press Enter.',
542
+ 'быстро переключить модель текущего провайдера': 'quickly switch model for the current provider',
543
+ 'подключить провайдера и API-ключ': 'connect a provider and API key',
532
544
  }
@@ -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, QuickMenuScreen, SessionsScreen, SetupScreen, ThemeScreen
40
+ from .screens import HelpScreen, ModelPickerScreen, ProjectScreen, SessionsScreen, SetupScreen, ThemeScreen
41
41
  from .widgets import (
42
42
  AssistantMessage, AttachmentBar, BrowserPane, BtwCard, Chip, ErrorMessage, MentionList, Notice, PermissionBar,
43
- PromptInput, QuickActionBar, ReasoningBlock, TodoBar, ToolCard, UserMessage,
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
- yield Chip("", self.action_connect, id="status-model")
122
+ yield Chip("", self.action_model, 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("Ctrl+K: меню · Tab: Build/Plan · Ctrl+O: модель · F1: помощь"), style="dim")
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("Модель не подключена — нажмите здесь"), style="bold yellow")
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:
@@ -577,6 +534,9 @@ class AnixApp(App):
577
534
  if cmd.action == "browser":
578
535
  self.action_browser(args)
579
536
  return
537
+ if cmd.action == "model":
538
+ self.action_model(args)
539
+ return
580
540
  if cmd.action == "reasoning":
581
541
  self.action_reasoning(args)
582
542
  return
@@ -1246,6 +1206,39 @@ class AnixApp(App):
1246
1206
  self.notify(tr("Plan: агент только читает и планирует") if self._agent_mode == "plan"
1247
1207
  else tr("Build: агент может править код"), timeout=2)
1248
1208
 
1209
+ def action_model(self, args: str = "") -> None:
1210
+ if isinstance(self.screen, (ModelPickerScreen, SetupScreen)):
1211
+ return
1212
+ if not self.settings.provider or self._llm_client is None:
1213
+ self.action_connect()
1214
+ return
1215
+ direct = args.strip()
1216
+ if direct:
1217
+ self._switch_model(direct)
1218
+ return
1219
+ provider_name = providers.get(self.settings.provider, self.settings).name
1220
+
1221
+ def done(choice: str | None) -> None:
1222
+ if choice == "__connect__":
1223
+ self.action_connect()
1224
+ return
1225
+ if choice:
1226
+ self._switch_model(choice)
1227
+ self.query_one(PromptInput).focus()
1228
+
1229
+ self.push_screen(ModelPickerScreen(provider_name, self.settings.model, self._llm_client), done)
1230
+
1231
+ def _switch_model(self, model_id: str) -> None:
1232
+ self.settings.model = model_id
1233
+ save_settings(self.settings, self.config_base)
1234
+ if self.agent is not None:
1235
+ self.agent.model = model_id
1236
+ else:
1237
+ self._build_agent()
1238
+ self.session.model = model_id
1239
+ self._refresh_bars()
1240
+ self.notify(tr("Модель: {0}", model_id), timeout=3)
1241
+
1249
1242
  def action_connect(self) -> None:
1250
1243
  if isinstance(self.screen, SetupScreen):
1251
1244
  return
@@ -1263,49 +1256,6 @@ class AnixApp(App):
1263
1256
 
1264
1257
  self.push_screen(SetupScreen(self.settings, self.auth, self.config_base), done)
1265
1258
 
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
1259
  async def _reset_chat(self) -> None:
1310
1260
  chat = self.query_one("#chat", VerticalScroll)
1311
1261
  await chat.remove_children()
@@ -23,57 +23,33 @@ Screen {
23
23
  background: $warning;
24
24
  color: $background;
25
25
  }
26
- #browser-chip, #menu-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, #menu-chip:hover, #mode:hover {
33
+ #browser-chip:hover, #mode:hover {
34
34
  text-style: bold reverse;
35
35
  }
36
- #quick-bar {
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: 2;
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
  }
@@ -284,6 +260,10 @@ ModalScreen {
284
260
  #models.visible {
285
261
  display: block;
286
262
  }
263
+ #model-picker-list {
264
+ height: 14;
265
+ margin: 1 0 0 0;
266
+ }
287
267
  #session-list {
288
268
  height: auto;
289
269
  max-height: 20;
@@ -94,7 +94,7 @@ class ProviderEditScreen(ModalScreen[dict | None]):
94
94
 
95
95
 
96
96
  class SetupScreen(ModalScreen[bool]):
97
- """Beginner-friendly 3-step setup wizard: pick provider, paste key, save (model pre-filled)."""
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("Подключение ИИ-модели"), classes="dialog-title")
117
- yield Static(
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 Static(id="provider-hint", classes="hint")
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("3. Модель (уже выбрана рекомендуемая)"))
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("Сохранить и начать"), id="save", variant="primary")
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
- tr("вставьте ваш API-ключ (sk-…)") if p.needs_key else tr("не обязателен для локальной модели")
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)
@@ -315,6 +270,117 @@ class SetupScreen(ModalScreen[bool]):
315
270
  self.dismiss(False)
316
271
 
317
272
 
273
+ class ModelPickerScreen(ModalScreen[str | None]):
274
+ """Quick model switcher for the active provider: live fetch + search filter.
275
+
276
+ Returns:
277
+ - chosen model id (str)
278
+ - "__connect__" if the user wants to switch provider / edit API key
279
+ - None on cancel
280
+ """
281
+
282
+ BINDINGS = [("escape", "cancel", tr("Отмена"))]
283
+
284
+ def __init__(self, provider_name: str, current_model: str, client) -> None:
285
+ super().__init__()
286
+ self._provider_name = provider_name
287
+ self._current_model = current_model
288
+ self._client = client
289
+ self._all_models: list[str] = []
290
+ self._filtered: list[str] = []
291
+
292
+ def compose(self) -> ComposeResult:
293
+ with Vertical(id="dialog"):
294
+ yield Label(tr("Модель · {0}", self._provider_name), classes="dialog-title")
295
+ yield Input(placeholder=tr("Поиск или название модели…"), id="model-filter")
296
+ yield Static(tr("Загружаю список моделей…"), id="model-picker-status", classes="hint")
297
+ yield OptionList(id="model-picker-list")
298
+ with Horizontal(classes="buttons"):
299
+ yield Button(tr("Выбрать"), id="mp-pick", variant="primary")
300
+ yield Button(tr("Провайдер и ключ"), id="mp-connect")
301
+ yield Button(tr("Отмена"), id="mp-cancel")
302
+
303
+ def on_mount(self) -> None:
304
+ self.query_one("#model-filter", Input).focus()
305
+ self._load_models()
306
+
307
+ @work(exclusive=True, group="model-picker")
308
+ async def _load_models(self) -> None:
309
+ status = self.query_one("#model-picker-status", Static)
310
+ try:
311
+ models = await self._client.list_models()
312
+ except LLMError as e:
313
+ status.update(Text(str(e).splitlines()[0], style="red"))
314
+ return
315
+ self._all_models = models
316
+ if not models:
317
+ status.update(tr("Сервер не вернул список — введите название модели и нажмите Enter."))
318
+ return
319
+ self._render_list(self.query_one("#model-filter", Input).value)
320
+
321
+ def _render_list(self, query: str) -> None:
322
+ q = query.strip().lower()
323
+ self._filtered = [m for m in self._all_models if not q or q in m.lower()]
324
+ box = self.query_one("#model-picker-list", OptionList)
325
+ box.clear_options()
326
+ for m in self._filtered:
327
+ if m == self._current_model:
328
+ box.add_option(Text.assemble(("● ", "bold"), (m, "bold")))
329
+ else:
330
+ box.add_option(Text(f" {m}"))
331
+ status = self.query_one("#model-picker-status", Static)
332
+ status.update(tr("Моделей: {0} · ↑↓ и Enter для выбора", len(self._filtered)))
333
+ if self._filtered:
334
+ if self._current_model in self._filtered and not q:
335
+ box.highlighted = self._filtered.index(self._current_model)
336
+ else:
337
+ box.highlighted = 0
338
+
339
+ @on(Input.Changed, "#model-filter")
340
+ def _filter_changed(self, event: Input.Changed) -> None:
341
+ if self._all_models:
342
+ self._render_list(event.value)
343
+
344
+ @on(Input.Submitted, "#model-filter")
345
+ def _filter_submitted(self) -> None:
346
+ self._confirm()
347
+
348
+ @on(OptionList.OptionSelected, "#model-picker-list")
349
+ def _option_picked(self, event: OptionList.OptionSelected) -> None:
350
+ if 0 <= event.option_index < len(self._filtered):
351
+ self.dismiss(self._filtered[event.option_index])
352
+
353
+ def _confirm(self) -> None:
354
+ box = self.query_one("#model-picker-list", OptionList)
355
+ typed = self.query_one("#model-filter", Input).value.strip()
356
+ if self._filtered and box.highlighted is not None and 0 <= box.highlighted < len(self._filtered):
357
+ self.dismiss(self._filtered[box.highlighted])
358
+ elif typed:
359
+ self.dismiss(typed)
360
+
361
+ def on_key(self, event) -> None:
362
+ if event.key in ("down", "up") and self._filtered:
363
+ box = self.query_one("#model-picker-list", OptionList)
364
+ if event.key == "down":
365
+ box.action_cursor_down()
366
+ else:
367
+ box.action_cursor_up()
368
+ event.stop()
369
+ event.prevent_default()
370
+
371
+ @on(Button.Pressed, "#mp-pick")
372
+ def _pick_pressed(self) -> None:
373
+ self._confirm()
374
+
375
+ @on(Button.Pressed, "#mp-connect")
376
+ def _connect_pressed(self) -> None:
377
+ self.dismiss("__connect__")
378
+
379
+ @on(Button.Pressed, "#mp-cancel")
380
+ def action_cancel(self) -> None:
381
+ self.dismiss(None)
382
+
383
+
318
384
  class ThemeScreen(ModalScreen[str | None]):
319
385
  """Theme picker with live preview."""
320
386
 
@@ -451,77 +517,6 @@ class HelpScreen(ModalScreen[None]):
451
517
  self.dismiss(None)
452
518
 
453
519
 
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
520
  CUSTOM_HELP = tr("""\
526
521
  ## Свои команды
527
522
 
@@ -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 [Разрешить ⏎] [Всегда] [Отклонить esc] [Полный доступ]"."""
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("Изменить файл") if req.kind == "edit" else (tr("Прочитать секретный файл") if req.kind == "read" else 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("\nНажмите Enter — разрешить · Esc — отклонить · или напишите словами, как сделать иначе"),
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
- try:
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anixcode
3
- Version: 0.12.3
3
+ Version: 0.12.5
4
4
  Summary: AI coding agent for the terminal. Bring your own API key.
5
5
  Author: an1zy
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "anixcode"
3
- version = "0.12.3"
3
+ version = "0.12.5"
4
4
  description = "AI coding agent for the terminal. Bring your own API key."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -305,17 +305,22 @@ 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 QuickMenuScreen, SetupScreen
309
- from anixcode.tui.widgets import BrowserPane, PromptInput, QuickActionBar, TodoBar
308
+ from anixcode.tui.screens import ModelPickerScreen, SetupScreen
309
+ from anixcode.tui.widgets import BrowserPane, TodoBar
310
+
311
+ class FakeModelClient:
312
+ async def list_models(self):
313
+ return ["deepseek-chat", "deepseek-reasoner", "qwen-coder"]
314
+
315
+ async def aclose(self):
316
+ pass
310
317
 
311
318
  async def go():
312
319
  store = Store(tmp_path / "tui.db")
313
320
  app = AnixApp(tmp_path, Settings(provider="deepseek", model="deepseek-chat", animations=False),
314
321
  store, base=tmp_path)
315
322
  async with app.run_test() as pilot:
316
- # Centered logo & QuickActionBar are visible on start
317
323
  assert app.query_one("#welcome") is not None
318
- assert app.query_one(QuickActionBar) is not None
319
324
  pane = app.query_one(BrowserPane)
320
325
  todos = app.query_one(TodoBar)
321
326
  assert not pane.display and not todos.display
@@ -328,16 +333,21 @@ def test_tui_boots_with_browser_pane_and_todo_bar(tmp_path):
328
333
  app.action_reasoning("medium")
329
334
  await pilot.pause()
330
335
  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()
336
+
337
+ # Direct /model <name> switches immediately
338
+ app._llm_client = FakeModelClient()
339
+ app.action_model("qwen-coder")
340
+ assert app.settings.model == "qwen-coder" and app.agent.model == "qwen-coder"
341
+
342
+ # Clicking model / calling /model opens ModelPickerScreen with live list & filter
343
+ app.action_model()
344
+ await pilot.pause(0.1)
345
+ assert isinstance(app.screen, ModelPickerScreen)
346
+ app.screen._render_list("reasoner")
347
+ app.screen._confirm()
339
348
  await pilot.pause()
340
- # Setup wizard opens cleanly with pre-filled defaults
349
+ assert app.settings.model == "deepseek-reasoner" and app.agent.model == "deepseek-reasoner"
350
+
341
351
  app.action_connect()
342
352
  await pilot.pause()
343
353
  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