core/cli: clearer /stream /tools /verbose help text

Use metavar [on|off] and document default/effect so /help stream is
readable without guessing ENABLED.
This commit is contained in:
2026-07-15 13:17:51 +08:00
parent ffab066cab
commit 00c3350225
2 changed files with 28 additions and 6 deletions
+19 -6
View File
@@ -405,10 +405,13 @@ def model_cmd(state: ReplState, model_id: str | None) -> None:
@slash.command("tools") @slash.command("tools")
@click.argument("enabled", required=False, type=ON_OFF) @click.argument("enabled", required=False, type=ON_OFF, metavar="[on|off]")
@click.pass_obj @click.pass_obj
def tools_cmd(state: ReplState, enabled: bool | None) -> None: # noqa: FBT001 def tools_cmd(state: ReplState, enabled: bool | None) -> None: # noqa: FBT001
"""Show or toggle tools.""" """Show or set whether agent tools are enabled.
Omit the argument to print the current value; pass ``on`` or ``off`` to change it.
"""
if enabled is None: if enabled is None:
click.echo(f"tools={'on' if state.tools_enabled else 'off'}") click.echo(f"tools={'on' if state.tools_enabled else 'off'}")
return return
@@ -418,10 +421,15 @@ def tools_cmd(state: ReplState, enabled: bool | None) -> None: # noqa: FBT001
@slash.command("stream") @slash.command("stream")
@click.argument("enabled", required=False, type=ON_OFF) @click.argument("enabled", required=False, type=ON_OFF, metavar="[on|off]")
@click.pass_obj @click.pass_obj
def stream_cmd(state: ReplState, enabled: bool | None) -> None: # noqa: FBT001 def stream_cmd(state: ReplState, enabled: bool | None) -> None: # noqa: FBT001
"""Show or toggle streaming model output.""" """Show or set streaming model output.
``on`` (default): print assistant text and reasoning as tokens arrive.
``off``: wait for each full model response before printing.
Omit the argument to print the current value.
"""
if enabled is None: if enabled is None:
click.echo(f"stream={'on' if state.agent.stream else 'off'}") click.echo(f"stream={'on' if state.agent.stream else 'off'}")
return return
@@ -431,10 +439,15 @@ def stream_cmd(state: ReplState, enabled: bool | None) -> None: # noqa: FBT001
@slash.command("verbose") @slash.command("verbose")
@click.argument("enabled", required=False, type=ON_OFF) @click.argument("enabled", required=False, type=ON_OFF, metavar="[on|off]")
@click.pass_obj @click.pass_obj
def verbose_cmd(state: ReplState, enabled: bool | None) -> None: # noqa: FBT001 def verbose_cmd(state: ReplState, enabled: bool | None) -> None: # noqa: FBT001
"""Show or toggle full tool-result dumps.""" """Show or set full tool-result dumps in the terminal.
``off`` (default): short one-line tool result preview.
``on``: print the full tool result text.
Omit the argument to print the current value.
"""
if enabled is None: if enabled is None:
click.echo(f"verbose={'on' if state.verbose else 'off'}") click.echo(f"verbose={'on' if state.verbose else 'off'}")
return return
+9
View File
@@ -114,6 +114,15 @@ async def test_help_history_no_fake_options(state: ReplState, capsys: pytest.Cap
assert "--help" not in out assert "--help" not in out
async def test_help_stream_clearer(state: ReplState, capsys: pytest.CaptureFixture[str]) -> None:
assert await handle_slash(state, "/help stream") is True
out = capsys.readouterr().out
assert "Usage: /stream [on|off]" in out
assert "ENABLED" not in out
assert "tokens arrive" in out
assert "default" in out
async def test_history_rejects_help_flag(state: ReplState, capsys: pytest.CaptureFixture[str]) -> None: async def test_history_rejects_help_flag(state: ReplState, capsys: pytest.CaptureFixture[str]) -> None:
assert await handle_slash(state, "/history --help") is True assert await handle_slash(state, "/history --help") is True
captured = capsys.readouterr() captured = capsys.readouterr()