diff --git a/docs/tools/hivectl-cli.md b/docs/tools/hivectl-cli.md index 5100315c..4626758a 100644 --- a/docs/tools/hivectl-cli.md +++ b/docs/tools/hivectl-cli.md @@ -379,11 +379,7 @@ Generate the federation peer-config block for THIS hive — the nix a peer opera Open an interactive Claude session inside an agent container. -Replaces the current process with `machinectl shell @h-` running `claude --continue` from the agent's state dir — drops the operator straight into the agent's live Claude session with its full loaded context and persona. Requires root (same as all machinectl shell operations) and the container must be running. - -To match the harness exactly, choom enters **as the agent user** (not root) so claude reads the OAuth credentials from the agent's `/home//.claude`; runs from the agent's state dir (`/agents//state`) so `--continue` resumes the right per-project session and `CLAUDE.md` loads; and passes the same `--settings` / `--mcp-config` / `--system-prompt-file` the harness writes to `/run/hive-config/` (settings, MCP tools, role prompt). Entering as root (the `machinectl shell` default) loses all of it. - -Pass `--fresh` to start a new Claude session instead of continuing the most recent one. +Runs claude as the agent user from its state dir with the harness's settings / MCP / system prompt. Bare `choom ` is a fresh session; `--continue ` rejoins a prior one. Never collides with the harness's live session. Requires root + a running container. See `docs/tools/hivectl.md` (Choom) for details. **Usage:** `hivectl choom [OPTIONS] ` @@ -393,7 +389,7 @@ Pass `--fresh` to start a new Claude session instead of continuing the most rece ###### **Options:** -* `--fresh` — Start a fresh Claude session instead of continuing the most recent one. Without this flag `--continue` is passed to Claude so the operator joins the agent's ongoing session context +* `--continue ` — Resume a prior claude session by id or display name, passed through as `claude --continue `. Omit for a fresh blank session. A value is required when the flag is given diff --git a/docs/tools/hivectl.md b/docs/tools/hivectl.md index 519e8953..9195899c 100644 --- a/docs/tools/hivectl.md +++ b/docs/tools/hivectl.md @@ -123,17 +123,22 @@ reported at the end rather than aborting mid-run. Drop into an interactive Claude session inside an agent container. Replaces the current process with `machinectl shell @h-` -running `claude --continue` from the agent's state dir. Requires root -(same as all `machinectl shell` operations). +running claude from the agent's state dir. Requires root (same as all +`machinectl shell` operations). ```bash -hivectl choom iris # join iris's ongoing Claude session (--continue) -hivectl choom iris --fresh # start a new Claude session instead +hivectl choom iris # fresh blank Claude session in iris's container +hivectl choom iris --continue # rejoin a prior session by id or display name ``` -Without `--fresh`, `--continue` is passed so the operator joins the -agent's live context window. With `--fresh` a clean session starts. -The container must be running. +Bare `choom` starts a fresh blank session. `--continue ` is +passed straight through as `claude --continue ` to rejoin a +prior session — claude resolves whether the value is a session id or a +display name (you can `/rename` a session in-session for an easy +handle). A value is required when the flag is given. Either way choom +never collides with the harness's live session in the same project dir: +the harness pins its own id via `--resume`, so a blank choom session is +invisible to it. The container must be running. choom reproduces the harness's own claude invocation so the operator lands in a faithful copy of the agent's environment: @@ -143,14 +148,13 @@ lands in a faithful copy of the agent's environment: agent's `/home//.claude` where its OAuth credentials live. choom prefixes the machine with `@` (the meta-flake sets the agent's unix user name to its label). -- **from `/agents//state`**: `--continue` resolves the session for - that project dir and `CLAUDE.md` (the persona) loads from the cwd. +- **from `/agents//state`**: the session and `CLAUDE.md` (the + persona) resolve against the right project dir. - **with the harness flags**: `--settings`, `--mcp-config`, and `--system-prompt-file` from `/run/hive-config/` — the same files the harness writes each turn — so the operator gets the agent's settings, - the hyperhive/matrix MCP tools (which `--continue` needs to replay a - tool-using history), and the role prompt. Each flag is included only - when its file exists. + the hyperhive/matrix MCP tools, and the role prompt. Each flag is + included only when its file exists. ## Open diff --git a/hive-c0re/src/bin/hivectl.rs b/hive-c0re/src/bin/hivectl.rs index 6e050532..3b3a9e2e 100644 --- a/hive-c0re/src/bin/hivectl.rs +++ b/hive-c0re/src/bin/hivectl.rs @@ -110,32 +110,19 @@ enum Cmd { }, /// Open an interactive Claude session inside an agent container. /// - /// Replaces the current process with `machinectl shell - /// @h-` running `claude --continue` from the agent's - /// state dir — drops the operator straight into the agent's live - /// Claude session with its full loaded context and persona. Requires - /// root (same as all machinectl shell operations) and the container - /// must be running. - /// - /// To match the harness exactly, choom enters **as the agent user** - /// (not root) so claude reads the OAuth credentials from the agent's - /// `/home//.claude`; runs from the agent's state dir - /// (`/agents//state`) so `--continue` resumes the right - /// per-project session and `CLAUDE.md` loads; and passes the same - /// `--settings` / `--mcp-config` / `--system-prompt-file` the harness - /// writes to `/run/hive-config/` (settings, MCP tools, role prompt). - /// Entering as root (the `machinectl shell` default) loses all of it. - /// - /// Pass `--fresh` to start a new Claude session instead of continuing - /// the most recent one. + /// Runs claude as the agent user from its state dir with the harness's + /// settings / MCP / system prompt. Bare `choom ` is a fresh + /// session; `--continue ` rejoins a prior one. Never collides + /// with the harness's live session. Requires root + a running + /// container. See `docs/tools/hivectl.md` (Choom) for details. Choom { /// Agent name (e.g. `damocles`, `iris`). name: String, - /// Start a fresh Claude session instead of continuing the most - /// recent one. Without this flag `--continue` is passed to Claude - /// so the operator joins the agent's ongoing session context. - #[arg(long)] - fresh: bool, + /// Resume a prior claude session by id or display name, passed + /// through as `claude --continue `. Omit for a fresh + /// blank session. A value is required when the flag is given. + #[arg(long = "continue", value_name = "SESSION")] + continue_session: Option, }, /// Stop containers hive-wide in one operator action. Bare `hivectl /// stop` stops **everything** — all sub-agents plus the ci, forge, @@ -642,7 +629,10 @@ async fn main() -> Result<()> { Cmd::Subvol { cmd } => match cmd { SubvolCmd::Upgrade { name, yes } => subvol_upgrade(&socket, &name, yes).await, }, - Cmd::Choom { name, fresh } => choom(&name, fresh), + Cmd::Choom { + name, + continue_session, + } => choom(&name, continue_session.as_deref()), Cmd::Quota { cmd } => match cmd { QuotaCmd::Enable => quota_enable().await, QuotaCmd::Show { name } => quota_show(name.as_deref()).await, @@ -1035,69 +1025,47 @@ fn agent_exists(name: &str) -> Result { /// Drop into an interactive Claude session in the agent container. /// -/// Replaces the current process (exec) with `machinectl shell -/// @h- /bin/sh -lc '