chore: CLI polish — peer inspect config, drop dead helper, doc/help consistency
This commit is contained in:
parent
726699785e
commit
3ba490f044
|
|
@ -41,8 +41,8 @@ def list_messages(
|
|||
try:
|
||||
# Server supports ?reverse=true on messages/list, but the Python
|
||||
# SDK doesn't forward it from Session.messages() yet. Until then,
|
||||
# --reverse walks every page via the SDK iterator and slices
|
||||
# — O(pages) in the session size. Safe for small sessions
|
||||
# --reverse walks every page via the SDK iterator and slices
|
||||
# — O(pages) in the session size. Safe for small sessions.
|
||||
if not reverse:
|
||||
msgs = sess.messages().items[:last]
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ def list_peers(
|
|||
json_output: bool = typer.Option(False, "--json", help="Force JSON output"),
|
||||
) -> None:
|
||||
"""List all peers in the workspace."""
|
||||
from honcho_cli.commands.workspace import _compact_config, _raw_list
|
||||
from honcho_cli.commands.workspace import _raw_list
|
||||
from honcho_cli.common import handle_cmd_flags
|
||||
from honcho_cli.main import get_client
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ def list_peers(
|
|||
{
|
||||
"id": p.id,
|
||||
"metadata": p.metadata,
|
||||
"configuration": _compact_config(_config_to_dict(p.configuration)) if p.configuration else None,
|
||||
"configuration": _config_to_dict(p.configuration) if p.configuration else None,
|
||||
"created_at": str(p.created_at),
|
||||
}
|
||||
for p in raw_peers
|
||||
|
|
@ -77,6 +77,7 @@ def inspect(
|
|||
|
||||
try:
|
||||
card = p.get_card()
|
||||
peer_config = p.get_configuration()
|
||||
# First page only; SyncPage.total (when the server supplies it) is
|
||||
# authoritative for counts without walking every page.
|
||||
session_page = p.sessions()
|
||||
|
|
@ -88,6 +89,7 @@ def inspect(
|
|||
result = {
|
||||
"id": pid,
|
||||
"card": card,
|
||||
"configuration": _config_to_dict(peer_config) if peer_config else None,
|
||||
"session_count": session_page.total if session_page.total is not None else len(session_items),
|
||||
"conclusion_count": conclusion_page.total if conclusion_page.total is not None else len(conclusion_items),
|
||||
"recent_conclusions": [
|
||||
|
|
@ -130,7 +132,7 @@ def chat(
|
|||
query: str = typer.Argument(help="Question to ask about the peer"),
|
||||
target: Optional[str] = typer.Option(None, help="Target peer for perspective"),
|
||||
workspace: Optional[str] = typer.Option(None, "--workspace", "-w", help="Override workspace ID"),
|
||||
peer: Optional[str] = typer.Option(None, "--peer", "-p", help="Peer ID (uses default if omitted)"),
|
||||
peer: Optional[str] = typer.Option(None, "--peer", "-p", help="Override peer ID"),
|
||||
json_output: bool = typer.Option(False, "--json", help="Force JSON output"),
|
||||
) -> None:
|
||||
"""Query the dialectic about a peer."""
|
||||
|
|
@ -156,7 +158,7 @@ def search(
|
|||
query: str = typer.Argument(help="Search query"),
|
||||
limit: int = typer.Option(10, help="Max results"),
|
||||
workspace: Optional[str] = typer.Option(None, "--workspace", "-w", help="Override workspace ID"),
|
||||
peer: Optional[str] = typer.Option(None, "--peer", "-p", help="Peer ID (uses default if omitted)"),
|
||||
peer: Optional[str] = typer.Option(None, "--peer", "-p", help="Override peer ID"),
|
||||
json_output: bool = typer.Option(False, "--json", help="Force JSON output"),
|
||||
) -> None:
|
||||
"""Search a peer's messages."""
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
"""Session commands: list, inspect, messages, context, summaries, peers, search, representation, metadata."""
|
||||
"""Session commands: list, inspect, context, summaries, peers, search, representation, metadata."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
@ -87,8 +87,6 @@ def inspect(
|
|||
summaries = sess.summaries()
|
||||
sess_config = sess.get_configuration()
|
||||
|
||||
from honcho_cli.commands.workspace import _compact_config
|
||||
|
||||
# Use SyncPage.total when the server provides it; otherwise fall back
|
||||
# to the first-page count and flag that we did so, so scripted
|
||||
# callers don't treat a lower bound as a total.
|
||||
|
|
@ -99,7 +97,6 @@ def inspect(
|
|||
message_count = len(msg_page.items)
|
||||
message_count_is_total = False
|
||||
|
||||
raw_config = _config_to_dict(sess_config) if sess_config else None
|
||||
result = {
|
||||
"id": sid,
|
||||
"peers": [{"id": p.id} for p in peers],
|
||||
|
|
@ -109,7 +106,7 @@ def inspect(
|
|||
"short": summaries.short_summary if hasattr(summaries, "short_summary") else None,
|
||||
"long": summaries.long_summary if hasattr(summaries, "long_summary") else None,
|
||||
},
|
||||
"configuration": _compact_config(raw_config) if raw_config else None,
|
||||
"configuration": _config_to_dict(sess_config) if sess_config else None,
|
||||
}
|
||||
print_result(result)
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@ def _raw_list(page) -> list:
|
|||
return items
|
||||
|
||||
|
||||
def _compact_config(config_dict: dict) -> dict:
|
||||
return config_dict
|
||||
|
||||
|
||||
@app.command("list")
|
||||
def list_workspaces(
|
||||
json_output: bool = typer.Option(False, "--json", help="Force JSON output"),
|
||||
|
|
@ -90,7 +86,7 @@ def inspect(
|
|||
result = {
|
||||
"workspace_id": wid,
|
||||
"metadata": ws_metadata,
|
||||
"configuration": _compact_config(_config_to_dict(ws_config)),
|
||||
"configuration": _config_to_dict(ws_config) if ws_config else None,
|
||||
"peer_count": len(raw_peers),
|
||||
"session_count": len(raw_sessions),
|
||||
"peers": [
|
||||
|
|
|
|||
Loading…
Reference in New Issue