lithe-cli 0.3.2__tar.gz → 0.4.2__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 (55) hide show
  1. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/PKG-INFO +89 -4
  2. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/README.md +84 -1
  3. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/__init__.py +1 -1
  4. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/agent.py +360 -23
  5. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/cli_parser.py +58 -3
  6. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/clipboard.py +39 -2
  7. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/config.py +51 -7
  8. lithe_cli-0.4.2/lithe_cli/diag.py +169 -0
  9. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/main.py +337 -83
  10. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/present.py +3 -3
  11. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/profiles.py +190 -39
  12. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/prompts.py +7 -5
  13. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/sessions.py +8 -8
  14. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/setup.py +16 -3
  15. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/ttui/app.py +84 -18
  16. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/ttui/copy.py +20 -1
  17. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/ttui/pickers.py +48 -10
  18. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/ttui_render.py +11 -2
  19. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/ttui_widgets.py +56 -18
  20. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/ui.py +40 -0
  21. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/workbench/core.py +39 -6
  22. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/workbench/dispatch.py +36 -4
  23. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/workbench/endpoints.py +34 -4
  24. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/workbench/settings.py +14 -0
  25. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/workbench/turns.py +47 -11
  26. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli.egg-info/PKG-INFO +89 -4
  27. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli.egg-info/SOURCES.txt +5 -0
  28. lithe_cli-0.4.2/lithe_cli.egg-info/requires.txt +9 -0
  29. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/pyproject.toml +20 -2
  30. lithe_cli-0.4.2/tests/test_agent_instructions.py +242 -0
  31. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/tests/test_cli.py +106 -2
  32. lithe_cli-0.4.2/tests/test_cli_surface.py +819 -0
  33. lithe_cli-0.4.2/tests/test_diag.py +284 -0
  34. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/tests/test_profiles.py +142 -0
  35. lithe_cli-0.4.2/tests/test_retention.py +75 -0
  36. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/tests/test_ttui.py +107 -0
  37. lithe_cli-0.3.2/lithe_cli.egg-info/requires.txt +0 -7
  38. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/LICENSE +0 -0
  39. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/__main__.py +0 -0
  40. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/commands.py +0 -0
  41. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/py.typed +0 -0
  42. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/ttui/__init__.py +0 -0
  43. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli/workbench/__init__.py +0 -0
  44. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli.egg-info/dependency_links.txt +0 -0
  45. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli.egg-info/entry_points.txt +0 -0
  46. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/lithe_cli.egg-info/top_level.txt +0 -0
  47. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/setup.cfg +0 -0
  48. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/tests/test_cli_budget_steer.py +0 -0
  49. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/tests/test_cli_clipboard.py +0 -0
  50. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/tests/test_cli_guard.py +0 -0
  51. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/tests/test_cli_sessions.py +0 -0
  52. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/tests/test_cli_subagents.py +0 -0
  53. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/tests/test_present.py +0 -0
  54. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/tests/test_setup.py +0 -0
  55. {lithe_cli-0.3.2 → lithe_cli-0.4.2}/tests/test_workbench.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lithe-cli
3
- Version: 0.3.2
3
+ Version: 0.4.2
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
 
@@ -39,12 +39,14 @@ Classifier: Typing :: Typed
39
39
  Requires-Python: >=3.10
40
40
  Description-Content-Type: text/markdown
41
41
  License-File: LICENSE
42
- Requires-Dist: lithe>=0.1.9
42
+ Requires-Dist: lithe>=0.2.2
43
43
  Requires-Dist: prompt-toolkit>=3.0.38
44
- Requires-Dist: textual>=1.0
44
+ Requires-Dist: textual<9,>=1.0
45
45
  Provides-Extra: dev
46
46
  Requires-Dist: pytest>=8; extra == "dev"
47
+ Requires-Dist: pytest-cov>=4; extra == "dev"
47
48
  Requires-Dist: ruff>=0.4; extra == "dev"
49
+ Requires-Dist: mypy>=1.8; extra == "dev"
48
50
  Dynamic: license-file
49
51
 
50
52
  # lithe-cli
@@ -123,6 +125,12 @@ lithe run --provider openrouter --base-url https://my-router/api/v1 \
123
125
  --api-key sk-... --model vendor/claude-sonnet-4 "task"
124
126
  ```
125
127
 
128
+ `--api-key` puts the secret in argv (process lists, shell history). The
129
+ same pin without that exposure: `--api-key-file PATH` reads a one-line
130
+ file, `--api-key-env VAR` reads a named environment variable. Order is
131
+ `--api-key` > `--api-key-file` > `--api-key-env` > `LITHE_API_KEY` > the
132
+ profile's saved key.
133
+
126
134
  To configure by hand instead, point the CLI at any OpenAI-compatible
127
135
  endpoint:
128
136
 
@@ -174,6 +182,34 @@ and `--max-tokens N` (cumulative); both show progress lines in the
174
182
  sidebar and adjust via `/set` (`off` clears). Sampling:
175
183
  `--temperature` / `--max-output-tokens` (flag > profile field).
176
184
 
185
+ `lithe run -` reads the task from stdin instead of argv — for long,
186
+ multi-line or generated prompts (`cat task.txt | lithe run -`,
187
+ `git diff | lithe run -`). A TTY or an empty pipe refuses with exit code 2
188
+ and the pipe syntax spelled out, rather than blocking the terminal or
189
+ running an empty task (an upstream command that failed quietly).
190
+
191
+ `--resume ID|标题` (or `-c` / `--continue` for the latest session) appends
192
+ the task as one turn of a stored conversation — the earlier messages are
193
+ replayed, so the follow-up keeps its context — and always prints the plain
194
+ line-mode rendering, even on a TTY: it is the scripted continuation
195
+ (`lithe run -c "接着上次的计划,列出下一步"`), not a chat. `--plain` (or
196
+ `LITHE_PLAIN=1`) forces the same line mode for any `run` / `chat` — the
197
+ escape hatch for editors' embedded terminals, slow SSH links, and anyone
198
+ who does not want the full-screen UI for one invocation.
199
+
200
+ `lithe run` exits with a code scripts can branch on — the same table for
201
+ the line renderer, `--resume` and the full-screen one-shot:
202
+
203
+ | Code | Status | Meaning |
204
+ | --- | --- | --- |
205
+ | 0 | `done` | the turn finished with a final answer |
206
+ | 1 | `failed` / `empty_response` / anything unknown | the run errored, the model answered nothing, or no status arrived — never a silent success |
207
+ | 2 | `cancelled` | stopped with Ctrl+C (the run's stop handle) |
208
+ | 3 | `max_steps` | the tool-loop step budget ran out |
209
+ | 4 | `budget_exceeded` | `--max-cost` / `--max-tokens` was crossed |
210
+
211
+ Ctrl+C interrupting the process itself still exits 130.
212
+
177
213
  ### Full-screen interface
178
214
 
179
215
  On an interactive terminal, `lithe chat` and `lithe run TASK` open a
@@ -265,7 +301,8 @@ sticks.
265
301
 
266
302
  Text selection uses the terminal's native `Shift+drag` (hide the sidebar
267
303
  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
304
+ per-line output unchanged (`--plain` / `LITHE_PLAIN=1` keeps it on a TTY
305
+ too); the legacy prompt_toolkit full-screen was
269
306
  removed — the Textual UI is the only full-screen front-end.
270
307
 
271
308
  ### Sessions
@@ -336,6 +373,25 @@ $ lithe run --shell "检查当前目录的项目状态"
336
373
  $ lithe chat --skills ~/my-skills --mcp @~/mcp.json
337
374
  ```
338
375
 
376
+ ### Workspace instructions
377
+
378
+ A project can carry its own conventions the way peer coding agents do. When
379
+ the workspace root holds `LITHE.md`, `AGENTS.md` or `CLAUDE.md` (first match,
380
+ in that order), its text is injected into the system prompt — after the
381
+ built-in rules, before the environment facts — and into every subagent's
382
+ prompt, so the `coder` worker knows the project's conventions too. The file
383
+ is read as data (64 KiB cap; a longer file is truncated with a note).
384
+ `--instructions PATH` names another file (a missing one is a hard error),
385
+ `--no-instructions` loads nothing.
386
+
387
+ ```bash
388
+ $ cat > AGENTS.md <<'EOF'
389
+ Run `pytest -q` and `ruff check .` before declaring a change done.
390
+ Keep user-facing strings Chinese; docstrings explain why, not what.
391
+ EOF
392
+ $ lithe run "给 undo 的 --dry-run 补一个测试"
393
+ ```
394
+
339
395
  ### Undo a run
340
396
 
341
397
  The bundled file and todo tools register reverters, so undo works with zero
@@ -364,6 +420,27 @@ $ lithe models # what the endpoint offers (cached)
364
420
  $ lithe doctor # config + capability status
365
421
  ```
366
422
 
423
+ `runs`, `sessions`, `log` and `models` take `--json`: exactly one JSON
424
+ document on stdout (indent 2, UTF-8), no colors, hint lines or `(…)`
425
+ notes. `runs` prints a list of run dicts (`run_id`, `status`, `steps`,
426
+ `cost`, `model`, `task`, `created_at`, `finished_at`, `conversation_id`,
427
+ `error`, `duration_s` — the store's epoch-second stamps, duration their
428
+ difference; newest last like the table), `sessions` the conversation
429
+ summaries exactly as stored, `log` a
430
+ `{"run": …, "messages": […], "actions": [{id, kind, target, status}]}`
431
+ object, `models` the id list (still cached into the profile). Diagnostics
432
+ go to stderr and the exit code stays nonzero, so `json.loads(stdout)`
433
+ after a zero exit is always safe.
434
+
435
+ `lithe models` authenticates the way the profile's provider expects — the
436
+ same request `/models` makes in chat: `x-api-key` + `anthropic-version`
437
+ for `messages` endpoints, Bearer otherwise, plus the profile's
438
+ `default_headers` — and names the real failure instead of a generic
439
+ "cannot connect": the host it could not reach (`连不上 host`),
440
+ `端点拒绝了该 key(HTTP 401)` for a refused key, `HTTP 500`, or a 200
441
+ that is not a model list. A failed fetch still prints the cached list
442
+ and exits 1.
443
+
367
444
  ### Tools
368
445
 
369
446
  ```bash
@@ -401,6 +478,8 @@ keys, inline wizard validation, and persistent history.
401
478
  | `~/.lithe/runs/todos-<scope-hash>.json` | the agent's task list, isolated by user and resolved workspace |
402
479
  | `~/.lithe/skills` (or `--skills`) | the markdown skill library, when enabled |
403
480
  | `~/.lithe/history` | chat input history (prompt_toolkit `FileHistory`; `↑`/`↓` recall in the TUI, Ctrl+R search in the plain REPL) |
481
+ | `~/.lithe/clipboard-*.txt` | last-resort copy targets (when neither a clipboard tool nor OSC 52 works); pruned after 7 days |
482
+ | `~/.lithe/logs/lithe.log` | rotating diagnostic log (1 MiB × 3), written only when `LITHE_LOG=debug|info|warning|error` is set — ids, statuses and timings; never keys, prompts or answers |
404
483
 
405
484
  ## Design notes
406
485
 
@@ -416,6 +495,12 @@ keys, inline wizard validation, and persistent history.
416
495
  line, Markdown rendering, completion suggestions) and the shared
417
496
  `TuiState` event folding have direct unit tests.
418
497
  - `python -m lithe_cli` works alongside the `lithe` console script.
498
+ - The package ships `py.typed` and is held to it: `mypy` runs in CI
499
+ (`check_untyped_defs`, `no_implicit_optional`), and the suite is gated
500
+ at 83 % line coverage (`pytest --cov-fail-under`). Dependencies get
501
+ weekly dependabot updates; `textual` is capped to its current major.
502
+ - `SECURITY.md` says what handles secrets and how to report a problem;
503
+ `CONTRIBUTING.md` covers the dev setup, the checks and the release flow.
419
504
 
420
505
  ## License
421
506
 
@@ -74,6 +74,12 @@ lithe run --provider openrouter --base-url https://my-router/api/v1 \
74
74
  --api-key sk-... --model vendor/claude-sonnet-4 "task"
75
75
  ```
76
76
 
77
+ `--api-key` puts the secret in argv (process lists, shell history). The
78
+ same pin without that exposure: `--api-key-file PATH` reads a one-line
79
+ file, `--api-key-env VAR` reads a named environment variable. Order is
80
+ `--api-key` > `--api-key-file` > `--api-key-env` > `LITHE_API_KEY` > the
81
+ profile's saved key.
82
+
77
83
  To configure by hand instead, point the CLI at any OpenAI-compatible
78
84
  endpoint:
79
85
 
@@ -125,6 +131,34 @@ and `--max-tokens N` (cumulative); both show progress lines in the
125
131
  sidebar and adjust via `/set` (`off` clears). Sampling:
126
132
  `--temperature` / `--max-output-tokens` (flag > profile field).
127
133
 
134
+ `lithe run -` reads the task from stdin instead of argv — for long,
135
+ multi-line or generated prompts (`cat task.txt | lithe run -`,
136
+ `git diff | lithe run -`). A TTY or an empty pipe refuses with exit code 2
137
+ and the pipe syntax spelled out, rather than blocking the terminal or
138
+ running an empty task (an upstream command that failed quietly).
139
+
140
+ `--resume ID|标题` (or `-c` / `--continue` for the latest session) appends
141
+ the task as one turn of a stored conversation — the earlier messages are
142
+ replayed, so the follow-up keeps its context — and always prints the plain
143
+ line-mode rendering, even on a TTY: it is the scripted continuation
144
+ (`lithe run -c "接着上次的计划,列出下一步"`), not a chat. `--plain` (or
145
+ `LITHE_PLAIN=1`) forces the same line mode for any `run` / `chat` — the
146
+ escape hatch for editors' embedded terminals, slow SSH links, and anyone
147
+ who does not want the full-screen UI for one invocation.
148
+
149
+ `lithe run` exits with a code scripts can branch on — the same table for
150
+ the line renderer, `--resume` and the full-screen one-shot:
151
+
152
+ | Code | Status | Meaning |
153
+ | --- | --- | --- |
154
+ | 0 | `done` | the turn finished with a final answer |
155
+ | 1 | `failed` / `empty_response` / anything unknown | the run errored, the model answered nothing, or no status arrived — never a silent success |
156
+ | 2 | `cancelled` | stopped with Ctrl+C (the run's stop handle) |
157
+ | 3 | `max_steps` | the tool-loop step budget ran out |
158
+ | 4 | `budget_exceeded` | `--max-cost` / `--max-tokens` was crossed |
159
+
160
+ Ctrl+C interrupting the process itself still exits 130.
161
+
128
162
  ### Full-screen interface
129
163
 
130
164
  On an interactive terminal, `lithe chat` and `lithe run TASK` open a
@@ -216,7 +250,8 @@ sticks.
216
250
 
217
251
  Text selection uses the terminal's native `Shift+drag` (hide the sidebar
218
252
  with F2 first if it grabs both panes). Pipes and CI keep the plain
219
- per-line output unchanged; the legacy prompt_toolkit full-screen was
253
+ per-line output unchanged (`--plain` / `LITHE_PLAIN=1` keeps it on a TTY
254
+ too); the legacy prompt_toolkit full-screen was
220
255
  removed — the Textual UI is the only full-screen front-end.
221
256
 
222
257
  ### Sessions
@@ -287,6 +322,25 @@ $ lithe run --shell "检查当前目录的项目状态"
287
322
  $ lithe chat --skills ~/my-skills --mcp @~/mcp.json
288
323
  ```
289
324
 
325
+ ### Workspace instructions
326
+
327
+ A project can carry its own conventions the way peer coding agents do. When
328
+ the workspace root holds `LITHE.md`, `AGENTS.md` or `CLAUDE.md` (first match,
329
+ in that order), its text is injected into the system prompt — after the
330
+ built-in rules, before the environment facts — and into every subagent's
331
+ prompt, so the `coder` worker knows the project's conventions too. The file
332
+ is read as data (64 KiB cap; a longer file is truncated with a note).
333
+ `--instructions PATH` names another file (a missing one is a hard error),
334
+ `--no-instructions` loads nothing.
335
+
336
+ ```bash
337
+ $ cat > AGENTS.md <<'EOF'
338
+ Run `pytest -q` and `ruff check .` before declaring a change done.
339
+ Keep user-facing strings Chinese; docstrings explain why, not what.
340
+ EOF
341
+ $ lithe run "给 undo 的 --dry-run 补一个测试"
342
+ ```
343
+
290
344
  ### Undo a run
291
345
 
292
346
  The bundled file and todo tools register reverters, so undo works with zero
@@ -315,6 +369,27 @@ $ lithe models # what the endpoint offers (cached)
315
369
  $ lithe doctor # config + capability status
316
370
  ```
317
371
 
372
+ `runs`, `sessions`, `log` and `models` take `--json`: exactly one JSON
373
+ document on stdout (indent 2, UTF-8), no colors, hint lines or `(…)`
374
+ notes. `runs` prints a list of run dicts (`run_id`, `status`, `steps`,
375
+ `cost`, `model`, `task`, `created_at`, `finished_at`, `conversation_id`,
376
+ `error`, `duration_s` — the store's epoch-second stamps, duration their
377
+ difference; newest last like the table), `sessions` the conversation
378
+ summaries exactly as stored, `log` a
379
+ `{"run": …, "messages": […], "actions": [{id, kind, target, status}]}`
380
+ object, `models` the id list (still cached into the profile). Diagnostics
381
+ go to stderr and the exit code stays nonzero, so `json.loads(stdout)`
382
+ after a zero exit is always safe.
383
+
384
+ `lithe models` authenticates the way the profile's provider expects — the
385
+ same request `/models` makes in chat: `x-api-key` + `anthropic-version`
386
+ for `messages` endpoints, Bearer otherwise, plus the profile's
387
+ `default_headers` — and names the real failure instead of a generic
388
+ "cannot connect": the host it could not reach (`连不上 host`),
389
+ `端点拒绝了该 key(HTTP 401)` for a refused key, `HTTP 500`, or a 200
390
+ that is not a model list. A failed fetch still prints the cached list
391
+ and exits 1.
392
+
318
393
  ### Tools
319
394
 
320
395
  ```bash
@@ -352,6 +427,8 @@ keys, inline wizard validation, and persistent history.
352
427
  | `~/.lithe/runs/todos-<scope-hash>.json` | the agent's task list, isolated by user and resolved workspace |
353
428
  | `~/.lithe/skills` (or `--skills`) | the markdown skill library, when enabled |
354
429
  | `~/.lithe/history` | chat input history (prompt_toolkit `FileHistory`; `↑`/`↓` recall in the TUI, Ctrl+R search in the plain REPL) |
430
+ | `~/.lithe/clipboard-*.txt` | last-resort copy targets (when neither a clipboard tool nor OSC 52 works); pruned after 7 days |
431
+ | `~/.lithe/logs/lithe.log` | rotating diagnostic log (1 MiB × 3), written only when `LITHE_LOG=debug|info|warning|error` is set — ids, statuses and timings; never keys, prompts or answers |
355
432
 
356
433
  ## Design notes
357
434
 
@@ -367,6 +444,12 @@ keys, inline wizard validation, and persistent history.
367
444
  line, Markdown rendering, completion suggestions) and the shared
368
445
  `TuiState` event folding have direct unit tests.
369
446
  - `python -m lithe_cli` works alongside the `lithe` console script.
447
+ - The package ships `py.typed` and is held to it: `mypy` runs in CI
448
+ (`check_untyped_defs`, `no_implicit_optional`), and the suite is gated
449
+ at 83 % line coverage (`pytest --cov-fail-under`). Dependencies get
450
+ weekly dependabot updates; `textual` is capped to its current major.
451
+ - `SECURITY.md` says what handles secrets and how to report a problem;
452
+ `CONTRIBUTING.md` covers the dev setup, the checks and the release flow.
370
453
 
371
454
  ## License
372
455
 
@@ -1,3 +1,3 @@
1
1
  """lithe-cli: the command-line interface for the lithe agent kernel."""
2
2
 
3
- __version__ = "0.3.2"
3
+ __version__ = "0.4.2"