Skip to content

Commit d7ddd65

Browse files
committed
add read command
1 parent 517949d commit d7ddd65

5 files changed

Lines changed: 33 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ API key priority (lowest to highest): config file → `HOTDATA_API_KEY` env var
7171
| `indexes` | `list`, `create` | Manage indexes on a table |
7272
| `results` | `list` | Retrieve stored query results |
7373
| `jobs` | `list` | Manage background jobs |
74-
| `sessions` | `list`, `new`, `set`, `update`, `run` | Manage work sessions |
74+
| `sessions` | `list`, `new`, `set`, `read`, `update`, `run` | Manage work sessions |
7575
| `skills` | `install`, `status` | Manage the hotdata-cli agent skill |
7676

7777
## Global options
@@ -235,6 +235,7 @@ hotdata sessions list [-w <id>] [-o table|json|yaml]
235235
hotdata sessions <session_id> [-w <id>] [-o table|json|yaml]
236236
hotdata sessions new [--name "My Session"] [-o table|json|yaml]
237237
hotdata sessions set [<session_id>]
238+
hotdata sessions read
238239
hotdata sessions update [<session_id>] [--name "New Name"] [--markdown "..."] [-o table|json|yaml]
239240
hotdata sessions run <cmd> [args...]
240241
hotdata sessions <session_id> run <cmd> [args...]
@@ -243,6 +244,7 @@ hotdata sessions <session_id> run <cmd> [args...]
243244
- `list` shows all sessions with a `*` marker on the active one.
244245
- `new` creates a session and sets it as active.
245246
- `set` switches the active session. Omit the ID to clear the active session.
247+
- `read` prints the markdown content of the current session.
246248
- `update` modifies the name or markdown of a session (defaults to the active session).
247249
- `run` runs a command with the hotdata CLI sandboxed in a session. Creates a new session unless a session ID is provided before `run`. Useful for launching an agent that can only access session data. Nesting sessions is not allowed.
248250

skills/hotdata/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ hotdata sessions list [-w <workspace_id>] [-o table|json|yaml]
287287
hotdata sessions <session_id> [-w <workspace_id>] [-o table|json|yaml]
288288
hotdata sessions new [--name "Session Name"] [-o table|json|yaml]
289289
hotdata sessions set [<session_id>]
290+
hotdata sessions read
290291
hotdata sessions update [<session_id>] [--name "New Name"] [--markdown "..."] [-o table|json|yaml]
291292
hotdata sessions run <cmd> [args...]
292293
hotdata sessions <session_id> run <cmd> [args...]
@@ -295,6 +296,7 @@ hotdata sessions <session_id> run <cmd> [args...]
295296
- `list` shows all sessions with a `*` marker on the active one.
296297
- `new` creates a session and sets it as active. Blocked inside an existing session.
297298
- `set` switches the active session. Omit the ID to clear. Blocked inside an existing session.
299+
- `read` prints the markdown content of the current session. Use this to retrieve session state at the start of work or between steps.
298300
- `update` modifies a session's name or markdown. Defaults to the active session if no ID is given. The `--markdown` field is for writing details about the work being done in the session — observations, intermediate findings, next steps, etc. This state persists for the life of the session and is the primary way to record context that should survive across commands or agent invocations within the session.
299301
- `run` launches a command with `HOTDATA_SESSION` and `HOTDATA_WORKSPACE` set in the child process environment. Creates a new session unless a session ID is provided before `run`. Blocked inside an existing session.
300302
- When inside a session (HOTDATA_SESSION is set), all API requests automatically include the session ID — no extra flags needed.

src/command.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,9 @@ pub enum SessionsCommands {
597597
output: String,
598598
},
599599

600+
/// Print the markdown content of the current session
601+
Read,
602+
600603
/// Set the active session (omit ID to clear)
601604
Set {
602605
/// Session ID to set as active (omit to clear)

src/main.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,20 @@ fn main() {
358358
}
359359
}
360360
}
361+
Some(SessionsCommands::Read) => {
362+
let session_id = id.or_else(|| {
363+
std::env::var("HOTDATA_SESSION").ok()
364+
}).or_else(|| {
365+
config::load("default").ok().and_then(|p| p.session)
366+
});
367+
match session_id {
368+
Some(sid) => sessions::read(&sid, &workspace_id),
369+
None => {
370+
eprintln!("error: no active session. Use 'sessions new' or 'sessions set <id>'.");
371+
std::process::exit(1);
372+
}
373+
}
374+
}
361375
Some(SessionsCommands::Set { id: set_id }) => {
362376
sessions::set(set_id.as_deref(), &workspace_id)
363377
}

src/sessions.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ pub fn get(session_id: &str, workspace_id: &str, format: &str) {
7878
}
7979
}
8080

81+
pub fn read(session_id: &str, workspace_id: &str) {
82+
let api = ApiClient::new(Some(workspace_id));
83+
let path = format!("/sessions/{session_id}");
84+
let body: DetailResponse = api.get(&path);
85+
if body.session.markdown.is_empty() {
86+
eprintln!("{}", "Session markdown is empty.".dark_grey());
87+
} else {
88+
print!("{}", body.session.markdown);
89+
}
90+
}
91+
8192
fn check_session_lock() {
8293
if std::env::var("HOTDATA_SESSION").is_ok() || find_session_run_ancestor().is_some() {
8394
eprintln!("error: session is locked");

0 commit comments

Comments
 (0)