lithe-cli 0.7.0__tar.gz → 0.8.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.

Potentially problematic release.


This version of lithe-cli might be problematic. Click here for more details.

Files changed (32) hide show
  1. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/PKG-INFO +36 -35
  2. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/README.md +34 -34
  3. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/__init__.py +1 -1
  4. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/main.py +30 -0
  5. lithe_cli-0.8.0/lithe_cli/ttui.py +776 -0
  6. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli.egg-info/PKG-INFO +36 -35
  7. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli.egg-info/SOURCES.txt +2 -0
  8. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli.egg-info/requires.txt +1 -0
  9. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/pyproject.toml +1 -1
  10. lithe_cli-0.8.0/tests/test_ttui.py +308 -0
  11. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/LICENSE +0 -0
  12. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/__main__.py +0 -0
  13. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/agent.py +0 -0
  14. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/commands.py +0 -0
  15. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/config.py +0 -0
  16. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/profiles.py +0 -0
  17. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/prompts.py +0 -0
  18. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/py.typed +0 -0
  19. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/sessions.py +0 -0
  20. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/setup.py +0 -0
  21. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/tui.py +0 -0
  22. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/ui.py +0 -0
  23. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli/workbench.py +0 -0
  24. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli.egg-info/dependency_links.txt +0 -0
  25. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli.egg-info/entry_points.txt +0 -0
  26. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/lithe_cli.egg-info/top_level.txt +0 -0
  27. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/setup.cfg +0 -0
  28. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/tests/test_cli.py +0 -0
  29. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/tests/test_cli_sessions.py +0 -0
  30. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/tests/test_profiles.py +0 -0
  31. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/tests/test_tui_v2.py +0 -0
  32. {lithe_cli-0.7.0 → lithe_cli-0.8.0}/tests/test_workbench.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lithe-cli
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Summary: Command-line interface for the lithe agent kernel: chat, one-shot runs, undo, and run inspection.
5
5
  License: MIT License
6
6
 
@@ -41,6 +41,7 @@ Description-Content-Type: text/markdown
41
41
  License-File: LICENSE
42
42
  Requires-Dist: lithe>=0.9.14
43
43
  Requires-Dist: prompt-toolkit>=3.0.38
44
+ Requires-Dist: textual>=1.0
44
45
  Provides-Extra: dev
45
46
  Requires-Dist: pytest>=8; extra == "dev"
46
47
  Requires-Dist: ruff>=0.4; extra == "dev"
@@ -141,25 +142,27 @@ usage/context gauges; `--max-steps` caps the tool loop;
141
142
  ### Full-screen interface
142
143
 
143
144
  On an interactive terminal, `lithe chat` and `lithe run TASK` open a
144
- persistent full-screen interface instead of scribbling one-line events
145
- into the console. The left pane is the conversation; the right sidebar
146
- is five fixed sections — 会话(current + recent ones, `●` marks sessions
147
- with a turn still running)、模型、运行、工具/待办、用量:
145
+ persistent full-screen interface (built on [Textual](https://textual.textualize.io))
146
+ instead of scribbling one-line events into the console. The left pane is
147
+ the conversation; the right sidebar is five fixed sections — 会话(current
148
+ + recent ones, `●` marks sessions with a turn still running)、模型、运行、
149
+ 工具/待办、用量:
148
150
 
149
151
  ```text
150
- lithe 0.7.0 · zhipu · glm-4.6 │ ▣ #12 重构计划 │ ~/myproj ● 运行中
151
- ╭─ 对话 ──────────────────────────────╮╭─ 运行状态 ─────────╮
152
- │ 把 a.txt 改成三行待办清单 ││ ◆ 会话 │
153
- │ ◆ edit_file · 局部修改 a.txt ││ #12 重构计划 ● │
154
- │ ✓ 编辑 a.txt(+3 -1 行) 0.0s ││ #11 bugfix ✓ 7轮 │
155
- │ 已完成。 ││ F3 切换 · /new 新建│
156
- │ ││ ◆ 模型 │
157
- │ ││ zhipu · glm-4.6 │
158
- │ ││ ◆ 会话用量 │
159
- │ ││ 输入 1,024 · 输出 216│
160
- ╰──────────────────────────────────────╯╰─────────────────────╯
161
- lithe ❯ _
162
- ● 运行中 · 步骤 2/35 Enter 发送 · F3 会话 · F4 模型 · /help
152
+ lithe 0.8.0 · ▣ #12 重构计划 │ zhipu · glm-4.6 │ ~/myproj ● 运行中
153
+ ╭──────────────────────────────────────╮╭──────────────────────────╮
154
+ │ 把 a.txt 改成三行待办清单 ││ ◆ 会话 │
155
+ │ ◆ edit_file · 局部修改 a.txt ││ #12 重构计划 ● │
156
+ │ ✓ 编辑 a.txt(+3 -1 行) 0.0s ││ #11 bugfix ✓ 7轮 │
157
+ │ 已完成。 ││ F3 切换 · /new 新建 │
158
+ │ ││ ◆ 模型 │
159
+ │ ││ zhipu · glm-4.6 │
160
+ │ ││ ◆ 会话用量 │
161
+ │ ││ 输入 1,024 · 输出 216 │
162
+ ╰──────────────────────────────────────╯╰──────────────────────────╯
163
+ Tab 采纳 → /model /models /new
164
+ lithe ❯ _
165
+ ● 运行中 · 步骤 2/35 Enter 发送 · F2 侧栏 · F3 会话 · F4 模型 · /help
163
166
  ```
164
167
 
165
168
  **Switch without leaving the screen**: `F3` opens the session picker
@@ -167,19 +170,16 @@ lithe ❯ _
167
170
  (grouped by profile; `Enter` switch, `s` save as the profile's default,
168
171
  `r` fetch `/models`). Switching away from a running session does **not**
169
172
  cancel it — its badge stays lit and the pane rebuilds from the store when
170
- you come back. Typing `/` pops an inline completion menu (commands, then
171
- model/profile names as arguments). `Ctrl+C` cancels the current turn,
172
- copies when a conversation selection is active, and exits when idle.
173
-
174
- The conversation has an application-managed mouse selection: drag across
175
- its text and press `Ctrl+C` to copy only the selected conversation,
176
- without sidebar content. `Shift+drag` bypasses the application and uses
177
- the terminal's native selection, which can cross both panes; hide the
178
- sidebar with F2 or `/sidebar` before using native selection. The
179
- conversation scrolls with the mouse wheel, PageUp/PageDown and Home/End
180
- (a new turn jumps back to the output). Layout, wrapping and alignment
181
- are East-Asian-width aware; narrower terminals stack the two panes
182
- vertically. Pipes and CI keep the plain per-line output unchanged.
173
+ you come back. Typing `/` shows matching commands above the prompt (`Tab`
174
+ accepts; `/model`, `/profile`, `/resume` complete their arguments too),
175
+ and `↑`/`↓` recall the persistent input history. `Ctrl+C` cancels the
176
+ current turn and exits when idle.
177
+
178
+ Text selection uses the terminal's native `Shift+drag` (hide the sidebar
179
+ with F2 first if it grabs both panes). The earlier prompt_toolkit screen —
180
+ which adds in-app mouse selection and OSC 52 copy — remains available with
181
+ `--ui prompt` / `LITHE_UI=prompt`. Pipes and CI keep the plain per-line
182
+ output unchanged.
183
183
 
184
184
  ### Sessions
185
185
 
@@ -289,13 +289,14 @@ keys, inline wizard validation, and persistent history.
289
289
 
290
290
  - The CLI is a thin host over a `Workbench`: the workbench owns the
291
291
  endpoint view (profile + model), the session manager and the running
292
- turns; the plain REPL and the full-screen TUI are both just
292
+ turns; the plain REPL and the full-screen Textual app are both just
293
293
  subscribers to its event bus and callers of one dispatcher. Everything
294
294
  else (ReAct loop, streaming, budgets, replay, undo engine) is reused
295
295
  from lithe.
296
- - End-to-end behavior is tested offline against a scripted transport — no
297
- test spends tokens. The TUI's row builders are pure functions tested
298
- headless; only key handling needs a real PTY (POSIX CI).
296
+ - The Textual screen is tested headlessly with `App.run_test()` pilots
297
+ (turns, F2/F3/F4, history, completion) — real interaction tests that
298
+ also run on Windows; the legacy prompt_toolkit screen keeps its pure
299
+ row-builder tests plus POSIX-only PTY tests.
299
300
  - `python -m lithe_cli` works alongside the `lithe` console script.
300
301
 
301
302
  ## License
@@ -93,25 +93,27 @@ usage/context gauges; `--max-steps` caps the tool loop;
93
93
  ### Full-screen interface
94
94
 
95
95
  On an interactive terminal, `lithe chat` and `lithe run TASK` open a
96
- persistent full-screen interface instead of scribbling one-line events
97
- into the console. The left pane is the conversation; the right sidebar
98
- is five fixed sections — 会话(current + recent ones, `●` marks sessions
99
- with a turn still running)、模型、运行、工具/待办、用量:
96
+ persistent full-screen interface (built on [Textual](https://textual.textualize.io))
97
+ instead of scribbling one-line events into the console. The left pane is
98
+ the conversation; the right sidebar is five fixed sections — 会话(current
99
+ + recent ones, `●` marks sessions with a turn still running)、模型、运行、
100
+ 工具/待办、用量:
100
101
 
101
102
  ```text
102
- lithe 0.7.0 · zhipu · glm-4.6 │ ▣ #12 重构计划 │ ~/myproj ● 运行中
103
- ╭─ 对话 ──────────────────────────────╮╭─ 运行状态 ─────────╮
104
- │ 把 a.txt 改成三行待办清单 ││ ◆ 会话 │
105
- │ ◆ edit_file · 局部修改 a.txt ││ #12 重构计划 ● │
106
- │ ✓ 编辑 a.txt(+3 -1 行) 0.0s ││ #11 bugfix ✓ 7轮 │
107
- │ 已完成。 ││ F3 切换 · /new 新建│
108
- │ ││ ◆ 模型 │
109
- │ ││ zhipu · glm-4.6 │
110
- │ ││ ◆ 会话用量 │
111
- │ ││ 输入 1,024 · 输出 216│
112
- ╰──────────────────────────────────────╯╰─────────────────────╯
113
- lithe ❯ _
114
- ● 运行中 · 步骤 2/35 Enter 发送 · F3 会话 · F4 模型 · /help
103
+ lithe 0.8.0 · ▣ #12 重构计划 │ zhipu · glm-4.6 │ ~/myproj ● 运行中
104
+ ╭──────────────────────────────────────╮╭──────────────────────────╮
105
+ │ 把 a.txt 改成三行待办清单 ││ ◆ 会话 │
106
+ │ ◆ edit_file · 局部修改 a.txt ││ #12 重构计划 ● │
107
+ │ ✓ 编辑 a.txt(+3 -1 行) 0.0s ││ #11 bugfix ✓ 7轮 │
108
+ │ 已完成。 ││ F3 切换 · /new 新建 │
109
+ │ ││ ◆ 模型 │
110
+ │ ││ zhipu · glm-4.6 │
111
+ │ ││ ◆ 会话用量 │
112
+ │ ││ 输入 1,024 · 输出 216 │
113
+ ╰──────────────────────────────────────╯╰──────────────────────────╯
114
+ Tab 采纳 → /model /models /new
115
+ lithe ❯ _
116
+ ● 运行中 · 步骤 2/35 Enter 发送 · F2 侧栏 · F3 会话 · F4 模型 · /help
115
117
  ```
116
118
 
117
119
  **Switch without leaving the screen**: `F3` opens the session picker
@@ -119,19 +121,16 @@ lithe ❯ _
119
121
  (grouped by profile; `Enter` switch, `s` save as the profile's default,
120
122
  `r` fetch `/models`). Switching away from a running session does **not**
121
123
  cancel it — its badge stays lit and the pane rebuilds from the store when
122
- you come back. Typing `/` pops an inline completion menu (commands, then
123
- model/profile names as arguments). `Ctrl+C` cancels the current turn,
124
- copies when a conversation selection is active, and exits when idle.
125
-
126
- The conversation has an application-managed mouse selection: drag across
127
- its text and press `Ctrl+C` to copy only the selected conversation,
128
- without sidebar content. `Shift+drag` bypasses the application and uses
129
- the terminal's native selection, which can cross both panes; hide the
130
- sidebar with F2 or `/sidebar` before using native selection. The
131
- conversation scrolls with the mouse wheel, PageUp/PageDown and Home/End
132
- (a new turn jumps back to the output). Layout, wrapping and alignment
133
- are East-Asian-width aware; narrower terminals stack the two panes
134
- vertically. Pipes and CI keep the plain per-line output unchanged.
124
+ you come back. Typing `/` shows matching commands above the prompt (`Tab`
125
+ accepts; `/model`, `/profile`, `/resume` complete their arguments too),
126
+ and `↑`/`↓` recall the persistent input history. `Ctrl+C` cancels the
127
+ current turn and exits when idle.
128
+
129
+ Text selection uses the terminal's native `Shift+drag` (hide the sidebar
130
+ with F2 first if it grabs both panes). The earlier prompt_toolkit screen —
131
+ which adds in-app mouse selection and OSC 52 copy — remains available with
132
+ `--ui prompt` / `LITHE_UI=prompt`. Pipes and CI keep the plain per-line
133
+ output unchanged.
135
134
 
136
135
  ### Sessions
137
136
 
@@ -241,13 +240,14 @@ keys, inline wizard validation, and persistent history.
241
240
 
242
241
  - The CLI is a thin host over a `Workbench`: the workbench owns the
243
242
  endpoint view (profile + model), the session manager and the running
244
- turns; the plain REPL and the full-screen TUI are both just
243
+ turns; the plain REPL and the full-screen Textual app are both just
245
244
  subscribers to its event bus and callers of one dispatcher. Everything
246
245
  else (ReAct loop, streaming, budgets, replay, undo engine) is reused
247
246
  from lithe.
248
- - End-to-end behavior is tested offline against a scripted transport — no
249
- test spends tokens. The TUI's row builders are pure functions tested
250
- headless; only key handling needs a real PTY (POSIX CI).
247
+ - The Textual screen is tested headlessly with `App.run_test()` pilots
248
+ (turns, F2/F3/F4, history, completion) — real interaction tests that
249
+ also run on Windows; the legacy prompt_toolkit screen keeps its pure
250
+ row-builder tests plus POSIX-only PTY tests.
251
251
  - `python -m lithe_cli` works alongside the `lithe` console script.
252
252
 
253
253
  ## License
@@ -1,3 +1,3 @@
1
1
  """lithe-cli: the command-line interface for the lithe agent kernel."""
2
2
 
3
- __version__ = "0.7.0"
3
+ __version__ = "0.8.0"
@@ -27,6 +27,7 @@ from __future__ import annotations
27
27
 
28
28
  import argparse
29
29
  import asyncio
30
+ import os
30
31
  import sys
31
32
  from typing import Any
32
33
 
@@ -112,6 +113,13 @@ def build_parser() -> argparse.ArgumentParser:
112
113
  sp.add_argument(
113
114
  "--stream", action="store_true", help="stream tokens as they generate"
114
115
  )
116
+ sp.add_argument(
117
+ "--ui",
118
+ choices=["textual", "prompt"],
119
+ default=None,
120
+ help="full-screen frontend (env LITHE_UI; default: textual; "
121
+ "'prompt' is the legacy prompt_toolkit screen)",
122
+ )
115
123
  sp.add_argument(
116
124
  "--no-setup",
117
125
  action="store_true",
@@ -584,6 +592,24 @@ def _chat_loop(
584
592
  return 0
585
593
 
586
594
 
595
+ def _resolve_ui(args: Any) -> str:
596
+ """Which full-screen frontend: 'textual' (default) or 'prompt'."""
597
+ ui = getattr(args, "ui", None) or os.environ.get("LITHE_UI") or ""
598
+ ui = ui.strip().lower()
599
+ return ui if ui in ("prompt", "textual") else "textual"
600
+
601
+
602
+ def _run_textual(cfg: Any, task: str | None, mode: str, args: Any) -> int:
603
+ try:
604
+ from .ttui import run_textual_screen
605
+ except ImportError as exc: # pragma: no cover - depends on install
606
+ raise SystemExit(
607
+ f"Textual 前端不可用({exc})。pip install textual,"
608
+ "或用 --ui prompt 走旧版界面。"
609
+ ) from exc
610
+ return asyncio.run(run_textual_screen(cfg, task, mode, args))
611
+
612
+
587
613
  def main(argv: list[str] | None = None) -> int:
588
614
  args = build_parser().parse_args(argv)
589
615
  if args.command is None:
@@ -594,6 +620,8 @@ def main(argv: list[str] | None = None) -> int:
594
620
  if args.command == "run":
595
621
  require_endpoint(cfg, interactive=not args.no_setup)
596
622
  if screen_supported():
623
+ if _resolve_ui(args) == "textual":
624
+ return _run_textual(cfg, args.task, "run", args)
597
625
  from .tui import run_screen
598
626
 
599
627
  return asyncio.run(run_screen(cfg, args.task, "run"))
@@ -601,6 +629,8 @@ def main(argv: list[str] | None = None) -> int:
601
629
  if args.command == "chat":
602
630
  require_endpoint(cfg, interactive=not args.no_setup)
603
631
  if screen_supported():
632
+ if _resolve_ui(args) == "textual":
633
+ return _run_textual(cfg, None, "chat", args)
604
634
  from .tui import run_screen
605
635
 
606
636
  return asyncio.run(run_screen(cfg, None, "chat", args))