lithe-cli 0.1.9__tar.gz → 0.1.10__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.1.9 → lithe_cli-0.1.10}/PKG-INFO +2 -2
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/__init__.py +1 -1
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/agent.py +59 -5
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/ttui.py +16 -14
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/ttui_render.py +2 -1
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/ttui_widgets.py +47 -12
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli.egg-info/PKG-INFO +2 -2
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli.egg-info/requires.txt +1 -1
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/pyproject.toml +1 -1
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/tests/test_cli.py +23 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/tests/test_cli_subagents.py +23 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/tests/test_ttui.py +24 -1
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/LICENSE +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/README.md +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/__main__.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/cli_parser.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/clipboard.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/commands.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/config.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/main.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/profiles.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/prompts.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/py.typed +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/sessions.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/setup.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/tui.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/ui.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli/workbench.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli.egg-info/SOURCES.txt +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli.egg-info/dependency_links.txt +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli.egg-info/entry_points.txt +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/lithe_cli.egg-info/top_level.txt +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/setup.cfg +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/tests/test_cli_budget_steer.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/tests/test_cli_clipboard.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/tests/test_cli_guard.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/tests/test_cli_sessions.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/tests/test_profiles.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/tests/test_tui_v2.py +0 -0
- {lithe_cli-0.1.9 → lithe_cli-0.1.10}/tests/test_workbench.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lithe-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.10
|
|
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.1.
|
|
42
|
+
Requires-Dist: lithe>=0.1.7
|
|
43
43
|
Requires-Dist: prompt-toolkit>=3.0.38
|
|
44
44
|
Requires-Dist: textual>=1.0
|
|
45
45
|
Provides-Extra: dev
|
|
@@ -96,8 +96,55 @@ def sandbox_backend() -> str:
|
|
|
96
96
|
return "bwrap" if shutil.which("bwrap") else "passthrough"
|
|
97
97
|
|
|
98
98
|
|
|
99
|
+
def environment_facts(cfg: Config) -> str:
|
|
100
|
+
"""Env-fact lines for the system prompt (host, shell, workspace layout).
|
|
101
|
+
|
|
102
|
+
The layout line exists because the dominant first-hour failures in a
|
|
103
|
+
real delegation session were assumption mismatches, not tool bugs:
|
|
104
|
+
git run at a workspace root that is not a repo while the real repos
|
|
105
|
+
live in nested sub-directories, CI snippets with project-relative
|
|
106
|
+
paths, a husk ``.venv`` guessed usable. A few dozen tokens of facts
|
|
107
|
+
replace each of those wrong guesses (one failed round-trip apiece).
|
|
108
|
+
The ``run_command`` hint rides along only when the shell capability
|
|
109
|
+
is on, keeping the no-shell prompt free of the tool's name.
|
|
110
|
+
"""
|
|
111
|
+
if sys.platform == "win32":
|
|
112
|
+
if shutil.which("pwsh"):
|
|
113
|
+
shell = "PowerShell 7+(pwsh)"
|
|
114
|
+
elif shutil.which("powershell"):
|
|
115
|
+
shell = "Windows PowerShell 5.1(无 &&,用 cmd1; if ($?) { cmd2 })"
|
|
116
|
+
else:
|
|
117
|
+
shell = "cmd"
|
|
118
|
+
facts = f"宿主环境:Windows,shell 为 {shell}。"
|
|
119
|
+
else:
|
|
120
|
+
facts = "宿主环境:Linux/macOS(POSIX shell)。"
|
|
121
|
+
root = cfg.workspace_dir.expanduser().resolve()
|
|
122
|
+
try:
|
|
123
|
+
entries = sorted(
|
|
124
|
+
(p for p in root.iterdir()
|
|
125
|
+
if p.is_dir() and not p.name.startswith(".")),
|
|
126
|
+
key=lambda p: p.name.lower())
|
|
127
|
+
except OSError:
|
|
128
|
+
return facts
|
|
129
|
+
names = [p.name for p in entries[:10]]
|
|
130
|
+
layout = "、".join(names) if names else "(空)"
|
|
131
|
+
if len(entries) > 10:
|
|
132
|
+
layout += f" 等 {len(entries)} 项"
|
|
133
|
+
line = (f"工作区 {root}("
|
|
134
|
+
f"{'是' if (root / '.git').exists() else '不是'} git 仓库)"
|
|
135
|
+
f"顶层目录:{layout}")
|
|
136
|
+
repos = [p.name for p in entries if (p / ".git").exists()]
|
|
137
|
+
if repos:
|
|
138
|
+
line += f";其中的独立 git 仓库:{'、'.join(repos)}"
|
|
139
|
+
if cfg.shell:
|
|
140
|
+
line += ("。对子项目执行命令用 run_command 的 cwd 参数指定目录"
|
|
141
|
+
"(区内自由、区外需用户审批),不要假设工作区根是仓库,"
|
|
142
|
+
"也不要在命令里拼接 cd")
|
|
143
|
+
return facts + "\n" + line
|
|
144
|
+
|
|
145
|
+
|
|
99
146
|
def build_system_prompt(cfg: Config) -> str:
|
|
100
|
-
"""Base prompt plus one line per enabled capability."""
|
|
147
|
+
"""Base prompt plus one line per enabled capability, then env facts."""
|
|
101
148
|
extras = []
|
|
102
149
|
if cfg.code:
|
|
103
150
|
extras.append("可以用 run_code 执行 Python 来验证想法、计算或测试。")
|
|
@@ -114,8 +161,7 @@ def build_system_prompt(cfg: Config) -> str:
|
|
|
114
161
|
extras.append("可以用 delegate 把独立子任务委派给子代理(可用名单见工具说明:检索/编码/操作),"
|
|
115
162
|
"互不依赖的子任务用 delegate_parallel 并行委派;"
|
|
116
163
|
"子代理与本对话共享预算,汇报时合并它们的结果。")
|
|
117
|
-
|
|
118
|
-
return SYSTEM_PROMPT_BASE
|
|
164
|
+
extras.append(environment_facts(cfg))
|
|
119
165
|
return SYSTEM_PROMPT_BASE + "\n" + "\n".join(extras)
|
|
120
166
|
|
|
121
167
|
|
|
@@ -196,7 +242,8 @@ def build_registry(
|
|
|
196
242
|
from lithe.bundles.command import CommandRunner
|
|
197
243
|
|
|
198
244
|
register_command_tools(
|
|
199
|
-
reg, lambda ctx: cfg.workspace_dir.resolve(), CommandRunner()
|
|
245
|
+
reg, lambda ctx: cfg.workspace_dir.resolve(), CommandRunner(),
|
|
246
|
+
approver=approver,
|
|
200
247
|
)
|
|
201
248
|
# Dangerous-command guard: catastrophic commands never run; the
|
|
202
249
|
# destructive-but-scoped tier (rm -r <path>, git push --force,
|
|
@@ -328,7 +375,14 @@ def register_subagents(cfg: Config, host: AgentHost, reg: ToolRegistry,
|
|
|
328
375
|
else:
|
|
329
376
|
render_event(enriched)
|
|
330
377
|
|
|
331
|
-
engine = SubagentEngine(
|
|
378
|
+
engine = SubagentEngine(
|
|
379
|
+
host, roster, on_subagent_event=forward_progress,
|
|
380
|
+
# Subagents do not inherit the orchestrator's system prompt — the
|
|
381
|
+
# roster's spec prompts are all they see. Prepending the same env
|
|
382
|
+
# facts (platform, shell, nested-repo layout) keeps the operator
|
|
383
|
+
# from re-learning the workspace layout by failed guesses.
|
|
384
|
+
prompt_builder=lambda spec, ctx: f"{environment_facts(cfg)}\n\n{spec.prompt}",
|
|
385
|
+
)
|
|
332
386
|
register_delegate_tools(reg, engine, parallel=True)
|
|
333
387
|
return engine
|
|
334
388
|
|
|
@@ -30,7 +30,7 @@ from typing import Any
|
|
|
30
30
|
from textual.app import App, ComposeResult
|
|
31
31
|
from textual.binding import Binding
|
|
32
32
|
from textual.containers import Horizontal, Vertical, VerticalScroll
|
|
33
|
-
from textual.widgets import
|
|
33
|
+
from textual.widgets import Static, TextArea
|
|
34
34
|
|
|
35
35
|
from .clipboard import deliver_clipboard, write_clipboard_file
|
|
36
36
|
from .config import lithe_home
|
|
@@ -47,7 +47,7 @@ from .ui import fmt_duration as fmt_duration # noqa: F401 — legacy re-export
|
|
|
47
47
|
from . import ttui_widgets as _widgets
|
|
48
48
|
from .ttui_widgets import (
|
|
49
49
|
ConfirmModal, ConversationPane, HistoryInput, PickerModal, SubagentCard,
|
|
50
|
-
WbEvent, completion_suggestions, selected_text,
|
|
50
|
+
HistoryInputSubmitted, WbEvent, completion_suggestions, selected_text,
|
|
51
51
|
)
|
|
52
52
|
from .ttui_render import footer_text, header_text, sidebar_markup
|
|
53
53
|
|
|
@@ -71,7 +71,7 @@ class LitheApp(App):
|
|
|
71
71
|
.subagent-search { height: 3; margin: 0 1 0 1; border: round #334155; }
|
|
72
72
|
.subagent-output { height: auto; margin: 0 1 0 1; color: #cbd5e1; }
|
|
73
73
|
#side-wrap { width: 44; border: round #475569; padding: 0 1; }
|
|
74
|
-
#prompt { border: round #475569; }
|
|
74
|
+
#prompt { height: auto; max-height: 8; border: round #475569; }
|
|
75
75
|
#foot { height: 1; background: #111827; color: #cbd5e1; }
|
|
76
76
|
#picker { width: 60%; height: auto; max-height: 80%;
|
|
77
77
|
border: round #38bdf8; background: $surface; padding: 1 2; }
|
|
@@ -162,13 +162,13 @@ class LitheApp(App):
|
|
|
162
162
|
)
|
|
163
163
|
self._sync_feed()
|
|
164
164
|
self._refresh_chrome()
|
|
165
|
-
self.query_one("#prompt",
|
|
165
|
+
self.query_one("#prompt", HistoryInput).focus()
|
|
166
166
|
# Live turn timer: kernel events alone leave the screen static
|
|
167
167
|
# during long model calls, so the chrome repaints on a heartbeat
|
|
168
168
|
# while a turn runs (elapsed comes from TuiState.elapsed()).
|
|
169
169
|
self.set_interval(0.5, self._tick_elapsed)
|
|
170
170
|
if self.mode == "run" and self.initial_task:
|
|
171
|
-
self.query_one("#prompt",
|
|
171
|
+
self.query_one("#prompt", HistoryInput).disabled = True
|
|
172
172
|
asyncio.create_task(self._run_one_shot(self.initial_task))
|
|
173
173
|
|
|
174
174
|
# -- state management --------------------------------------------------------
|
|
@@ -417,29 +417,31 @@ class LitheApp(App):
|
|
|
417
417
|
|
|
418
418
|
# -- input -------------------------------------------------------------------
|
|
419
419
|
|
|
420
|
-
def
|
|
421
|
-
if event.
|
|
420
|
+
def on_text_area_changed(self, event: TextArea.Changed) -> None:
|
|
421
|
+
if event.text_area.id != "prompt":
|
|
422
422
|
return
|
|
423
423
|
from .commands import COMMANDS
|
|
424
424
|
|
|
425
425
|
prompt = self.query_one("#prompt", HistoryInput)
|
|
426
|
-
prompt.
|
|
427
|
-
event.
|
|
426
|
+
prompt.completions = completion_suggestions(
|
|
427
|
+
event.text_area.text,
|
|
428
428
|
COMMANDS,
|
|
429
429
|
self.state.model_candidates,
|
|
430
430
|
self.state.profile_names,
|
|
431
431
|
[f"#{row['id']}" for row in self.state.sessions],
|
|
432
432
|
)
|
|
433
433
|
strip = self.query_one("#suggest", Static)
|
|
434
|
-
if prompt.
|
|
434
|
+
if prompt.completions:
|
|
435
435
|
strip.update("[dim]Tab 采纳 →[/] " +
|
|
436
|
-
" ".join(prompt.
|
|
436
|
+
" ".join(prompt.completions[:4]))
|
|
437
437
|
strip.display = True
|
|
438
438
|
else:
|
|
439
439
|
strip.update("")
|
|
440
440
|
strip.display = False
|
|
441
441
|
|
|
442
|
-
async def
|
|
442
|
+
async def on_history_input_submitted(
|
|
443
|
+
self, event: HistoryInputSubmitted,
|
|
444
|
+
) -> None:
|
|
443
445
|
if event.input.id != "prompt":
|
|
444
446
|
return
|
|
445
447
|
line = event.value.strip()
|
|
@@ -714,7 +716,7 @@ class LitheApp(App):
|
|
|
714
716
|
self._activate(self.wb.current["id"])
|
|
715
717
|
|
|
716
718
|
def _picker_rename(self, payload) -> None:
|
|
717
|
-
prompt = self.query_one("#prompt",
|
|
719
|
+
prompt = self.query_one("#prompt", HistoryInput)
|
|
718
720
|
prompt.value = "/rename "
|
|
719
721
|
prompt.focus()
|
|
720
722
|
|
|
@@ -891,7 +893,7 @@ class LitheApp(App):
|
|
|
891
893
|
self._cancel_asked = False
|
|
892
894
|
self._sync_feed()
|
|
893
895
|
self._refresh_chrome()
|
|
894
|
-
self.query_one("#prompt",
|
|
896
|
+
self.query_one("#prompt", HistoryInput).disabled = False
|
|
895
897
|
|
|
896
898
|
|
|
897
899
|
async def _driver(app: LitheApp) -> int:
|
|
@@ -118,5 +118,6 @@ def footer_text(state: TuiState) -> str:
|
|
|
118
118
|
timer = f" · {fmt_duration(live)}" if live is not None else ""
|
|
119
119
|
return (f" ● {state.status}{timer} · Ctrl+C 取消 · F3 会话"
|
|
120
120
|
f" · F4 模型 · F6 推理 ")
|
|
121
|
-
return (f" ● {state.status} · Enter 发送 ·
|
|
121
|
+
return (f" ● {state.status} · Enter 发送 · Ctrl+Enter 换行 · F2 侧栏"
|
|
122
|
+
f" · F3 会话 · F4 模型"
|
|
122
123
|
f" · F5 设置 · F6 推理 · /help ")
|
|
@@ -12,7 +12,7 @@ from textual.content import Content
|
|
|
12
12
|
from textual.css.query import NoMatches
|
|
13
13
|
from textual.message import Message
|
|
14
14
|
from textual.screen import ModalScreen
|
|
15
|
-
from textual.widgets import Button, Input, Label, ListItem, ListView, Static
|
|
15
|
+
from textual.widgets import Button, Input, Label, ListItem, ListView, Static, TextArea
|
|
16
16
|
|
|
17
17
|
from .ui import display_width, truncate
|
|
18
18
|
|
|
@@ -31,7 +31,7 @@ def completion_suggestions(
|
|
|
31
31
|
complete their first argument (cached models, saved profiles, session
|
|
32
32
|
ids). Empty result hides the suggestion strip.
|
|
33
33
|
"""
|
|
34
|
-
if not value.startswith("/"):
|
|
34
|
+
if "\n" in value or not value.startswith("/"):
|
|
35
35
|
return []
|
|
36
36
|
if " " not in value:
|
|
37
37
|
prefix = value.rstrip()
|
|
@@ -52,14 +52,17 @@ def completion_suggestions(
|
|
|
52
52
|
return [w for w in words if w.startswith(arg) and w != arg][:6]
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
class HistoryInput(
|
|
56
|
-
"""
|
|
55
|
+
class HistoryInput(TextArea):
|
|
56
|
+
"""Multiline prompt with history recall and persistent FileHistory."""
|
|
57
57
|
|
|
58
58
|
BINDINGS = [
|
|
59
59
|
Binding("up", "history_prev", "上一条", show=False, priority=True),
|
|
60
60
|
Binding("down", "history_next", "下一条", show=False, priority=True),
|
|
61
61
|
Binding("tab", "accept_suggestion", "采纳", show=False,
|
|
62
62
|
priority=True),
|
|
63
|
+
Binding("enter", "submit", "发送", show=False, priority=True),
|
|
64
|
+
Binding("ctrl+enter", "insert_newline", "换行", show=False,
|
|
65
|
+
priority=True),
|
|
63
66
|
]
|
|
64
67
|
|
|
65
68
|
def __init__(self, *args, file_history=None, **kwargs):
|
|
@@ -68,9 +71,24 @@ class HistoryInput(Input):
|
|
|
68
71
|
self._lines: list[str] = []
|
|
69
72
|
self._pos: int | None = None
|
|
70
73
|
self._draft = ""
|
|
71
|
-
self.
|
|
74
|
+
self.completions: list[str] = []
|
|
72
75
|
self.reload_history()
|
|
73
76
|
|
|
77
|
+
@property
|
|
78
|
+
def value(self) -> str:
|
|
79
|
+
"""Input-compatible alias used by the workbench and UI code."""
|
|
80
|
+
return self.text
|
|
81
|
+
|
|
82
|
+
@value.setter
|
|
83
|
+
def value(self, text: str) -> None:
|
|
84
|
+
self.text = text
|
|
85
|
+
|
|
86
|
+
def action_submit(self) -> None:
|
|
87
|
+
self.post_message(HistoryInputSubmitted(self, self.text))
|
|
88
|
+
|
|
89
|
+
def action_insert_newline(self) -> None:
|
|
90
|
+
self.insert("\n")
|
|
91
|
+
|
|
74
92
|
def reload_history(self) -> None:
|
|
75
93
|
self._lines = []
|
|
76
94
|
if self.file_history is not None:
|
|
@@ -82,8 +100,7 @@ class HistoryInput(Input):
|
|
|
82
100
|
self._draft = ""
|
|
83
101
|
|
|
84
102
|
def record(self, line: str) -> None:
|
|
85
|
-
|
|
86
|
-
if not line:
|
|
103
|
+
if not line.strip():
|
|
87
104
|
return
|
|
88
105
|
if not self._lines or self._lines[-1] != line:
|
|
89
106
|
self._lines.append(line)
|
|
@@ -98,9 +115,15 @@ class HistoryInput(Input):
|
|
|
98
115
|
def _apply(self, text: str, pos: int | None) -> None:
|
|
99
116
|
self._pos = pos
|
|
100
117
|
self.value = text
|
|
101
|
-
|
|
118
|
+
lines = text.split("\n")
|
|
119
|
+
self.move_cursor((len(lines) - 1, len(lines[-1])))
|
|
102
120
|
|
|
103
121
|
def action_history_prev(self) -> None:
|
|
122
|
+
# Keep normal vertical editing inside a multiline draft; history is
|
|
123
|
+
# recalled only when the cursor is already on its first line.
|
|
124
|
+
if self.cursor_location[0] > 0:
|
|
125
|
+
self.action_cursor_up()
|
|
126
|
+
return
|
|
104
127
|
if not self._lines:
|
|
105
128
|
return
|
|
106
129
|
if self._pos is None:
|
|
@@ -110,6 +133,9 @@ class HistoryInput(Input):
|
|
|
110
133
|
self._apply(self._lines[self._pos - 1], self._pos - 1)
|
|
111
134
|
|
|
112
135
|
def action_history_next(self) -> None:
|
|
136
|
+
if self.cursor_location[0] < len(self.text.split("\n")) - 1:
|
|
137
|
+
self.action_cursor_down()
|
|
138
|
+
return
|
|
113
139
|
if self._pos is None:
|
|
114
140
|
return
|
|
115
141
|
if self._pos < len(self._lines) - 1:
|
|
@@ -118,11 +144,20 @@ class HistoryInput(Input):
|
|
|
118
144
|
self._apply(self._draft, None)
|
|
119
145
|
|
|
120
146
|
def action_accept_suggestion(self) -> None:
|
|
121
|
-
if self.
|
|
122
|
-
accepted = self.
|
|
147
|
+
if self.completions:
|
|
148
|
+
accepted = self.completions[0]
|
|
123
149
|
self.value = accepted
|
|
124
|
-
self.
|
|
125
|
-
self.
|
|
150
|
+
self.move_cursor((0, len(accepted)))
|
|
151
|
+
self.completions = []
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class HistoryInputSubmitted(Message):
|
|
155
|
+
"""A multiline prompt submission, kept separate from TextArea.Changed."""
|
|
156
|
+
|
|
157
|
+
def __init__(self, input: HistoryInput, value: str) -> None:
|
|
158
|
+
super().__init__()
|
|
159
|
+
self.input = input
|
|
160
|
+
self.value = value
|
|
126
161
|
|
|
127
162
|
|
|
128
163
|
# -- workbench → app message ----------------------------------------------------
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lithe-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.10
|
|
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.1.
|
|
42
|
+
Requires-Dist: lithe>=0.1.7
|
|
43
43
|
Requires-Dist: prompt-toolkit>=3.0.38
|
|
44
44
|
Requires-Dist: textual>=1.0
|
|
45
45
|
Provides-Extra: dev
|
|
@@ -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.1.
|
|
12
|
+
dependencies = ["lithe>=0.1.7", "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",
|
|
@@ -552,6 +552,29 @@ def test_system_prompt_puts_each_capability_on_its_own_line():
|
|
|
552
552
|
assert "\n可以用 run_command" in prompt
|
|
553
553
|
|
|
554
554
|
|
|
555
|
+
def test_system_prompt_carries_environment_facts(tmp_path):
|
|
556
|
+
from lithe_cli.agent import build_system_prompt
|
|
557
|
+
from lithe_cli.config import Config
|
|
558
|
+
|
|
559
|
+
(tmp_path / "lithe").mkdir()
|
|
560
|
+
(tmp_path / "lithe" / ".git").mkdir()
|
|
561
|
+
(tmp_path / "notes").mkdir()
|
|
562
|
+
cfg = Config(workspace_dir=tmp_path)
|
|
563
|
+
prompt = build_system_prompt(cfg)
|
|
564
|
+
assert "宿主环境" in prompt
|
|
565
|
+
assert "不是 git 仓库" in prompt
|
|
566
|
+
assert "lithe" in prompt and "notes" in prompt
|
|
567
|
+
assert "独立 git 仓库:lithe" in prompt
|
|
568
|
+
# the run_command cwd hint rides along only with the shell capability
|
|
569
|
+
assert "run_command" not in prompt
|
|
570
|
+
shell_on = build_system_prompt(Config(workspace_dir=tmp_path, shell=True))
|
|
571
|
+
assert "cwd 参数" in shell_on
|
|
572
|
+
|
|
573
|
+
# a root-level repo flips the layout verdict
|
|
574
|
+
(tmp_path / ".git").mkdir()
|
|
575
|
+
assert "是 git 仓库" in build_system_prompt(Config(workspace_dir=tmp_path))
|
|
576
|
+
|
|
577
|
+
|
|
555
578
|
def test_todo_storage_is_scoped_to_user_and_workspace(tmp_path):
|
|
556
579
|
from lithe_cli.agent import todo_store_path
|
|
557
580
|
from lithe_cli.config import Config
|
|
@@ -133,6 +133,29 @@ def test_roster_adapts_to_capability_flags(tmp_path):
|
|
|
133
133
|
assert "run_command" in op_names
|
|
134
134
|
|
|
135
135
|
|
|
136
|
+
def test_subagent_prompt_prepends_environment_facts(tmp_path):
|
|
137
|
+
"""Subagents never see the orchestrator's system prompt — without the
|
|
138
|
+
facts prepended they re-learn the workspace layout (nested repos,
|
|
139
|
+
platform) by failed guesses, which is what this fixes."""
|
|
140
|
+
from lithe import AgentContext
|
|
141
|
+
|
|
142
|
+
cfg = make_config(tmp_path, [])
|
|
143
|
+
cfg.subagents = True
|
|
144
|
+
cfg.shell = True
|
|
145
|
+
cfg.workspace_dir.mkdir(parents=True, exist_ok=True)
|
|
146
|
+
(cfg.workspace_dir / "svc").mkdir()
|
|
147
|
+
(cfg.workspace_dir / "svc" / ".git").mkdir()
|
|
148
|
+
reg = build_registry(cfg)
|
|
149
|
+
host = build_host(cfg, reg)
|
|
150
|
+
engine = register_subagents(cfg, host, reg)
|
|
151
|
+
prompt = engine.system_prompt(
|
|
152
|
+
engine.roster.get("researcher"), AgentContext(run_id="r", user_id="u"))
|
|
153
|
+
assert "宿主环境" in prompt
|
|
154
|
+
assert "独立 git 仓库:svc" in prompt
|
|
155
|
+
# the spec's own persona is intact after the prepended facts
|
|
156
|
+
assert "只读检索子代理" in prompt
|
|
157
|
+
|
|
158
|
+
|
|
136
159
|
def test_set_subagents_toggles_and_warns(tmp_path):
|
|
137
160
|
cfg = make_config(tmp_path, [])
|
|
138
161
|
assert cfg.subagents is True # default-on since the roster adds no powers
|
|
@@ -512,7 +512,10 @@ def test_resumed_session_mounts_persisted_subagent_cards(tmp_path):
|
|
|
512
512
|
args=SimpleNamespace(resume=str(cid), cont=False, title=None))
|
|
513
513
|
|
|
514
514
|
async def scenario():
|
|
515
|
-
|
|
515
|
+
# wide terminal: the one-line heading truncates the task to the
|
|
516
|
+
# pane width, so give it room to show "检查 README" in full on
|
|
517
|
+
# every runner (the assertion would be width-dependent otherwise)
|
|
518
|
+
async with app.run_test(size=(120, 30)) as pilot:
|
|
516
519
|
await pilot.pause()
|
|
517
520
|
cards = list(app.query(SubagentCard))
|
|
518
521
|
assert len(cards) == 1
|
|
@@ -630,6 +633,26 @@ def test_app_completion_strip_and_history_recall(tmp_path, monkeypatch):
|
|
|
630
633
|
asyncio.run(scenario())
|
|
631
634
|
|
|
632
635
|
|
|
636
|
+
def test_prompt_submits_multiline_text_and_ctrl_enter_inserts_newline(tmp_path):
|
|
637
|
+
async def scenario():
|
|
638
|
+
app = _app(tmp_path, [{"content": "收到完整内容"}])
|
|
639
|
+
async with app.run_test(size=(100, 30)) as pilot:
|
|
640
|
+
await pilot.pause()
|
|
641
|
+
prompt = app.query_one("#prompt")
|
|
642
|
+
prompt.focus()
|
|
643
|
+
|
|
644
|
+
await pilot.press("a", "ctrl+enter", "b")
|
|
645
|
+
await pilot.pause()
|
|
646
|
+
assert prompt.text == "a\nb"
|
|
647
|
+
|
|
648
|
+
await pilot.press("enter")
|
|
649
|
+
assert await _run_until_done(pilot, app), "multiline turn did not finish"
|
|
650
|
+
assert "a\nb" in _conv_text(app)
|
|
651
|
+
assert "收到完整内容" in _conv_text(app)
|
|
652
|
+
|
|
653
|
+
asyncio.run(scenario())
|
|
654
|
+
|
|
655
|
+
|
|
633
656
|
def test_history_persists_across_processes(tmp_path, monkeypatch):
|
|
634
657
|
monkeypatch.setenv("LITHE_HOME", str(tmp_path / "home"))
|
|
635
658
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|