lithe-cli 0.2.4__tar.gz → 0.3.1__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.
- lithe_cli-0.3.1/PKG-INFO +422 -0
- lithe_cli-0.3.1/README.md +373 -0
- {lithe_cli-0.2.4 → lithe_cli-0.3.1}/lithe_cli/__init__.py +1 -1
- lithe_cli-0.3.1/lithe_cli/agent.py +651 -0
- lithe_cli-0.3.1/lithe_cli/cli_parser.py +204 -0
- lithe_cli-0.3.1/lithe_cli/clipboard.py +123 -0
- lithe_cli-0.3.1/lithe_cli/commands.py +70 -0
- lithe_cli-0.3.1/lithe_cli/config.py +430 -0
- lithe_cli-0.3.1/lithe_cli/main.py +596 -0
- lithe_cli-0.3.1/lithe_cli/profiles.py +477 -0
- lithe_cli-0.3.1/lithe_cli/prompts.py +171 -0
- lithe_cli-0.3.1/lithe_cli/sessions.py +164 -0
- lithe_cli-0.3.1/lithe_cli/setup.py +190 -0
- lithe_cli-0.3.1/lithe_cli/ttui.py +1387 -0
- lithe_cli-0.3.1/lithe_cli/ttui_render.py +456 -0
- lithe_cli-0.3.1/lithe_cli/ttui_widgets.py +788 -0
- lithe_cli-0.3.1/lithe_cli/tui.py +630 -0
- lithe_cli-0.3.1/lithe_cli/ui.py +366 -0
- lithe_cli-0.3.1/lithe_cli/workbench.py +1118 -0
- lithe_cli-0.3.1/lithe_cli.egg-info/PKG-INFO +422 -0
- lithe_cli-0.3.1/lithe_cli.egg-info/SOURCES.txt +39 -0
- lithe_cli-0.3.1/lithe_cli.egg-info/requires.txt +7 -0
- {lithe_cli-0.2.4 → lithe_cli-0.3.1}/pyproject.toml +1 -1
- lithe_cli-0.3.1/tests/test_cli.py +1173 -0
- lithe_cli-0.3.1/tests/test_cli_budget_steer.py +286 -0
- lithe_cli-0.3.1/tests/test_cli_clipboard.py +179 -0
- lithe_cli-0.3.1/tests/test_cli_guard.py +67 -0
- lithe_cli-0.3.1/tests/test_cli_sessions.py +271 -0
- lithe_cli-0.3.1/tests/test_cli_subagents.py +342 -0
- lithe_cli-0.3.1/tests/test_profiles.py +630 -0
- lithe_cli-0.3.1/tests/test_setup.py +173 -0
- lithe_cli-0.3.1/tests/test_ttui.py +1514 -0
- lithe_cli-0.3.1/tests/test_tui_v2.py +393 -0
- lithe_cli-0.3.1/tests/test_workbench.py +704 -0
- lithe_cli-0.2.4/PKG-INFO +0 -223
- lithe_cli-0.2.4/README.md +0 -176
- lithe_cli-0.2.4/lithe_cli/agent.py +0 -224
- lithe_cli-0.2.4/lithe_cli/config.py +0 -242
- lithe_cli-0.2.4/lithe_cli/main.py +0 -413
- lithe_cli-0.2.4/lithe_cli/setup.py +0 -198
- lithe_cli-0.2.4/lithe_cli/ttyio.py +0 -195
- lithe_cli-0.2.4/lithe_cli/ui.py +0 -214
- lithe_cli-0.2.4/lithe_cli.egg-info/PKG-INFO +0 -223
- lithe_cli-0.2.4/lithe_cli.egg-info/SOURCES.txt +0 -19
- lithe_cli-0.2.4/lithe_cli.egg-info/requires.txt +0 -5
- lithe_cli-0.2.4/tests/test_cli.py +0 -634
- {lithe_cli-0.2.4 → lithe_cli-0.3.1}/LICENSE +0 -0
- {lithe_cli-0.2.4 → lithe_cli-0.3.1}/lithe_cli/__main__.py +0 -0
- {lithe_cli-0.2.4 → lithe_cli-0.3.1}/lithe_cli/py.typed +0 -0
- {lithe_cli-0.2.4 → lithe_cli-0.3.1}/lithe_cli.egg-info/dependency_links.txt +0 -0
- {lithe_cli-0.2.4 → lithe_cli-0.3.1}/lithe_cli.egg-info/entry_points.txt +0 -0
- {lithe_cli-0.2.4 → lithe_cli-0.3.1}/lithe_cli.egg-info/top_level.txt +0 -0
- {lithe_cli-0.2.4 → lithe_cli-0.3.1}/setup.cfg +0 -0
lithe_cli-0.3.1/PKG-INFO
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lithe-cli
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Command-line interface for the lithe agent kernel: chat, one-shot runs, undo, and run inspection.
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 betaloop contributors
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Keywords: agent,llm,react,cli,tool-calling
|
|
28
|
+
Classifier: Development Status :: 4 - Beta
|
|
29
|
+
Classifier: Environment :: Console
|
|
30
|
+
Classifier: Intended Audience :: Developers
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
37
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
38
|
+
Classifier: Typing :: Typed
|
|
39
|
+
Requires-Python: >=3.10
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
License-File: LICENSE
|
|
42
|
+
Requires-Dist: lithe>=0.1.9
|
|
43
|
+
Requires-Dist: prompt-toolkit>=3.0.38
|
|
44
|
+
Requires-Dist: textual>=1.0
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
47
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
# lithe-cli
|
|
51
|
+
|
|
52
|
+
[](https://pypi.org/project/lithe-cli/)
|
|
53
|
+
[](https://pypi.org/project/lithe-cli/)
|
|
54
|
+
[](https://pypi.org/project/lithe-cli/)
|
|
55
|
+
|
|
56
|
+
**lithe-cli** is the command-line interface for
|
|
57
|
+
[lithe](https://pypi.org/project/lithe/) — the storage-free ReAct agent
|
|
58
|
+
kernel. Installing it pulls in `lithe` automatically and gives you a `lithe`
|
|
59
|
+
command: chat with an agent that reads and writes files in your workspace,
|
|
60
|
+
runs code, searches the web through MCP tools, inspects stored runs, and
|
|
61
|
+
undoes a run's mutations.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install lithe-cli
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Configure
|
|
68
|
+
|
|
69
|
+
There is no default endpoint — the CLI refuses to run rather than silently
|
|
70
|
+
hitting some third-party URL. The easiest way in is the wizard: on the
|
|
71
|
+
first `lithe chat` / `lithe run` (or any time, via `lithe config`) an
|
|
72
|
+
interactive terminal walks a **provider-first interview** — profile name,
|
|
73
|
+
provider type (Tab-completed: openai / anthropic / zai / deepseek /
|
|
74
|
+
openrouter / qwen / moonshot, or `none` for a hand-written endpoint),
|
|
75
|
+
base_url (defaults to the preset's official URL — override it to point a
|
|
76
|
+
provider's format at your own router), API key, model — and saves them
|
|
77
|
+
to `$LITHE_HOME/config.json` (mode 0600 — it holds the key). An optional
|
|
78
|
+
connectivity probe catches typos before your first turn, using the
|
|
79
|
+
provider's own auth (`x-api-key` for messages endpoints).
|
|
80
|
+
|
|
81
|
+
The config file holds **named profiles** — several endpoints, one active:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"version": 2,
|
|
86
|
+
"active": "zhipu",
|
|
87
|
+
"profiles": {
|
|
88
|
+
"zhipu": {"base_url": "https://…", "api_key": "…", "model": "glm-4.6",
|
|
89
|
+
"context_window": 128000, "cached_models": ["glm-4.6"]},
|
|
90
|
+
"zai-preset": {"provider": "zai", "api_key": "…", "model": "glm-4.6"}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
A profile may set `"provider"` instead of (or alongside) `base_url`: the
|
|
96
|
+
vendor preset from `lithe.bundles.providers` fills `base_url` when unset
|
|
97
|
+
and contributes `LLMConfig` defaults (transport, `extra_body`,
|
|
98
|
+
`default_headers`) **under** your explicit values — you write the key and
|
|
99
|
+
model, the preset knows the endpoint shape. `--provider` /
|
|
100
|
+
`LITHE_PROVIDER` override the profile field; `config --list` / `--show`
|
|
101
|
+
display it; an unknown name fails loudly with the available presets
|
|
102
|
+
(openai / anthropic / zai / deepseek / openrouter / qwen / moonshot).
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
lithe config # provider-first wizard (edits a named profile)
|
|
106
|
+
lithe config --list # profiles, key masked
|
|
107
|
+
lithe config --use openrouter # switch active profile (script-friendly)
|
|
108
|
+
lithe config --model glm-4.5 # set the active profile's default model
|
|
109
|
+
lithe config --provider anthropic # set the active profile's preset
|
|
110
|
+
# (none/off clears)
|
|
111
|
+
lithe models # GET {base_url}/models, cached into the profile
|
|
112
|
+
# (in chat: /models refreshes the current
|
|
113
|
+
# profile's cache; /models all fans out to
|
|
114
|
+
# every saved profile in parallel)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
A one-shot provider for a single invocation pairs the flag with an
|
|
118
|
+
explicit `--base-url` — the custom-router form without touching the
|
|
119
|
+
config file:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
lithe run --provider openrouter --base-url https://my-router/api/v1 \
|
|
123
|
+
--api-key sk-... --model vendor/claude-sonnet-4 "task"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
To configure by hand instead, point the CLI at any OpenAI-compatible
|
|
127
|
+
endpoint:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
export LITHE_API_KEY=sk-...
|
|
131
|
+
export LITHE_BASE_URL=https://your-endpoint/api/v1
|
|
132
|
+
export LITHE_MODEL=your-model
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Resolution order is flag (`--api-key`, `--base-url`, `--model`) >
|
|
136
|
+
environment > the selected profile's fields, per key; `--profile NAME`
|
|
137
|
+
(or `LITHE_PROFILE`) selects a profile for one invocation. The wizard
|
|
138
|
+
never runs without a TTY on both ends, so pipes and CI keep the hard
|
|
139
|
+
refusal; `--no-setup` restores that fail-fast behavior on terminals
|
|
140
|
+
too. `lithe config --show` peeks at the saved values with a masked key.
|
|
141
|
+
|
|
142
|
+
`LITHE_HOME` (default `~/.lithe`) locates the run store; the agent's
|
|
143
|
+
workspace defaults to the current directory (`--workspace` to change).
|
|
144
|
+
|
|
145
|
+
`lithe doctor` prints the effective configuration — endpoint (with a
|
|
146
|
+
masked key), config file, store, workspace, sandbox backend, skills, MCP
|
|
147
|
+
servers — so you can see what a run would use before starting one.
|
|
148
|
+
|
|
149
|
+
## Use
|
|
150
|
+
|
|
151
|
+
### One-shot task
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
$ cd my-project
|
|
155
|
+
$ lithe run "总结 README.md 的要点,存到 SUMMARY.md"
|
|
156
|
+
⚒ read_file 读取 README.md
|
|
157
|
+
✓ 已读取 README.md(120 行) 0.1s
|
|
158
|
+
⚒ write_file 写入 SUMMARY.md
|
|
159
|
+
✓ 写入 SUMMARY.md(+12 行,新建) 0.0s
|
|
160
|
+
已把要点写入 SUMMARY.md。
|
|
161
|
+
── done · steps 3 · tokens 2100 · cost 0.0042
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
修改已有文件时,助手优先调用 `edit_file` 或 `apply_patch` 做局部更新;只有新建文件或需要整体替换时才使用 `write_file`。工具调用界面只显示工具名、文件路径等摘要,文件写入/编辑的结果带 `+N -M 行` 的行数变化提示(lithe 0.1.0 起由内核统计)。
|
|
165
|
+
|
|
166
|
+
`--stream` streams tokens as they generate; `-v` adds per-call
|
|
167
|
+
usage/context gauges; `--max-steps` caps the tool loop;
|
|
168
|
+
`--context-window` enables fullness gauges; `--reasoning-effort LEVEL`
|
|
169
|
+
sets the reasoning intensity for one invocation (flag > profile field;
|
|
170
|
+
`/reasoning` adjusts it in-session). Run budgets end the turn with
|
|
171
|
+
status `budget_exceeded` once crossed: `--max-cost USD` (needs a
|
|
172
|
+
`pricing` table in the profile on endpoints that report no usage cost)
|
|
173
|
+
and `--max-tokens N` (cumulative); both show progress lines in the
|
|
174
|
+
sidebar and adjust via `/set` (`off` clears). Sampling:
|
|
175
|
+
`--temperature` / `--max-output-tokens` (flag > profile field).
|
|
176
|
+
|
|
177
|
+
### Full-screen interface
|
|
178
|
+
|
|
179
|
+
On an interactive terminal, `lithe chat` and `lithe run TASK` open a
|
|
180
|
+
persistent full-screen interface (built on [Textual](https://textual.textualize.io))
|
|
181
|
+
instead of scribbling one-line events into the console. The chrome is
|
|
182
|
+
deliberately quiet (kilo-style): no box borders and no header strip —
|
|
183
|
+
just the conversation on the left (blocks separated by a breathing
|
|
184
|
+
line; your own messages sit on a solid violet panel with near-white
|
|
185
|
+
text, so quoted input reads as a block), and a sidebar of **collapsible sections** on the right on
|
|
186
|
+
a darker background band — the two panes separate by color alone, with
|
|
187
|
+
no divider line (click a `▾`/`▸` heading to fold/unfold; a folded
|
|
188
|
+
section keeps its one-line summary — the numbers worth a glance never
|
|
189
|
+
require unfolding). There is no run-status section: while a turn runs
|
|
190
|
+
the conversation itself shows a live `⠋ thinking · 12.3s` lane (a
|
|
191
|
+
rotating spinner, the live elapsed, click to unfold the model's
|
|
192
|
+
reasoning), and once the turn ends that lane settles under the output —
|
|
193
|
+
`▸ thought · 4.2s` when the model reasoned, a dim `model · 4.2s` meta
|
|
194
|
+
line otherwise — so the current turn's duration always sits below its
|
|
195
|
+
message. Section headings render bold with their bodies indented
|
|
196
|
+
underneath in regular weight, and a 工作区 section carries the resolved
|
|
197
|
+
workspace path (wrapped at path separators). There is no footer status
|
|
198
|
+
bar — the key map lives in the sidebar's folded 按键 section, and run
|
|
199
|
+
state belongs to the conversation. The prompt is a taller `❯` box (min
|
|
200
|
+
3 lines) on a solid, slightly raised background band whose bottom
|
|
201
|
+
carries a dim info line — `glm-4.6 · zhipu · 推理 high` (model with
|
|
202
|
+
its profile, plus the reasoning effort when one is set), the endpoint
|
|
203
|
+
truth at a glance where you type. Assistant replies render as
|
|
204
|
+
Markdown — headings keep their text but lose the `#` markers (a `▍`
|
|
205
|
+
bar and weight carry the level), `**emphasis**`/`` `code` ``/links
|
|
206
|
+
turn into styled spans, fenced code blocks render whole as
|
|
207
|
+
pygments-highlighted code (the terminal's own 16-color palette via
|
|
208
|
+
rich's `ansi_dark`, unknown language tags fall back to plain), lists
|
|
209
|
+
normalize to `•`/`n.`/task glyphs, and blank lines between paragraphs
|
|
210
|
+
render as nothing (code fences keep them verbatim) so the transcript
|
|
211
|
+
stays dense — while anything that is *not* Markdown
|
|
212
|
+
(bracket pairs like `[dim]`, unclosed markers, intraword `2*3*4`)
|
|
213
|
+
passes through verbatim, and `/copy` still lifts the original
|
|
214
|
+
Markdown off the feed.
|
|
215
|
+
|
|
216
|
+
A fresh, empty conversation opens on a welcome screen — the lithe logo
|
|
217
|
+
plus the effective model, workspace and session, and the handful of keys
|
|
218
|
+
worth knowing — which the first message replaces (it is chrome, never
|
|
219
|
+
feed: `/copy` still reports an empty conversation while it shows).
|
|
220
|
+
|
|
221
|
+
```text
|
|
222
|
+
把 a.txt 改成三行待办清单 │ ▾ 会话
|
|
223
|
+
◆ edit_file · 局部修改 a.txt │ ▾ 工作区
|
|
224
|
+
│ I:\Lithe\my-project
|
|
225
|
+
✓ 编辑 a.txt(+3 -1 行) 0.0s │ ▾ 模型
|
|
226
|
+
│ zhipu · glm-4.6
|
|
227
|
+
⠋ thinking · 4.2s │ zai · chat · F7 端点
|
|
228
|
+
│ ▾ 工具
|
|
229
|
+
│ ✓ edit_file 0.0s
|
|
230
|
+
│ ▾ 待办 1/2
|
|
231
|
+
│ [~] 改 a.txt
|
|
232
|
+
│ ▸ 用量 输入 1,024 · 输出 216 · $0.0008 · 上下文 0.8%
|
|
233
|
+
Tab 采纳 → /model /models /new │ ▸ 按键 F2–F7 · /help
|
|
234
|
+
❯ _ │
|
|
235
|
+
glm-4.6 · zhipu · 推理 high
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Switch without leaving the screen**: `F3` opens the session picker
|
|
239
|
+
(`Enter` switch, `n` new, `d` delete, `r` rename), `F4` the model picker
|
|
240
|
+
(grouped by profile; `Enter` switch, `s` save as the profile's default,
|
|
241
|
+
`r` fetch `/models`), `F5` the settings picker (`Enter` toggles a
|
|
242
|
+
capability; see below), and `F7` the **endpoint manager** — every saved
|
|
243
|
+
profile with its `provider · transport` dialect, base_url and masked
|
|
244
|
+
key; `Enter` switches, `n` creates a profile right in the form (provider
|
|
245
|
+
type cycled with Enter, base_url defaulting to each preset's official
|
|
246
|
+
URL — overridable for custom routers, star-echoed API key; the model
|
|
247
|
+
field is optional — leave it blank and pick from the `/models` listing
|
|
248
|
+
afterwards), `e` edits one, `p` swaps its provider type, `d` deletes one
|
|
249
|
+
after a y/n confirmation. A profile created in the form is
|
|
250
|
+
switched to on save; edits to the current profile apply to the next
|
|
251
|
+
turn. Switching away from a running session does **not**
|
|
252
|
+
cancel it — its badge stays lit and the pane rebuilds from the store when
|
|
253
|
+
you come back. Typing `/` shows matching commands above the prompt (`Tab`
|
|
254
|
+
accepts; `/model`, `/profile`, `/set` complete their arguments too),
|
|
255
|
+
and `↑`/`↓` recall the persistent input history. `Ctrl+C` cancels the
|
|
256
|
+
current turn (a second press during the same turn force-exits) and exits
|
|
257
|
+
when idle. Plain text typed mid-turn **steers** the running agent: it is
|
|
258
|
+
queued into the kernel's steering inbox and injected as a user message at
|
|
259
|
+
the next step boundary (rendered in the transcript; persistently
|
|
260
|
+
recorded), so you can correct course while it works — texts that cannot
|
|
261
|
+
be injected before the turn ends are honestly reported as dropped. Slash
|
|
262
|
+
commands work while a turn runs. The transcript follows new output only
|
|
263
|
+
while you're at the bottom — scroll up to re-read and your position
|
|
264
|
+
sticks.
|
|
265
|
+
|
|
266
|
+
Text selection uses the terminal's native `Shift+drag` (hide the sidebar
|
|
267
|
+
with F2 first if it grabs both panes). Pipes and CI keep the plain
|
|
268
|
+
per-line output unchanged; the legacy prompt_toolkit full-screen was
|
|
269
|
+
removed — the Textual UI is the only full-screen front-end.
|
|
270
|
+
|
|
271
|
+
### Sessions
|
|
272
|
+
|
|
273
|
+
Every chat conversation persists as a kernel conversation (one run per
|
|
274
|
+
turn, messages written incrementally):
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
lithe chat -c # continue the most recent session
|
|
278
|
+
lithe chat --resume 12 # by id (or unique title prefix)
|
|
279
|
+
lithe sessions # list; newest activity first
|
|
280
|
+
lithe sessions --rename 12 规划 # rename
|
|
281
|
+
lithe sessions --delete 12 # soft delete (runs stay: log/undo work)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
A session remembers its last profile and model and restores them on
|
|
285
|
+
resume (unless `--model`/env pinned). Inside chat, the same operations
|
|
286
|
+
are slash commands: `/sessions`, `/resume 12`, `/new [标题]`,
|
|
287
|
+
`/rename 标题`, `/model glm-4.5 [--save]`, `/profile zhipu`,
|
|
288
|
+
`/models`, `/undo`, `/tools`, `/sidebar`, `/help`, `/exit`.
|
|
289
|
+
|
|
290
|
+
### In-session settings
|
|
291
|
+
|
|
292
|
+
The per-turn knobs don't need a restart: `/set` (or `F5`) opens a picker
|
|
293
|
+
where `Enter` toggles a capability, and typed forms set anything —
|
|
294
|
+
`/set shell on`, `/set code off`, `/set vision`, `/set document on`,
|
|
295
|
+
`/set max-steps 50`, `/set timeout 240`, `/set attempts 3`,
|
|
296
|
+
`/set stream on`, `/set verbose`.
|
|
297
|
+
Settings apply to the **next turn** (the running turn keeps its own tool
|
|
298
|
+
set), stay session-scoped (nothing is written to the profile), and
|
|
299
|
+
turning `shell` on restates its trust warning. `/tools` re-derives the
|
|
300
|
+
registry after a capability flip, so the listing always matches what the
|
|
301
|
+
next turn will see.
|
|
302
|
+
|
|
303
|
+
**Reasoning intensity**: `/reasoning` (or `F6`) picks a level —
|
|
304
|
+
`off / minimal / low / medium / high`, or any value your model accepts
|
|
305
|
+
(`none` on some) typed directly; `--save` persists it to the profile. The
|
|
306
|
+
kernel maps it per protocol (`reasoning_effort` on chat-completions,
|
|
307
|
+
`reasoning.effort` on Responses) and combines it with
|
|
308
|
+
`extra_body["reasoning"]` siblings such as OpenRouter's
|
|
309
|
+
`max_tokens`/`exclude`. The sidebar shows the active level when set.
|
|
310
|
+
|
|
311
|
+
### Extra capabilities
|
|
312
|
+
|
|
313
|
+
The kernel ships these as bundles. Default policy: only the execution
|
|
314
|
+
surfaces are off until asked for — the analysis/ingress bundles are on
|
|
315
|
+
out of the box:
|
|
316
|
+
|
|
317
|
+
| Flag | Tools granted | Notes |
|
|
318
|
+
| --- | --- | --- |
|
|
319
|
+
| `--code` | `run_code` / `run_file` | Python under bubblewrap when installed (passthrough otherwise); `doctor` shows which; **off by default** |
|
|
320
|
+
| `--shell` | `run_command` | Native bash/sh on Linux and macOS, PowerShell/cmd on Windows; runs with the current user's host permissions, is not sandboxed, and cannot be undone; **off by default** |
|
|
321
|
+
| `--skills DIR` | `load_skill` | markdown skill library; defaults to `$LITHE_HOME/skills` when it exists, `--skills ""` disables |
|
|
322
|
+
| `--download` / `--no-download` | `download_file` | SSRF-guarded, size-capped network fetch; **on by default** |
|
|
323
|
+
| `--vision` / `--no-vision` | `image_info` / `analyze_image` | image probe is stdlib-only; analysis routes one vision call to the main endpoint; **on by default** |
|
|
324
|
+
| `--document` / `--no-document` | `document_info` / `analyze_document` | PDF/DOCX/XLSX/PPTX reading on the main endpoint; **on by default**; `/set document` toggles in-session |
|
|
325
|
+
| `--document-format` | (dialect for `analyze_document`) | `inline-file` (OpenRouter family) / `files-api` (strict OpenAI upload) / `none` (probe only); default: profile field `document_format`, else provider preset |
|
|
326
|
+
| `--max-cost USD` | (run budget) | the turn ends `budget_exceeded` once cumulative cost crosses it; on endpoints reporting no `usage.cost` add a profile `pricing` table (`{"prompt": 3, "completion": 15}` per 1M) — the preset providers' known prices work too |
|
|
327
|
+
| `--max-tokens N` | (run budget) | cumulative token budget for the turn; `--max-output-tokens N` is the different per-call cap |
|
|
328
|
+
| `--subagents` / `--no-subagents` | `delegate` / `delegate_parallel` | kernel delegation on the default roster — `researcher` (read-only lookup, gains vision/document tools with those flags), `coder` (file edits + `run_code` with `--code`), `operator` (`run_command`/`download_file`, present only with `--shell`/`--download`); children inherit the endpoint and budgets, parallel workers share one live cost ceiling; **on by default** (the roster reuses already-enabled tools only — no new powers); `/set subagents` toggles in-session |
|
|
329
|
+
| `--mcp SPEC` | whatever the servers expose | JSON array/object or `@file` (env `LITHE_MCP`); stdio and streamable-http; failed servers degrade gracefully |
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
$ lithe run --code "用 run_code 验证 results.csv 的行数"
|
|
333
|
+
$ lithe run --document "总结 report.pdf 的结论,存到 NOTES.md"
|
|
334
|
+
$ lithe run --subagents "先让 researcher 摸清 src 结构,再让 coder 分头改"
|
|
335
|
+
$ lithe run --shell "检查当前目录的项目状态"
|
|
336
|
+
$ lithe chat --skills ~/my-skills --mcp @~/mcp.json
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Undo a run
|
|
340
|
+
|
|
341
|
+
The bundled file and todo tools register reverters, so undo works with zero
|
|
342
|
+
configuration:
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
$ lithe runs # find the run
|
|
346
|
+
run status steps cost task
|
|
347
|
+
──────────── ────── ───── ──── ────────────────
|
|
348
|
+
abc123def456 done 3 0.01 总结 README.md …
|
|
349
|
+
$ lithe undo abc123def456
|
|
350
|
+
✓ 已撤销 2 个操作(run abc123def456)
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
A file the run created is deleted; a file it overwrote is restored.
|
|
354
|
+
(`run_code` side effects are not revertible — its tool description warns
|
|
355
|
+
the model.)
|
|
356
|
+
|
|
357
|
+
### Inspect
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
$ lithe runs # stored runs (newest last)
|
|
361
|
+
$ lithe sessions # stored conversations (newest first)
|
|
362
|
+
$ lithe log abc123def456 # messages + actions of one run
|
|
363
|
+
$ lithe models # what the endpoint offers (cached)
|
|
364
|
+
$ lithe doctor # config + capability status
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### Tools
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
$ lithe tools # what the agent can do
|
|
371
|
+
tool category description
|
|
372
|
+
──────────── ──────── ──────────────────────────────
|
|
373
|
+
apply_patch WRITE 以行级 patch 一次修改多个文件…
|
|
374
|
+
read_file READ 读取文件内容…
|
|
375
|
+
...
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
The default tool set is the workspace bundle (`read_file` / `write_file` /
|
|
379
|
+
`edit_file` / `list_files` / `search_files` / `glob_files` /
|
|
380
|
+
`apply_patch`) plus todos (`update_todos` / `list_todos`); the flags above
|
|
381
|
+
add capabilities. (MCP tools attach at run time, so `lithe tools` lists
|
|
382
|
+
them only after a session has started the servers.)
|
|
383
|
+
|
|
384
|
+
### Colors
|
|
385
|
+
|
|
386
|
+
Output is colored when stdout is a TTY and `NO_COLOR` is unset; `--color`
|
|
387
|
+
/ `--no-color` force either way. Output rendering itself stays
|
|
388
|
+
dependency-free — plain text degrades cleanly through pipes and cron.
|
|
389
|
+
Interactive *input* (the chat prompt and the setup wizard) is
|
|
390
|
+
[prompt_toolkit](https://python-prompt-toolkit.readthedocs.io/):
|
|
391
|
+
wide-character-safe editing, bracketed-paste handling, star-echoed API
|
|
392
|
+
keys, inline wizard validation, and persistent history.
|
|
393
|
+
|
|
394
|
+
## Where things land
|
|
395
|
+
|
|
396
|
+
| Path | Contents |
|
|
397
|
+
| --- | --- |
|
|
398
|
+
| current dir (or `--workspace`) | the agent's sandboxed workspace — every tool path resolves strictly inside it |
|
|
399
|
+
| `~/.lithe/config.json` (or `LITHE_HOME`) | endpoint profiles: `{version, active, profiles}` (0600 — it holds keys) |
|
|
400
|
+
| `~/.lithe/runs` (or `--store`) | JSONL run store: conversations, runs, messages, actions, undo records |
|
|
401
|
+
| `~/.lithe/runs/todos-<scope-hash>.json` | the agent's task list, isolated by user and resolved workspace |
|
|
402
|
+
| `~/.lithe/skills` (or `--skills`) | the markdown skill library, when enabled |
|
|
403
|
+
| `~/.lithe/history` | chat input history (prompt_toolkit `FileHistory`; `↑`/`↓` recall in the TUI, Ctrl+R search in the plain REPL) |
|
|
404
|
+
|
|
405
|
+
## Design notes
|
|
406
|
+
|
|
407
|
+
- The CLI is a thin host over a `Workbench`: the workbench owns the
|
|
408
|
+
endpoint view (profile + model), the session manager and the running
|
|
409
|
+
turns; the plain REPL and the full-screen Textual app are both just
|
|
410
|
+
subscribers to its event bus and callers of one dispatcher. Everything
|
|
411
|
+
else (ReAct loop, streaming, budgets, replay, undo engine) is reused
|
|
412
|
+
from lithe.
|
|
413
|
+
- The Textual screen is tested headlessly with `App.run_test()` pilots
|
|
414
|
+
(turns, F2/F3/F4, history, completion) — real interaction tests that
|
|
415
|
+
also run on Windows; its pure builders (sidebar sections, prompt info
|
|
416
|
+
line, Markdown rendering, completion suggestions) and the shared
|
|
417
|
+
`TuiState` event folding have direct unit tests.
|
|
418
|
+
- `python -m lithe_cli` works alongside the `lithe` console script.
|
|
419
|
+
|
|
420
|
+
## License
|
|
421
|
+
|
|
422
|
+
MIT
|