lithe-cli 0.8.4__tar.gz → 0.8.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.
Potentially problematic release.
This version of lithe-cli might be problematic. Click here for more details.
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/PKG-INFO +1 -1
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/__init__.py +1 -1
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/commands.py +1 -1
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/ttui.py +51 -2
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/tui.py +25 -3
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli.egg-info/PKG-INFO +1 -1
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/tests/test_ttui.py +47 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/LICENSE +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/README.md +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/__main__.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/agent.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/config.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/main.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/profiles.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/prompts.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/py.typed +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/sessions.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/setup.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/ui.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli/workbench.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli.egg-info/SOURCES.txt +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli.egg-info/dependency_links.txt +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli.egg-info/entry_points.txt +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli.egg-info/requires.txt +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/lithe_cli.egg-info/top_level.txt +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/pyproject.toml +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/setup.cfg +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/tests/test_cli.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/tests/test_cli_sessions.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/tests/test_profiles.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/tests/test_tui_v2.py +0 -0
- {lithe_cli-0.8.4 → lithe_cli-0.8.5}/tests/test_workbench.py +0 -0
|
@@ -24,7 +24,7 @@ COMMANDS: dict[str, tuple[str, str]] = {
|
|
|
24
24
|
"models": ("", "从端点拉取模型列表并缓存"),
|
|
25
25
|
"reasoning": ("[级别|--save]", "查看/设置推理强度(F6 同效);off/minimal/low/medium/high,下一轮生效"),
|
|
26
26
|
"profile": ("[名称]", "查看/切换 provider 档案"),
|
|
27
|
-
"set": ("[名称] [值]", "查看/调整运行设置(F5
|
|
27
|
+
"set": ("[名称] [值]", "查看/调整运行设置(F5 同效);面板内空格连切不关闭、Enter 切换并关闭,下一轮生效"),
|
|
28
28
|
"tools": ("", "列出已注册的工具"),
|
|
29
29
|
"undo": ("[run]", "撤销当前会话最近一轮(或指定 run)的文件改动"),
|
|
30
30
|
"sidebar": ("", "显示/隐藏右侧状态栏(F2 同效)"),
|
|
@@ -24,6 +24,7 @@ Known gap versus the prompt_toolkit screen: no in-app mouse-drag selection
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
26
|
import asyncio
|
|
27
|
+
from collections.abc import Callable
|
|
27
28
|
from typing import Any
|
|
28
29
|
|
|
29
30
|
from textual.app import App, ComposeResult
|
|
@@ -271,15 +272,20 @@ class PickerModal(ModalScreen):
|
|
|
271
272
|
Binding("d", "letter('d')", show=False),
|
|
272
273
|
Binding("r", "letter('r')", show=False),
|
|
273
274
|
Binding("s", "letter('s')", show=False),
|
|
275
|
+
# In-place toggle for the settings picker: flips the focused row
|
|
276
|
+
# without dismissing, so several knobs change in one visit.
|
|
277
|
+
Binding("space", "toggle", "切换(不关闭)", priority=True),
|
|
274
278
|
]
|
|
275
279
|
|
|
276
280
|
def __init__(self, title: str, items: list[tuple[dict, str]],
|
|
277
|
-
hint: str = "", letter_actions: dict[str, str] | None = None
|
|
281
|
+
hint: str = "", letter_actions: dict[str, str] | None = None,
|
|
282
|
+
live_toggle: Callable[[dict], str | None] | None = None):
|
|
278
283
|
super().__init__()
|
|
279
284
|
self.title = title
|
|
280
285
|
self.items = items
|
|
281
286
|
self.hint = hint
|
|
282
287
|
self.letter_actions = letter_actions or {}
|
|
288
|
+
self.live_toggle = live_toggle
|
|
283
289
|
|
|
284
290
|
def compose(self) -> ComposeResult:
|
|
285
291
|
with Vertical(id="picker"):
|
|
@@ -316,6 +322,25 @@ class PickerModal(ModalScreen):
|
|
|
316
322
|
payload = self._current_payload()
|
|
317
323
|
self.dismiss(("letter", name, payload) if name else None)
|
|
318
324
|
|
|
325
|
+
def action_toggle(self) -> None:
|
|
326
|
+
"""Flip the focused row in place: the ``live_toggle`` callback
|
|
327
|
+
applies the change and returns a rebuilt label (``None`` when the
|
|
328
|
+
row is not toggleable); the modal stays open."""
|
|
329
|
+
if self.live_toggle is None:
|
|
330
|
+
return
|
|
331
|
+
view = self.query_one("#picker-list", ListView)
|
|
332
|
+
index = view.index if view.index is not None else 0
|
|
333
|
+
if not 0 <= index < len(self.items):
|
|
334
|
+
return
|
|
335
|
+
payload = self.items[index][0]
|
|
336
|
+
label = self.live_toggle(payload)
|
|
337
|
+
if label is None:
|
|
338
|
+
return
|
|
339
|
+
self.items[index] = (payload, label)
|
|
340
|
+
row = view.children[index]
|
|
341
|
+
if row.children:
|
|
342
|
+
row.children[0].update(label)
|
|
343
|
+
|
|
319
344
|
|
|
320
345
|
# -- the app ----------------------------------------------------------------------
|
|
321
346
|
|
|
@@ -524,6 +549,8 @@ class LitheApp(App):
|
|
|
524
549
|
if t == "command_output":
|
|
525
550
|
self.state.say(ev.get("style") or "", ev.get("text", ""))
|
|
526
551
|
self._sync_feed()
|
|
552
|
+
self._refresh_meta() # e.g. /models just rewrote cached_models
|
|
553
|
+
self._refresh_chrome()
|
|
527
554
|
return
|
|
528
555
|
if t == "undo_done":
|
|
529
556
|
self.state.say("ok", f"已撤销 {ev.get('reverted', 0)} 个操作"
|
|
@@ -669,7 +696,9 @@ class LitheApp(App):
|
|
|
669
696
|
))
|
|
670
697
|
self.push_screen(PickerModal(
|
|
671
698
|
"运行设置", items,
|
|
672
|
-
"Enter
|
|
699
|
+
"空格 切换(不关闭)· Enter 切换并关闭 · 数值项用 /set 名称 值"
|
|
700
|
+
" · Esc 关闭",
|
|
701
|
+
live_toggle=self._toggle_setting_live,
|
|
673
702
|
), self._set_picked)
|
|
674
703
|
elif name == "reasoning":
|
|
675
704
|
from .workbench import REASONING_LEVELS
|
|
@@ -725,6 +754,26 @@ class LitheApp(App):
|
|
|
725
754
|
self._refresh_chrome()
|
|
726
755
|
self._sync_feed()
|
|
727
756
|
|
|
757
|
+
def _toggle_setting_live(self, payload) -> str | None:
|
|
758
|
+
"""F5 picker's in-place toggle (space): flip the knob via the same
|
|
759
|
+
bare ``set_setting`` call /set makes, refresh the chrome, and hand
|
|
760
|
+
back the row's rebuilt label; hints are not toggleable."""
|
|
761
|
+
if not payload or payload.get("kind") == "hint":
|
|
762
|
+
return None
|
|
763
|
+
r = self.wb.set_setting(payload["key"]) # bare value toggles booleans
|
|
764
|
+
for cls, text in r.messages:
|
|
765
|
+
self.state.say(cls, text)
|
|
766
|
+
if r.changed:
|
|
767
|
+
self._refresh_meta()
|
|
768
|
+
self._refresh_chrome()
|
|
769
|
+
self._sync_feed()
|
|
770
|
+
row = next(row for row in self.wb.settings_rows()
|
|
771
|
+
if row["key"] == payload["key"])
|
|
772
|
+
value = row["value"]
|
|
773
|
+
shown = "on" if value else "off"
|
|
774
|
+
return (f"{'[green]●[/] ' if value else '○ '}"
|
|
775
|
+
f"{row['key']:<10} {shown:<4}{row['label']}")
|
|
776
|
+
|
|
728
777
|
def _set_picked(self, result) -> None:
|
|
729
778
|
if not result or result[0] != "select" or not result[1]:
|
|
730
779
|
return
|
|
@@ -771,7 +771,8 @@ def settings_overlay_items(setting_rows: list[dict]) -> list[dict]:
|
|
|
771
771
|
"label": f" {row['key']:<10} {shown!s:<6}{row['label']}"
|
|
772
772
|
f"(/set {row['key']} 值)"})
|
|
773
773
|
items.append({"kind": "hint",
|
|
774
|
-
"label": "Enter
|
|
774
|
+
"label": "空格 切换(不关闭)· Enter 切换并关闭 · 数值项用 "
|
|
775
|
+
"/set 名称 值 · Esc 关闭"})
|
|
775
776
|
return items
|
|
776
777
|
|
|
777
778
|
|
|
@@ -988,6 +989,10 @@ def build_app(
|
|
|
988
989
|
def _overlay_enter(event):
|
|
989
990
|
_select(state.overlay_current())
|
|
990
991
|
|
|
992
|
+
@kb.add("space", filter=overlay_open, eager=True)
|
|
993
|
+
def _overlay_space(event):
|
|
994
|
+
_key(" ")
|
|
995
|
+
|
|
991
996
|
@kb.add("n", filter=overlay_open, eager=True)
|
|
992
997
|
@kb.add("d", filter=overlay_open, eager=True)
|
|
993
998
|
@kb.add("r", filter=overlay_open, eager=True)
|
|
@@ -1257,6 +1262,7 @@ async def run_screen(cfg, task, mode, args=None):
|
|
|
1257
1262
|
if t == "command_output":
|
|
1258
1263
|
state.say(ev.get("style") if ev.get("style") in _SAY_CLASSES
|
|
1259
1264
|
else "dim", ev.get("text", ""))
|
|
1265
|
+
_refresh_meta(state) # e.g. /models just rewrote cached_models
|
|
1260
1266
|
return
|
|
1261
1267
|
if t == "undo_done":
|
|
1262
1268
|
state.say("ok", "已撤销 " + str(ev.get("reverted", 0)) + " 个操作"
|
|
@@ -1321,8 +1327,9 @@ async def run_screen(cfg, task, mode, args=None):
|
|
|
1321
1327
|
_say_result(wb.set_model(item["model"]))
|
|
1322
1328
|
_refresh_meta(state)
|
|
1323
1329
|
elif name == "set":
|
|
1324
|
-
# Enter on a boolean row toggles it (same call /set
|
|
1325
|
-
_say_result(wb.set_setting(item["key"]
|
|
1330
|
+
# Enter on a boolean row toggles it (same bare call /set makes)
|
|
1331
|
+
_say_result(wb.set_setting(item["key"]))
|
|
1332
|
+
_refresh_meta(state)
|
|
1326
1333
|
elif name == "reasoning":
|
|
1327
1334
|
_say_result(wb.set_reasoning(item["level"]))
|
|
1328
1335
|
_refresh_meta(state)
|
|
@@ -1366,6 +1373,21 @@ async def run_screen(cfg, task, mode, args=None):
|
|
|
1366
1373
|
_say_result(wb.set_reasoning(item["level"], save=True))
|
|
1367
1374
|
_refresh_meta(state)
|
|
1368
1375
|
|
|
1376
|
+
elif name == "set":
|
|
1377
|
+
if key == " ":
|
|
1378
|
+
item = state.overlay_current()
|
|
1379
|
+
if not item: # hint rows are not toggleable
|
|
1380
|
+
return
|
|
1381
|
+
_say_result(wb.set_setting(item["key"]))
|
|
1382
|
+
_refresh_meta(state)
|
|
1383
|
+
row = next(r for r in wb.settings_rows()
|
|
1384
|
+
if r["key"] == item["key"])
|
|
1385
|
+
value = row["value"]
|
|
1386
|
+
shown = "on" if value else "off"
|
|
1387
|
+
item["label"] = (f"{'●' if value else '○'} "
|
|
1388
|
+
f"{row['key']:<10} {shown:<4}{row['label']}")
|
|
1389
|
+
state.invalidate()
|
|
1390
|
+
|
|
1369
1391
|
# -- input ----------------------------------------------------------------
|
|
1370
1392
|
|
|
1371
1393
|
def on_line(text):
|
|
@@ -354,3 +354,50 @@ def test_f5_settings_picker_toggles_bool(tmp_path):
|
|
|
354
354
|
assert "shell:off → on" in _conv_text(app)
|
|
355
355
|
|
|
356
356
|
asyncio.run(scenario())
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def test_f5_space_toggles_in_place_without_closing(tmp_path):
|
|
360
|
+
"""Regression: Enter was the only toggle and it dismissed the picker,
|
|
361
|
+
so flipping several knobs meant reopening F5 per knob. Space now
|
|
362
|
+
flips the focused row in place and the modal stays open."""
|
|
363
|
+
|
|
364
|
+
async def scenario():
|
|
365
|
+
app = _app(tmp_path, [])
|
|
366
|
+
async with app.run_test(size=(100, 30)) as pilot:
|
|
367
|
+
await pilot.press("f5")
|
|
368
|
+
await pilot.pause()
|
|
369
|
+
assert isinstance(app.screen, PickerModal)
|
|
370
|
+
await pilot.press("space") # shell off -> on
|
|
371
|
+
await pilot.pause()
|
|
372
|
+
assert app.cfg.shell is True
|
|
373
|
+
assert isinstance(app.screen, PickerModal), "空格不得关闭设置面板"
|
|
374
|
+
await pilot.press("down")
|
|
375
|
+
await pilot.press("space") # code off -> on
|
|
376
|
+
await pilot.pause()
|
|
377
|
+
assert app.cfg.code is True and app.cfg.shell is True
|
|
378
|
+
assert isinstance(app.screen, PickerModal)
|
|
379
|
+
# the flipped row's label reflects the new state in place
|
|
380
|
+
labels = [label for _payload, label in app.screen.items]
|
|
381
|
+
assert any("shell" in text and "●" in text for text in labels)
|
|
382
|
+
|
|
383
|
+
asyncio.run(scenario())
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
def test_command_output_refreshes_model_candidates(tmp_path):
|
|
387
|
+
"""Regression: /models rewrote cached_models in the profile, but the
|
|
388
|
+
session's F4 list and /model completion stayed stale until an
|
|
389
|
+
unrelated event happened to call _refresh_meta."""
|
|
390
|
+
|
|
391
|
+
async def scenario():
|
|
392
|
+
app = _app(tmp_path, [])
|
|
393
|
+
async with app.run_test(size=(100, 30)) as pilot:
|
|
394
|
+
await pilot.pause()
|
|
395
|
+
app.cfg.model = "fresh-model"
|
|
396
|
+
app.wb._emit(-1, {"type": "command_output", "style": "ok",
|
|
397
|
+
"text": "端点返回 2 个模型"})
|
|
398
|
+
await pilot.pause()
|
|
399
|
+
assert app.state.model == "fresh-model"
|
|
400
|
+
assert app.state.model_candidates[0] == "fresh-model"
|
|
401
|
+
assert "端点返回" in _conv_text(app)
|
|
402
|
+
|
|
403
|
+
asyncio.run(scenario())
|
|
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
|