honcho-cli 0.4.0__tar.gz → 0.6.0__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 (60) hide show
  1. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/CHANGELOG.md +30 -0
  2. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/PKG-INFO +12 -2
  3. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/README.md +10 -0
  4. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/pyproject.toml +2 -2
  5. honcho_cli-0.6.0/src/honcho_cli/__init__.py +11 -0
  6. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/_help.py +3 -0
  7. honcho_cli-0.6.0/src/honcho_cli/commands/dream.py +318 -0
  8. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/commands/setup.py +2 -0
  9. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/commands/workspace.py +188 -3
  10. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/common.py +61 -7
  11. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/config.py +22 -10
  12. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/main.py +2 -0
  13. honcho_cli-0.6.0/src/honcho_cli/replay.py +702 -0
  14. honcho_cli-0.6.0/src/honcho_cli/replay_view.py +415 -0
  15. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_common.py +81 -1
  16. honcho_cli-0.6.0/tests/test_dream.py +234 -0
  17. honcho_cli-0.6.0/tests/test_replay.py +860 -0
  18. honcho_cli-0.6.0/tests/test_version.py +13 -0
  19. honcho_cli-0.4.0/src/honcho_cli/__init__.py +0 -3
  20. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/.gitignore +0 -0
  21. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/scripts/generate_cli_docs.py +0 -0
  22. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/agents.py +0 -0
  23. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/branding.py +0 -0
  24. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/commands/__init__.py +0 -0
  25. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/commands/conclusion.py +0 -0
  26. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/commands/config_cmd.py +0 -0
  27. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/commands/install.py +0 -0
  28. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/commands/message.py +0 -0
  29. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/commands/peer.py +0 -0
  30. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/commands/scope.py +0 -0
  31. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/commands/session.py +0 -0
  32. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/commands/stack.py +0 -0
  33. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/local/__init__.py +0 -0
  34. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/local/docker.py +0 -0
  35. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/local/env.py +0 -0
  36. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/local/health.py +0 -0
  37. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/local/profile.py +0 -0
  38. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/local/setup.py +0 -0
  39. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/local/templates/__init__.py +0 -0
  40. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/local/templates/docker-compose.yml +0 -0
  41. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/local/templates/init.sql +0 -0
  42. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/oauth.py +0 -0
  43. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/output.py +0 -0
  44. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/recall.py +0 -0
  45. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/update_check.py +0 -0
  46. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/src/honcho_cli/validation.py +0 -0
  47. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/__init__.py +0 -0
  48. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/conftest.py +0 -0
  49. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_commands.py +0 -0
  50. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_conclusion_attribution.py +0 -0
  51. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_config.py +0 -0
  52. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_install.py +0 -0
  53. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_local.py +0 -0
  54. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_oauth.py +0 -0
  55. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_output.py +0 -0
  56. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_recall.py +0 -0
  57. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_setup.py +0 -0
  58. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_start.py +0 -0
  59. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/tests/test_validation.py +0 -0
  60. {honcho_cli-0.4.0 → honcho_cli-0.6.0}/uv.lock +0 -0
@@ -5,6 +5,30 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## [0.6.0] - 2026-11-10
9
+
10
+ ### Added
11
+
12
+ - `honcho workspace replay --from <id> --to <id>`: copy a workspace by replaying it. Workspace, peer and session metadata and configuration, session membership and scopes are copied, then every message is re-sent in order with its original `created_at`, so the destination derives its own conclusions, summaries and peer cards; nothing derived is copied. `--from-url` / `--to-url` (and `HONCHO_FROM_API_KEY` / `HONCHO_TO_API_KEY`) put either side on another Honcho instance, and the configured credentials are never sent to an instance they were not issued for. `--num-sessions N` replays only the N sessions with the most recent message, `--dry-run` reads both sides without writing and says, for each session, whether a replay will create it, resume it, find it up to date, or skip it as a conflict, and a rerun resumes by skipping messages the destination already has. A destination session whose messages differ from the source is left untouched and reported. In a terminal the command prints a short report and the `queue-status` command that shows derivation on the destination; `--json` prints the same facts as one object. Both reports count the conclusions in the source (`not_copied`), because conclusions and peer cards written through the API have no source message and are not recreated. The destination session has the source's current members from its first message, so a peer that joined late observes the whole session. With a workspace-scoped key, a source that has no sessions and no peers is reported as `NOTHING_TO_REPLAY` and is not created. Per-message configuration is not stored by Honcho and cannot be replayed (#1573)
13
+
14
+ ### Fixed
15
+
16
+ - `honcho --version`, the update check and the `X-Honcho-Host` header report the installed version. `__version__` was a hardcoded string that the 0.5.0 release did not bump, so a 0.5.0 install reported itself as 0.4.0, and the update check told 0.5.0 users that 0.5.0 was available. The version is now read from the installed package metadata (#1571)
17
+
18
+ ## [0.5.0] - 2026-11-05
19
+
20
+ ### Added
21
+
22
+ - `honcho dream list` and `honcho dream inspect <id>` (Representation History): list the dreams in a workspace, newest first, or the dreams about one peer with `-p`, and see what a dream changed. `inspect` shows the conclusions it created, each with the conclusions it was derived from and where those stand now (current, removed and by which dream, or unavailable once deleted or removed longer ago than history is kept); the conclusions it removed, as they read when removed; and the peer card before and after. A dream past the retention window shows when it was pruned and keeps only the conclusions it created that still exist. Needs a workspace or admin key, and Honcho v3.6.0+ (#1542)
23
+
24
+ ### Changed
25
+
26
+ - Requires `honcho-ai` 2.9.0 or newer, the first Python SDK with `dreams()` and `get_dream()`
27
+
28
+ ### Fixed
29
+
30
+ - `HONCHO_API_KEY` wins over a saved OAuth grant, as the documented flag > env > file order says. Before, `HONCHO_API_KEY=<key> honcho workspace list` quietly ran as the saved OAuth identity. A run with an env key no longer refreshes or writes `~/.honcho/config.json`, and an OAuth refresh under `HONCHO_API_KEY` or `HONCHO_BASE_URL` no longer writes those values into it, which had switched every other tool sharing the file to that key's org. A refreshed grant records the host it was refreshed against, and `honcho doctor` names the env key as the credential in use (#1518)
31
+
8
32
  ## [0.4.0] - 2026-10-29
9
33
 
10
34
  ### Added
@@ -32,6 +56,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
32
56
 
33
57
  - `honcho session summaries`, `honcho session inspect`, `honcho session context` and `honcho workspace queue-status` emit nested SDK objects (summaries, context messages, per-session queue status) as JSON objects instead of Python repr strings like `"content='...' message_id='...'"` (#1324)
34
58
 
59
+ ## [0.2.1] - 2026-10-20
60
+
61
+ ### Fixed
62
+
63
+ - `honcho session summaries`, `honcho session inspect`, `honcho session context` and `honcho workspace queue-status` emit nested SDK objects (summaries, context messages, per-session queue status) as JSON objects instead of Python repr strings like `"content='...' message_id='...'"` (#1324)
64
+
35
65
  ## [0.2.0] - 2026-09-21
36
66
 
37
67
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: honcho-cli
3
- Version: 0.4.0
3
+ Version: 0.6.0
4
4
  Summary: A terminal for Honcho — memory that reasons.
5
5
  Project-URL: Homepage, https://github.com/plastic-labs/honcho
6
6
  Project-URL: Repository, https://github.com/plastic-labs/honcho
@@ -15,7 +15,7 @@ Classifier: Topic :: Software Development :: Libraries
15
15
  Requires-Python: >=3.11
16
16
  Requires-Dist: certifi>=2026.10.19
17
17
  Requires-Dist: click>=8.0.0
18
- Requires-Dist: honcho-ai>=2.8.0
18
+ Requires-Dist: honcho-ai>=2.9.0
19
19
  Requires-Dist: httpx>=0.27.0
20
20
  Requires-Dist: questionary>=2.1.0
21
21
  Requires-Dist: rich>=13.0.0
@@ -107,6 +107,7 @@ honcho stop --wipe # also delete volumes
107
107
  | `honcho workspace chat <query>` | Query the dialectic across all peers (optional `-s` / `--scope` / `--reasoning`) |
108
108
  | `honcho workspace search <query>` | Search messages across workspace |
109
109
  | `honcho workspace queue-status` | Deriver queue status (filter with `--observer` / `--sender`) |
110
+ | `honcho workspace replay --from <id> --to <id>` | Copy a workspace by re-sending its messages, so the destination derives its own memory. `--to-url` / `--from-url` for another instance, `--num-sessions N` for the N most recently active sessions, `--dry-run` to preview |
110
111
  | `honcho workspace delete <id>` | Delete a workspace. Use `--dry-run` to preview, `--cascade` to also delete sessions, `--yes` to skip the confirm prompt |
111
112
 
112
113
  ### Peers
@@ -166,6 +167,13 @@ honcho stop --wipe # also delete volumes
166
167
  | `honcho conclusion create` | Create a conclusion |
167
168
  | `honcho conclusion delete <id>` | Delete a conclusion |
168
169
 
170
+ ### Dreams (Representation History)
171
+
172
+ | Command | Description |
173
+ |---------|-------------|
174
+ | `honcho dream list` | Dreams in the workspace, newest first (`-p` for dreams about one peer, `--observer` for one representation) |
175
+ | `honcho dream inspect <id>` | What one dream changed: conclusions created (with what each was derived from), conclusions removed, and the peer card before and after |
176
+
169
177
  ### Config
170
178
 
171
179
  | Command | Description |
@@ -228,6 +236,8 @@ Precedence (highest first): **flag → env var → config file → default**.
228
236
  | `HONCHO_JSON` | `--json` | Force JSON output (`1` / `true`) |
229
237
  | `HONCHO_NO_UPDATE_CHECK` | — | Disable the once-a-day upgrade notice (`1` / `true`) |
230
238
  | `HONCHO_PROFILE` | `--profile` (start/stop/status) | Local stack profile (default: `local`) |
239
+ | `HONCHO_FROM_URL` / `HONCHO_FROM_API_KEY` | `--from-url` (workspace replay); the key has no flag | Source instance, when it is not the configured one |
240
+ | `HONCHO_TO_URL` / `HONCHO_TO_API_KEY` | `--to-url` (workspace replay); the key has no flag | Destination instance, when it is not the configured one |
231
241
  | `LLM_OPENAI_API_KEY` | — | Provider key for `honcho start` (also `LLM_ANTHROPIC_API_KEY`, `LLM_GEMINI_API_KEY`) |
232
242
 
233
243
  ```bash
@@ -80,6 +80,7 @@ honcho stop --wipe # also delete volumes
80
80
  | `honcho workspace chat <query>` | Query the dialectic across all peers (optional `-s` / `--scope` / `--reasoning`) |
81
81
  | `honcho workspace search <query>` | Search messages across workspace |
82
82
  | `honcho workspace queue-status` | Deriver queue status (filter with `--observer` / `--sender`) |
83
+ | `honcho workspace replay --from <id> --to <id>` | Copy a workspace by re-sending its messages, so the destination derives its own memory. `--to-url` / `--from-url` for another instance, `--num-sessions N` for the N most recently active sessions, `--dry-run` to preview |
83
84
  | `honcho workspace delete <id>` | Delete a workspace. Use `--dry-run` to preview, `--cascade` to also delete sessions, `--yes` to skip the confirm prompt |
84
85
 
85
86
  ### Peers
@@ -139,6 +140,13 @@ honcho stop --wipe # also delete volumes
139
140
  | `honcho conclusion create` | Create a conclusion |
140
141
  | `honcho conclusion delete <id>` | Delete a conclusion |
141
142
 
143
+ ### Dreams (Representation History)
144
+
145
+ | Command | Description |
146
+ |---------|-------------|
147
+ | `honcho dream list` | Dreams in the workspace, newest first (`-p` for dreams about one peer, `--observer` for one representation) |
148
+ | `honcho dream inspect <id>` | What one dream changed: conclusions created (with what each was derived from), conclusions removed, and the peer card before and after |
149
+
142
150
  ### Config
143
151
 
144
152
  | Command | Description |
@@ -201,6 +209,8 @@ Precedence (highest first): **flag → env var → config file → default**.
201
209
  | `HONCHO_JSON` | `--json` | Force JSON output (`1` / `true`) |
202
210
  | `HONCHO_NO_UPDATE_CHECK` | — | Disable the once-a-day upgrade notice (`1` / `true`) |
203
211
  | `HONCHO_PROFILE` | `--profile` (start/stop/status) | Local stack profile (default: `local`) |
212
+ | `HONCHO_FROM_URL` / `HONCHO_FROM_API_KEY` | `--from-url` (workspace replay); the key has no flag | Source instance, when it is not the configured one |
213
+ | `HONCHO_TO_URL` / `HONCHO_TO_API_KEY` | `--to-url` (workspace replay); the key has no flag | Destination instance, when it is not the configured one |
204
214
  | `LLM_OPENAI_API_KEY` | — | Provider key for `honcho start` (also `LLM_ANTHROPIC_API_KEY`, `LLM_GEMINI_API_KEY`) |
205
215
 
206
216
  ```bash
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "honcho-cli"
3
- version = "0.4.0"
3
+ version = "0.6.0"
4
4
  description = "A terminal for Honcho — memory that reasons."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -19,7 +19,7 @@ classifiers = [
19
19
  dependencies = [
20
20
  "click>=8.0.0",
21
21
  "typer>=0.15.0",
22
- "honcho-ai>=2.8.0",
22
+ "honcho-ai>=2.9.0",
23
23
  "rich>=13.0.0",
24
24
  "httpx>=0.27.0",
25
25
  "questionary>=2.1.0",
@@ -0,0 +1,11 @@
1
+ """Honcho CLI — a terminal for Honcho."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ # pyproject.toml is the single source of the version; reading it from the
7
+ # installed metadata keeps --version, the update check and the
8
+ # X-Honcho-Host header in step with each release bump.
9
+ __version__ = version("honcho-cli")
10
+ except PackageNotFoundError: # running from a source tree that isn't installed
11
+ __version__ = "0+unknown"
@@ -82,6 +82,7 @@ def print_welcome(console: Console) -> None:
82
82
  ("[dim]example[/dim]", "[dim]honcho peer chat \"what does alice prefer?\" -p alice -w agents[/dim]"),
83
83
  ("", ""),
84
84
  ("workspace", "list · create · search · chat · delete · inspect · queue-status"),
85
+ ("", "replay"),
85
86
  ("peer", "list · create · search · inspect · card · chat"),
86
87
  ("", "get-metadata · set-metadata · representation"),
87
88
  ("session", "list · create · search · delete · inspect · view · add-peers"),
@@ -91,6 +92,7 @@ def print_welcome(console: Console) -> None:
91
92
  ("", "remove-session · status"),
92
93
  ("message", "list · create · get"),
93
94
  ("conclusion", "list · create · search · delete"),
95
+ ("dream", "list · inspect"),
94
96
  ("config", "inspect current configuration"),
95
97
  ]
96
98
  memory_rows = [
@@ -103,6 +105,7 @@ def print_welcome(console: Console) -> None:
103
105
  ("honcho peer chat \"...\" -p <peer> --scope <scope>", "answer from one scope's sessions only"),
104
106
  ("honcho peer card -p <peer> -w <workspace>", "synthesized identity: traits, preferences, instructions"),
105
107
  ("honcho conclusion list -p <peer> -w <workspace>", "browse peer conclusions"),
108
+ ("honcho dream list -p <peer> -w <workspace>", "dreams about a peer; inspect one to see what it changed"),
106
109
  ("honcho session view / context -s <session>", "transcript, or what an agent would see"),
107
110
  ("honcho workspace queue-status", "is the deriver processing?"),
108
111
  ]
@@ -0,0 +1,318 @@
1
+ """Dream commands: list, inspect.
2
+
3
+ Representation History: every dream records what it changed in a peer's
4
+ representation — the conclusions it created (with the conclusions each was
5
+ derived from), the conclusions it removed (with their text as it read when
6
+ removed), and the peer card before and after. Runs are kept for the server's
7
+ retention window (30 days by default). Needs a workspace or admin key.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from datetime import datetime
13
+ from typing import Any, Optional
14
+
15
+ import typer
16
+ from rich.console import Group
17
+ from rich.panel import Panel
18
+ from rich.table import Table
19
+ from rich.text import Text
20
+
21
+ from honcho_cli._help import HonchoTyperGroup
22
+ from honcho_cli.commands.workspace import _handle_error
23
+ from honcho_cli.common import add_common_options, get_client, handle_cmd_flags
24
+ from honcho_cli.output import (
25
+ _format_timestamp,
26
+ print_error,
27
+ print_json,
28
+ status,
29
+ stdout_console,
30
+ use_json,
31
+ )
32
+ from honcho_cli.validation import validate_resource_id
33
+
34
+ app = typer.Typer(
35
+ cls=HonchoTyperGroup,
36
+ help="List dreams and inspect what each one changed in a peer's representation.",
37
+ )
38
+ add_common_options(app)
39
+
40
+
41
+ _STATUS_STYLE = {
42
+ "completed": "green",
43
+ "running": "cyan",
44
+ "failed": "red",
45
+ "interrupted": "yellow",
46
+ }
47
+
48
+ def _short_time(value: datetime | None) -> str:
49
+ """``YYYY-MM-DD HH:MM`` UTC — a dream takes minutes, not milliseconds."""
50
+ return _format_timestamp(value)[:16].replace("T", " ") if value else ""
51
+
52
+
53
+ def _changes(run: Any) -> Text:
54
+ text = Text()
55
+ text.append(f"+{run.created_count}", style="green" if run.created_count else "dim")
56
+ text.append(" ")
57
+ text.append(f"-{run.removed_count}", style="red" if run.removed_count else "dim")
58
+ if run.peer_card_updated:
59
+ text.append(" card", style="cyan")
60
+ return text
61
+
62
+
63
+ def _print_runs(runs: list, title: str) -> None:
64
+ """Dream runs as a table. Run IDs never truncate: they feed `dream inspect`."""
65
+ table = Table(title=title, show_header=True, header_style="bold")
66
+ # min_width holds the id whole in a narrow terminal; the rest wrap instead.
67
+ table.add_column("id", no_wrap=True, min_width=max(len(run.id) for run in runs))
68
+ table.add_column("started (UTC)", style="dim")
69
+ table.add_column("status")
70
+ table.add_column("observer → observed", overflow="fold")
71
+ table.add_column("type", style="dim", overflow="fold")
72
+ table.add_column("changes")
73
+ for run in runs:
74
+ table.add_row(
75
+ run.id,
76
+ _short_time(run.started_at),
77
+ Text(run.status, style=_STATUS_STYLE.get(run.status, "")),
78
+ f"{run.observer_id} → {run.observed_id}",
79
+ " · ".join(part for part in (run.dream_type, run.trigger_reason) if part),
80
+ _changes(run),
81
+ )
82
+ stdout_console.print(table)
83
+
84
+
85
+ @app.command("list")
86
+ def list_dreams(
87
+ observer: Optional[str] = typer.Option(
88
+ None,
89
+ "--observer",
90
+ help="Only dreams from this observer's perspective (with -p: one representation)",
91
+ ),
92
+ limit: int = typer.Option(20, "--limit", help="Dreams per page"),
93
+ page: int = typer.Option(1, "--page", help="Page number, newest dreams first"),
94
+ workspace: Optional[str] = typer.Option(None, "--workspace", "-w", help="Override workspace ID"),
95
+ peer: Optional[str] = typer.Option(
96
+ None, "--peer", "-p", help="Only dreams about this peer (the observed peer)"
97
+ ),
98
+ json_output: bool = typer.Option(False, "--json", help="Force JSON output"),
99
+ ) -> None:
100
+ """List dreams in the workspace, newest first.
101
+
102
+ Pass -p to see the dreams about one peer, and --observer to narrow to one
103
+ observer's model of that peer. `honcho dream inspect <id>` shows what a
104
+ dream changed.
105
+ """
106
+ handle_cmd_flags(json_output=json_output, workspace=workspace, peer=peer)
107
+ if limit < 1 or page < 1:
108
+ print_error("INVALID_ARGUMENT", "--limit and --page must be positive")
109
+ raise typer.Exit(1)
110
+ if observer:
111
+ validate_resource_id(observer, "peer")
112
+ client, config = get_client()
113
+
114
+ try:
115
+ # An unset peer is "" in config; "" would filter to no peer at all.
116
+ result = client.dreams(
117
+ observed=config.peer_id or None, observer=observer or None, page=page, size=limit
118
+ )
119
+ if use_json():
120
+ print_json([run.model_dump(mode="json") for run in result.items])
121
+ return
122
+ title = "Dreams"
123
+ if config.peer_id:
124
+ title += f" about {config.peer_id}"
125
+ if result.pages:
126
+ title += f" · page {result.page}/{result.pages}"
127
+ if not result.items:
128
+ status("No dreams recorded in the retention window.")
129
+ return
130
+ _print_runs(result.items, title)
131
+ if result.pages and page < result.pages:
132
+ status(f"more: --page {page + 1}")
133
+ except Exception as e:
134
+ _handle_error(e, "dream", "list")
135
+
136
+
137
+ def _duration(started: datetime, finished: datetime | None) -> str:
138
+ if finished is None:
139
+ return ""
140
+ seconds = int((finished - started).total_seconds())
141
+ minutes, seconds = divmod(seconds, 60)
142
+ return f"{minutes}m {seconds:02d}s" if minutes else f"{seconds}s"
143
+
144
+
145
+ def _removed_note(removed_in_run: str | None, run_id: str) -> str:
146
+ if removed_in_run == run_id:
147
+ return "removed in this dream"
148
+ return f"removed by dream {removed_in_run}" if removed_in_run else "removed"
149
+
150
+
151
+ def _source_line(source: Any, run_id: str) -> Text:
152
+ """One source conclusion, marked by what has happened to it since."""
153
+ line = Text(" ")
154
+ if source.status == "current":
155
+ line.append("● ", style="green")
156
+ line.append(source.content or "")
157
+ elif source.status == "removed":
158
+ line.append("✕ ", style="red")
159
+ line.append(source.content or "", style="strike dim")
160
+ line.append(f" {_removed_note(source.removed_in_run, run_id)}", style="dim red")
161
+ else:
162
+ line.append("? ", style="dim")
163
+ line.append(
164
+ f"{source.id} (unavailable: deleted, or removed longer ago than history is kept)",
165
+ style="dim",
166
+ )
167
+ return line
168
+
169
+
170
+ def _header(detail: Any) -> Panel:
171
+ status_text = Text(detail.status, style=f"bold {_STATUS_STYLE.get(detail.status, '')}")
172
+ grid = Table.grid(padding=(0, 2))
173
+ grid.add_column(style="bold")
174
+ grid.add_column()
175
+ grid.add_row("representation", f"{detail.observer_id} → {detail.observed_id}")
176
+ grid.add_row(
177
+ "type",
178
+ " · ".join(part for part in (detail.dream_type, detail.trigger_reason) if part),
179
+ )
180
+ grid.add_row("status", status_text)
181
+ grid.add_row("started", _format_timestamp(detail.started_at))
182
+ if detail.finished_at:
183
+ grid.add_row(
184
+ "finished",
185
+ f"{_format_timestamp(detail.finished_at)} "
186
+ f"({_duration(detail.started_at, detail.finished_at)})",
187
+ )
188
+ if detail.pruned_at:
189
+ grid.add_row(
190
+ "pruned",
191
+ Text(
192
+ f"{_format_timestamp(detail.pruned_at)} past retention: only "
193
+ "created conclusions that still exist are shown",
194
+ style="dim",
195
+ ),
196
+ )
197
+ grid.add_row(
198
+ "changes",
199
+ Text.assemble(
200
+ (f"+{detail.created_count} created", "green"),
201
+ " ",
202
+ (f"-{detail.removed_count} removed", "red"),
203
+ " ",
204
+ ("peer card updated" if detail.peer_card_updated else "peer card unchanged", "dim"),
205
+ ),
206
+ )
207
+ return Panel(grid, title=f"dream {detail.id}", title_align="left")
208
+
209
+
210
+ def _created_table(detail: Any) -> Table:
211
+ table = Table(
212
+ title=f"Created ({len(detail.created)})",
213
+ title_justify="left",
214
+ show_header=True,
215
+ header_style="bold",
216
+ show_lines=True,
217
+ expand=True,
218
+ )
219
+ table.add_column("specialist", style="dim", no_wrap=True)
220
+ table.add_column("level", no_wrap=True)
221
+ table.add_column("conclusion, and what it was derived from", ratio=1)
222
+ for created in detail.created:
223
+ conclusion = created.conclusion
224
+ body = Text()
225
+ body.append("+ ", style="bold green")
226
+ if conclusion.status == "current":
227
+ body.append(conclusion.content or "")
228
+ elif conclusion.status == "removed":
229
+ body.append(conclusion.content or "", style="strike")
230
+ body.append(
231
+ f" ({_removed_note(conclusion.removed_in_run, detail.id)})", style="dim red"
232
+ )
233
+ else:
234
+ body.append(f"{conclusion.id} (unavailable)", style="dim")
235
+ lines = [body] + [_source_line(source, detail.id) for source in created.sources]
236
+ table.add_row(created.specialist or "", conclusion.level or "", Group(*lines))
237
+ return table
238
+
239
+
240
+ def _removed_table(detail: Any) -> Table:
241
+ replacements = {c.conclusion.id: c.conclusion.content for c in detail.created}
242
+ table = Table(
243
+ title=f"Removed ({len(detail.removed)})",
244
+ title_justify="left",
245
+ show_header=True,
246
+ header_style="bold",
247
+ show_lines=True,
248
+ expand=True,
249
+ )
250
+ table.add_column("specialist", style="dim", no_wrap=True)
251
+ table.add_column("level", no_wrap=True)
252
+ table.add_column("conclusion, as it read when removed", ratio=1)
253
+ for removed in detail.removed:
254
+ body = Text()
255
+ body.append("- ", style="bold red")
256
+ body.append(removed.content)
257
+ lines = [body]
258
+ if removed.replaced_by:
259
+ replacement = replacements.get(removed.replaced_by) or removed.replaced_by
260
+ lines.append(Text(f" replaced by: {replacement}", style="dim"))
261
+ table.add_row(removed.specialist or "", removed.level or "", Group(*lines))
262
+ return table
263
+
264
+
265
+ def _peer_card_panel(detail: Any) -> Panel:
266
+ before = list(detail.peer_card.before or [])
267
+ after = list(detail.peer_card.after)
268
+ lines: list[Text] = []
269
+ for entry in before:
270
+ if entry not in after:
271
+ lines.append(Text(f"- {entry}", style="red"))
272
+ for entry in after:
273
+ if entry in before:
274
+ lines.append(Text(f" {entry}", style="dim"))
275
+ else:
276
+ lines.append(Text(f"+ {entry}", style="green"))
277
+ if not lines:
278
+ lines.append(Text("(empty)", style="dim"))
279
+ return Panel(Group(*lines), title="Peer card", title_align="left")
280
+
281
+
282
+ @app.command()
283
+ def inspect(
284
+ run_id: str = typer.Argument(help="Dream run ID, from `honcho dream list`"),
285
+ workspace: Optional[str] = typer.Option(None, "--workspace", "-w", help="Override workspace ID"),
286
+ json_output: bool = typer.Option(False, "--json", help="Force JSON output"),
287
+ ) -> None:
288
+ """Show what one dream changed.
289
+
290
+ Lists the conclusions it created, each with the conclusions it was derived
291
+ from; the conclusions it removed, as they read when removed; and the peer
292
+ card before and after. Each source shows where it stands now: current,
293
+ removed (and by which dream), or unavailable once deleted or removed longer
294
+ ago than history is kept.
295
+ """
296
+ handle_cmd_flags(json_output=json_output, workspace=workspace)
297
+ validate_resource_id(run_id, "dream")
298
+ client, _config = get_client()
299
+
300
+ try:
301
+ detail = client.get_dream(run_id)
302
+ except Exception as e:
303
+ _handle_error(e, "dream", run_id)
304
+ return
305
+
306
+ if use_json():
307
+ print_json(detail.model_dump(mode="json"))
308
+ return
309
+
310
+ stdout_console.print(_header(detail))
311
+ if detail.created:
312
+ stdout_console.print(_created_table(detail))
313
+ if detail.removed:
314
+ stdout_console.print(_removed_table(detail))
315
+ if detail.peer_card is not None:
316
+ stdout_console.print(_peer_card_panel(detail))
317
+ if not (detail.created or detail.removed or detail.peer_card):
318
+ status("This dream committed no changes.")
@@ -334,6 +334,8 @@ def _check_connection(base_url: str, api_key: str) -> None:
334
334
 
335
335
  def _auth_mode_detail(config: CLIConfig) -> str:
336
336
  """Human summary of which credential the CLI will use."""
337
+ if config.api_key_from_env:
338
+ return "API key (HONCHO_API_KEY)"
337
339
  tokens = config.usable_oauth()
338
340
  if tokens is not None:
339
341
  if tokens.access_valid():