From 07e8f442cb90d3b86c583c9ab9c8cd379f0fce35 Mon Sep 17 00:00:00 2001 From: damocles Date: Fri, 5 Jun 2026 22:16:00 +0200 Subject: [PATCH] fix: hivectl choom passes the harness --settings/--mcp-config/--system-prompt-file so claude gets settings + tools + persona --- docs/tools/hivectl-cli.md | 2 +- docs/tools/hivectl.md | 23 +++++++++---- hive-c0re/src/bin/hivectl.rs | 67 +++++++++++++++++++++++++----------- 3 files changed, 64 insertions(+), 28 deletions(-) diff --git a/docs/tools/hivectl-cli.md b/docs/tools/hivectl-cli.md index 972abbe4..65249f1a 100644 --- a/docs/tools/hivectl-cli.md +++ b/docs/tools/hivectl-cli.md @@ -281,7 +281,7 @@ 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. -The session is entered **as the agent user** (not root): claude reads its OAuth credentials + settings from the agent's `/home//.claude`, and the working directory is set to the agent's state dir (`/agents//state`) so `--continue` resumes the same per-project session the harness runs. Entering as root (the `machinectl shell` default) is what loses both. +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. diff --git a/docs/tools/hivectl.md b/docs/tools/hivectl.md index ddc974ba..51989da5 100644 --- a/docs/tools/hivectl.md +++ b/docs/tools/hivectl.md @@ -124,10 +124,19 @@ 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. -The session is entered **as the agent user**, not root: `machinectl -shell` defaults to root in the container, which would make claude read -`/root/.claude` (empty) instead of the agent's `/home//.claude` -where its OAuth credentials + settings live. choom prefixes the -machine with `@` (the meta-flake sets the agent's unix user name -to its label) and `cd`s into `/agents//state` first so -`--continue` resolves the same per-project session the harness runs. +choom reproduces the harness's own claude invocation so the operator +lands in a faithful copy of the agent's environment: + +- **as the agent user**, not root: `machinectl shell` defaults to root, + which would make claude read `/root/.claude` (empty) instead of the + 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. +- **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. diff --git a/hive-c0re/src/bin/hivectl.rs b/hive-c0re/src/bin/hivectl.rs index fd36f8a8..36c56ad7 100644 --- a/hive-c0re/src/bin/hivectl.rs +++ b/hive-c0re/src/bin/hivectl.rs @@ -80,12 +80,14 @@ enum Cmd { /// root (same as all machinectl shell operations) and the container /// must be running. /// - /// The session is entered **as the agent user** (not root): claude - /// reads its OAuth credentials + settings from the agent's - /// `/home//.claude`, and the working directory is set to the - /// agent's state dir (`/agents//state`) so `--continue` - /// resumes the same per-project session the harness runs. Entering - /// as root (the `machinectl shell` default) is what loses both. + /// 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. @@ -366,23 +368,35 @@ fn is_agent(name: &str) -> bool { /// Drop into an interactive Claude session in the agent container. /// /// Replaces the current process (exec) with `machinectl shell -/// @h- /bin/sh -lc 'cd /agents//state && exec claude -/// [--continue]'`. Two things matter here, both of which the naive +/// @h- /bin/sh -lc '