lithe-cli 0.9.3__tar.gz → 0.9.4__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 (35) hide show
  1. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/PKG-INFO +3 -3
  2. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/README.md +1 -1
  3. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/__init__.py +1 -1
  4. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/agent.py +8 -5
  5. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/config.py +13 -6
  6. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/main.py +8 -6
  7. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli.egg-info/PKG-INFO +3 -3
  8. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli.egg-info/requires.txt +1 -1
  9. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/pyproject.toml +1 -1
  10. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/tests/test_cli.py +17 -0
  11. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/tests/test_cli_subagents.py +22 -5
  12. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/LICENSE +0 -0
  13. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/__main__.py +0 -0
  14. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/commands.py +0 -0
  15. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/profiles.py +0 -0
  16. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/prompts.py +0 -0
  17. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/py.typed +0 -0
  18. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/sessions.py +0 -0
  19. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/setup.py +0 -0
  20. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/ttui.py +0 -0
  21. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/tui.py +0 -0
  22. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/ui.py +0 -0
  23. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli/workbench.py +0 -0
  24. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli.egg-info/SOURCES.txt +0 -0
  25. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli.egg-info/dependency_links.txt +0 -0
  26. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli.egg-info/entry_points.txt +0 -0
  27. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/lithe_cli.egg-info/top_level.txt +0 -0
  28. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/setup.cfg +0 -0
  29. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/tests/test_cli_budget_steer.py +0 -0
  30. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/tests/test_cli_guard.py +0 -0
  31. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/tests/test_cli_sessions.py +0 -0
  32. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/tests/test_profiles.py +0 -0
  33. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/tests/test_ttui.py +0 -0
  34. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/tests/test_tui_v2.py +0 -0
  35. {lithe_cli-0.9.3 → lithe_cli-0.9.4}/tests/test_workbench.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lithe-cli
3
- Version: 0.9.3
3
+ Version: 0.9.4
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,7 +39,7 @@ 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.9.24
42
+ Requires-Dist: lithe>=0.9.3
43
43
  Requires-Dist: prompt-toolkit>=3.0.38
44
44
  Requires-Dist: textual>=1.0
45
45
  Provides-Extra: dev
@@ -260,7 +260,7 @@ The kernel ships these as bundles; the CLI grants them per flag:
260
260
  | `--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 |
261
261
  | `--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 |
262
262
  | `--max-tokens N` | (run budget) | cumulative token budget for the turn; `--max-output-tokens N` is the different per-call cap |
263
- | `--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; `/set subagents` toggles in-session |
263
+ | `--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 |
264
264
  | `--mcp SPEC` | whatever the servers expose | JSON array/object or `@file` (env `LITHE_MCP`); stdio and streamable-http; failed servers degrade gracefully |
265
265
 
266
266
  ```bash
@@ -211,7 +211,7 @@ The kernel ships these as bundles; the CLI grants them per flag:
211
211
  | `--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 |
212
212
  | `--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 |
213
213
  | `--max-tokens N` | (run budget) | cumulative token budget for the turn; `--max-output-tokens N` is the different per-call cap |
214
- | `--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; `/set subagents` toggles in-session |
214
+ | `--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 |
215
215
  | `--mcp SPEC` | whatever the servers expose | JSON array/object or `@file` (env `LITHE_MCP`); stdio and streamable-http; failed servers degrade gracefully |
216
216
 
217
217
  ```bash
@@ -1,3 +1,3 @@
1
1
  """lithe-cli: the command-line interface for the lithe agent kernel."""
2
2
 
3
- __version__ = "0.9.3"
3
+ __version__ = "0.9.4"
@@ -50,11 +50,14 @@ from .ui import CYAN, GREEN, YELLOW, ui
50
50
 
51
51
  SYSTEM_PROMPT_BASE = (
52
52
  "你是运行在命令行里的助理,工作区是用户的当前目录。"
53
- "用提供的文件工具完成任务(读写前先读、谨慎修改);修改已有文件时优先用 edit_file 或 apply_patch 做局部修改,"
54
- "仅在新建文件或确需整体重写时使用 write_file。"
53
+ "文件路径一律用工作区内的相对路径,不要用绝对路径或 ../ 指向工作区之外。\n"
54
+ "用提供的文件工具完成任务:改文件前先读它,谨慎修改;"
55
+ "修改已有文件时优先用 edit_file 或 apply_patch 做局部修改,"
56
+ "仅在新建文件或确需整体重写时使用 write_file。\n"
57
+ "工具调用失败时,先读返回的错误信息,修正参数后重试,不要原样重发。\n"
55
58
  "只有用户明确要求计划/跟踪,或任务确有多个需要追踪的独立阶段时才调用 update_todos;"
56
59
  "普通问答、解释、单步操作和小改动不创建待办。已有清单仅在用户继续相关工作时更新,无关请求保持不变;"
57
- "更新前读取并保留相关的现有任务,条数按实际步骤确定,不使用固定数量。"
60
+ "更新前读取并保留相关的现有任务,条数按实际步骤确定,不使用固定数量。\n"
58
61
  "最后用简洁中文汇报结果。"
59
62
  )
60
63
 
@@ -96,7 +99,7 @@ def build_system_prompt(cfg: Config) -> str:
96
99
  "子代理与本对话共享预算,汇报时合并它们的结果。")
97
100
  if not extras:
98
101
  return SYSTEM_PROMPT_BASE
99
- return SYSTEM_PROMPT_BASE + "".join(extras)
102
+ return SYSTEM_PROMPT_BASE + "\n" + "\n".join(extras)
100
103
 
101
104
 
102
105
  def build_llm(cfg: Config) -> LLMConfig:
@@ -240,7 +243,7 @@ def register_subagents(cfg: Config, host: AgentHost, reg: ToolRegistry):
240
243
 
241
244
  Must run after ``build_host`` (the engine shares the host's registry,
242
245
  store and LLM config — children inherit the endpoint, retry policy and
243
- budgets; parallel siblings share one live cost ceiling, kernel ≥0.9.20).
246
+ budgets; parallel siblings share one live cost ceiling, kernel ≥0.9.3).
244
247
  Returns the engine (roster inspection for hosts and tests).
245
248
  """
246
249
  from lithe.bundles.subagents import (
@@ -9,7 +9,7 @@ silently hitting some third-party URL. Resolution order is flag > env >
9
9
  interactive terminal a missing endpoint triggers the wizard instead of
10
10
  the refusal — see :mod:`lithe_cli.setup`.
11
11
 
12
- Capability flags (all off unless asked for):
12
+ Capability flags (off unless asked for, except where noted):
13
13
 
14
14
  - ``--code`` sandboxed ``run_code`` / ``run_file`` tools (bwrap when
15
15
  available, passthrough otherwise);
@@ -23,7 +23,11 @@ Capability flags (all off unless asked for):
23
23
  - ``--document`` ``document_info`` + ``analyze_document`` (PDF/OOXML
24
24
  reading on the main endpoint; the content-block dialect
25
25
  comes from ``--document-format`` > the profile's
26
- ``document_format`` field > the provider preset).
26
+ ``document_format`` field > the provider preset);
27
+ - ``--subagents`` delegate/delegate_parallel on the default roster; ON by
28
+ default — the roster reuses already-enabled tools only
29
+ (no new powers), so this is a spend selector, not a
30
+ security gate; ``--no-subagents`` disables.
27
31
  """
28
32
 
29
33
  from __future__ import annotations
@@ -68,9 +72,12 @@ class Config:
68
72
  document_format: str | None = None
69
73
  document: bool = False
70
74
  # Subagent delegation (kernel bundles.subagents): grants delegate /
71
- # delegate_parallel on the CLI's default roster. Off by default — each
72
- # delegation is a full agent run, so token spend multiplies.
73
- subagents: bool = False
75
+ # delegate_parallel on the CLI's default roster. ON by default — the
76
+ # roster only carries already-registered tools (delegation adds no new
77
+ # powers; workers inherit the same sandbox, guards and budgets), so the
78
+ # knob is a token-spend selector, not a security gate. --no-subagents
79
+ # (or /set subagents off) opts out.
80
+ subagents: bool = True
74
81
  # Run budgets (kernel AgentHost): the run ends with status
75
82
  # "budget_exceeded" once cumulative cost / tokens cross the cap. None
76
83
  # disables the cap.
@@ -319,7 +326,7 @@ def load_config(args: Any) -> Config:
319
326
  if isinstance(document_format, str)
320
327
  and document_format.strip() else None),
321
328
  document=g("document", False),
322
- subagents=g("subagents", False),
329
+ subagents=g("subagents", True),
323
330
  max_cost=g("max_cost", None),
324
331
  max_total_tokens=g("max_total_tokens", None),
325
332
  temperature=(
@@ -106,10 +106,12 @@ def build_parser() -> argparse.ArgumentParser:
106
106
  )
107
107
  sp.add_argument(
108
108
  "--subagents",
109
- action="store_true",
110
- help="grant delegate/delegate_parallel (subagent delegation on "
111
- "the default roster: researcher/coder/operator; multiplies "
112
- "token spend)",
109
+ action=argparse.BooleanOptionalAction,
110
+ default=True,
111
+ help="grant delegate/delegate_parallel on the default roster "
112
+ "(researcher/coder/operator). Default: on — the roster only "
113
+ "reuses already-enabled tools; multiplies token spend "
114
+ "(--no-subagents disables)",
113
115
  )
114
116
  sp.add_argument(
115
117
  "--document-format",
@@ -490,8 +492,8 @@ def _cmd_doctor() -> int:
490
492
  print(ui.kv("mcp", f"{len(cfg.mcp_servers)} 个服务器:{names}"))
491
493
  else:
492
494
  print(ui.kv("mcp", "未配置(--mcp 或环境变量 LITHE_MCP)"))
493
- delegation = "已启用(delegate 可委派子代理,token 花费会放大)" \
494
- if cfg.subagents else "未启用(--subagents 显式授权)"
495
+ delegation = "已启用(delegate 可委派子代理,token 花费会放大;--no-subagents 关闭)" \
496
+ if cfg.subagents else "未启用(--subagents 开启)"
495
497
  print(ui.kv("subagents", delegation))
496
498
  print(ui.kv("color", "on" if ui.color else "off"))
497
499
  return 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lithe-cli
3
- Version: 0.9.3
3
+ Version: 0.9.4
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,7 +39,7 @@ 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.9.24
42
+ Requires-Dist: lithe>=0.9.3
43
43
  Requires-Dist: prompt-toolkit>=3.0.38
44
44
  Requires-Dist: textual>=1.0
45
45
  Provides-Extra: dev
@@ -260,7 +260,7 @@ The kernel ships these as bundles; the CLI grants them per flag:
260
260
  | `--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 |
261
261
  | `--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 |
262
262
  | `--max-tokens N` | (run budget) | cumulative token budget for the turn; `--max-output-tokens N` is the different per-call cap |
263
- | `--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; `/set subagents` toggles in-session |
263
+ | `--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 |
264
264
  | `--mcp SPEC` | whatever the servers expose | JSON array/object or `@file` (env `LITHE_MCP`); stdio and streamable-http; failed servers degrade gracefully |
265
265
 
266
266
  ```bash
@@ -1,4 +1,4 @@
1
- lithe>=0.9.24
1
+ lithe>=0.9.3
2
2
  prompt-toolkit>=3.0.38
3
3
  textual>=1.0
4
4
 
@@ -9,7 +9,7 @@ description = "Command-line interface for the lithe agent kernel: chat, one-shot
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
11
11
  requires-python = ">=3.10"
12
- dependencies = ["lithe>=0.9.24", "prompt-toolkit>=3.0.38", "textual>=1.0"]
12
+ dependencies = ["lithe>=0.9.3", "prompt-toolkit>=3.0.38", "textual>=1.0"]
13
13
  keywords = ["agent", "llm", "react", "cli", "tool-calling"]
14
14
  classifiers = [
15
15
  "Development Status :: 4 - Beta",
@@ -535,6 +535,23 @@ def test_system_prompt_prefers_localized_file_edits_and_limits_todo_planning():
535
535
  assert "条数按实际步骤确定,不使用固定数量" in SYSTEM_PROMPT_BASE
536
536
 
537
537
 
538
+ def test_system_prompt_states_relative_path_rule_and_error_recovery():
539
+ from lithe_cli.agent import SYSTEM_PROMPT_BASE
540
+
541
+ assert "相对路径" in SYSTEM_PROMPT_BASE
542
+ assert "工作区之外" in SYSTEM_PROMPT_BASE
543
+ assert "错误信息" in SYSTEM_PROMPT_BASE
544
+
545
+
546
+ def test_system_prompt_puts_each_capability_on_its_own_line():
547
+ from lithe_cli.agent import build_system_prompt
548
+ from lithe_cli.config import Config
549
+
550
+ prompt = build_system_prompt(Config(code=True, shell=True))
551
+ assert "汇报结果。\n可以用 run_code" in prompt
552
+ assert "\n可以用 run_command" in prompt
553
+
554
+
538
555
  def test_todo_storage_is_scoped_to_user_and_workspace(tmp_path):
539
556
  from lithe_cli.agent import todo_store_path
540
557
  from lithe_cli.config import Config
@@ -40,12 +40,26 @@ DELEGATE_SCRIPT = [
40
40
  ]
41
41
 
42
42
 
43
- def test_delegation_disabled_by_default(tmp_path):
43
+ def test_delegation_enabled_by_default_with_opt_out(tmp_path):
44
+ """子代理委派默认包含(roster 只复用已启用工具,不新增能力),
45
+ --no-subagents 显式退出。"""
46
+ from lithe_cli.main import build_parser
47
+
48
+ parser = build_parser()
49
+ assert parser.parse_args(["run", "t"]).subagents is True
50
+ assert parser.parse_args(["run", "--no-subagents", "t"]).subagents is False
51
+ assert parser.parse_args(["run", "--subagents", "t"]).subagents is True
52
+
44
53
  cfg = make_config(tmp_path, DELEGATE_SCRIPT)
45
- reg = build_registry(cfg)
46
- assert reg.spec("delegate") is None and reg.spec("delegate_parallel") is None
47
- assert "delegate" not in tool_names(cfg)
48
- assert "delegate" not in build_system_prompt(Config())
54
+ assert cfg.subagents is True
55
+ assert "delegate" in tool_names(cfg)
56
+ assert "delegate" in build_system_prompt(Config())
57
+
58
+ # opting out keeps the delegation pair off the registry-facing surface
59
+ off = make_config(tmp_path / "off", [])
60
+ off.subagents = False
61
+ assert "delegate" not in tool_names(off)
62
+ assert "delegate" not in build_system_prompt(off)
49
63
 
50
64
 
51
65
  def test_delegation_runs_and_records_child_messages(tmp_path, capsys):
@@ -97,9 +111,12 @@ def test_roster_adapts_to_capability_flags(tmp_path):
97
111
 
98
112
  def test_set_subagents_toggles_and_warns(tmp_path):
99
113
  cfg = make_config(tmp_path, [])
114
+ assert cfg.subagents is True # default-on since the roster adds no powers
100
115
  wb = Workbench(cfg)
101
116
  keys = [row["key"] for row in wb.settings_rows()]
102
117
  assert "subagents" in keys
118
+ # enabling from off warns about token amplification
119
+ assert wb.dispatch("/set subagents off").changed
103
120
  r = wb.dispatch("/set subagents on")
104
121
  assert cfg.subagents is True
105
122
  assert any("token 花费" in text for cls, text in r.messages
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes