Skip to content

The agent that grows with you

docs: bring cli-commands.md back under its file-size ratchet

Teknium72b1eece9fdc
diff --git a/website/docs/developer-guide/gateway-internals.md b/website/docs/developer-guide/gateway-internals.md
index 512e3a113ce..44a2b3a3df6 100644
--- a/website/docs/developer-guide/gateway-internals.md
+++ b/website/docs/developer-guide/gateway-internals.md
@@ -340,6 +340,77 @@ Setup orchestration lives in `hermes_cli/gateway_setup_service.py`. Its
`ensure_gateway_service` helper is not a general runtime discovery or auto-start API:
ordinary calls never reinstall a missing service based only on stored preference.
+## `hermes gateway ensure`
+
+Clients (Desktop, `hermes chat`, the TUI) discover or start the profile's session
+runtime with `hermes gateway ensure --json --timeout 60`; the summary is in the
+[CLI reference](../reference/cli-commands.md#local-runtime-discovery-and-startup).
+
+The timeout is a finite, positive total deadline in seconds (default `60`, enough for a
+cold daemon boot on a loaded host). An
+existing reservation or starting owner is waited for, not replaced. When absence
+is established, an existing service takes precedence; an unmanaged process is
+requested only when no service is found. This command never installs or rewrites
+service definitions, enables linger, elevates privileges, or clears update fences.
+Ambiguous or inaccessible ownership fails closed.
+
+Before requesting a service start, `ensure` checks its canonical profile directory
+and execution account, not just its unit/task name. Linux uses the manager's
+loaded command and environment (including effective drop-ins), macOS checks the
+loaded launchd job rather than assuming the on-disk plist is current, and Windows
+queries the actual task XML, principal, and installed launcher.
+
+- `profile_mismatch`: the installed service selects a different home or profile.
+ Inspect the selected service's `HERMES_HOME` and command-line profile selector;
+ use the matching profile or explicitly repair the service configuration.
+- `service_account_mismatch`: the service belongs to another account. Run the
+ client as that account, or explicitly configure a service for the intended user.
+- `service_identity_unverified`: the manager did not expose enough identity data,
+ or the definition uses unsupported dynamic configuration. Inspect it with
+ `systemctl [--user] show <unit> --all`, `launchctl print <domain>/<label>`, or
+ `schtasks /Query /TN <task> /XML`. Linux environment files, PAM/dynamic users,
+ start-time hooks and alternate root filesystems require operator review;
+ arbitrary shell launchers and modified Windows launcher scripts are not
+ interpreted by `ensure`. Restore an explicit supported definition through an
+ intentional service-management operation before retrying.
+
+These refusals do not start a service, rewrite configuration, or launch an
+unmanaged replacement. Standard explicitly bound default and custom-root installs
+remain eligible; a successful start request still must pass live readiness checks.
+
+On POSIX, local bootstrap checks the profile directory before it trusts the
+control socket inside it. Newly reserved homes are created with mode `0700`;
+existing permissions are never changed by `ensure`. The home keeps the operator's
+mode (a symlinked `~/.hermes`, `HERMES_HOME_MODE` `0701`/`0750`, or a `0755`
+home all work): read and search bits grant nothing against the owner-only (`0600`)
+socket. Only write access another user could use to swap the socket is refused
+with `inaccessible / unsafe_control_permissions`: world-write always, and
+group-write unless the group is the owner's private group (the umask-`002`
+user-private-group default) with no other members and no access ACL. The socket,
+its pointer file and the fallback socket directory stay strictly owner-only.
+Remove the extra write bit (`chmod o-w,g-w`) before retrying local attachment.
+
+| Exit code | Meaning |
+|-----------|---------|
+| `0` | Compatible session runtime ready. |
+| `2` | Invalid invocation, including invalid timeout or unknown arguments. |
+| `3` | Incompatible runtime protocol or capabilities. |
+| `4` | Authorization or profile mismatch. |
+| `5` | Deadline reached; startup may still be pending. |
+| `6` | Runtime draining or update in progress. |
+| `7` | Inaccessible runtime, conflicting supervisor, or startup failure. |
+
+A service start command or process creation is not a readiness acknowledgement.
+A gateway that has not exposed the session-authority capability can remain
+`starting` until the deadline even while its messaging adapters work. Do not treat
+exit `5` as permission to replace that owner. On Windows, a Startup-folder-only
+installation requires login rather than an unmanaged fallback; failure to detach
+from a parent job is reported instead of retried with weaker process isolation.
+
+Service persistence is separately opt-in during setup. Imports and noninteractive
+setup do not install a missing service based on an imported preference. See
+[optional service installation](#optional-service-installation).
+
## Architecture Overview
```text
diff --git a/website/docs/reference/cli-commands.md b/website/docs/reference/cli-commands.md
index 8aa43840ee2..d54656a3a43 100644
--- a/website/docs/reference/cli-commands.md
+++ b/website/docs/reference/cli-commands.md
@@ -202,29 +202,9 @@ same `exit_code`.
#### Delegation in finite chat runs
-When chat answers and exits (`-Q`, `chat --oneshot`, or a query with non-TTY
-stdio), `delegate_task` waits for its children and returns their results to the
-parent in the same turn. Batch children still run in parallel, subject to
-`delegation.max_concurrent_children`. The parent can use those results in its
-final response before the CLI exits.
-
-- **Automatic joining:** no opt-in or background-mode override is needed.
- Interactive TTY chat and messaging sessions keep background delegation.
-- **Per-input policy:** the CLI records finite consumption with the admitted prompt,
- including when resuming an interactive session. It does not change that session's
- creation policy, sibling viewers, or the daemon environment.
-- **Existing safeguards:** delegation limits, timeouts, cancellation, and
- `approvals.single_query_mode` (`-q` turns; `hermes -z` turns are unattended) still apply.
- Joining does not auto-approve commands or guarantee successful child outcomes.
- Inspect results and verify artifacts. Managed/safe workers still reject child
- delegation until their child-registration contract is available.
-- **Separate limits:** `--run-budget` remains unsupported by gateway chat; it is not
- required for joining. `terminal.oneshot_completion_wait_seconds` is not a
- delegation timeout. Canonical terminal notifications remain gateway-owned.
-
-Closing the CLI detaches rather than terminating its gateway-owned turn. Child
-execution is still process-local to that owner: use a durable scheduler for work
-that must survive an owner restart.
+When chat answers and exits, `delegate_task` waits for its children and returns their
+results in the same turn instead of running them in the background. Details and limits:
+[Delegation: finite chat runs](../user-guide/features/delegation.md#finite-chat-runs).
### `hermes -z <prompt>` — scripted one-shot
@@ -373,73 +353,14 @@ Use `hermes gateway run` instead of `hermes gateway start` — WSL's systemd sup
### Local runtime discovery and startup
-```bash
-hermes gateway ensure --json --timeout 60
-```
-
-`ensure` targets the active profile and emits one JSON object with `state`,
-`reason_code`, and `endpoint`. The endpoint is present only when authenticated
-local discovery reports compatible session readiness. Output contains no bootstrap
-tickets or bearer credentials. JSON is also the default without `--json`.
-
-The timeout is a finite, positive total deadline in seconds (default `60`, enough for a
-cold daemon boot on a loaded host). An
-existing reservation or starting owner is waited for, not replaced. When absence
-is established, an existing service takes precedence; an unmanaged process is
-requested only when no service is found. This command never installs or rewrites
-service definitions, enables linger, elevates privileges, or clears update fences.
-Ambiguous or inaccessible ownership fails closed.
-
-Before requesting a service start, `ensure` checks its canonical profile directory
-and execution account, not just its unit/task name. Linux uses the manager's
-loaded command and environment (including effective drop-ins), macOS checks the
-loaded launchd job rather than assuming the on-disk plist is current, and Windows
-queries the actual task XML, principal, and installed launcher.
-
-- `profile_mismatch`: the installed service selects a different home or profile.
- Inspect the selected service's `HERMES_HOME` and command-line profile selector;
- use the matching profile or explicitly repair the service configuration.
-- `service_account_mismatch`: the service belongs to another account. Run the
- client as that account, or explicitly configure a service for the intended user.
-- `service_identity_unverified`: the manager did not expose enough identity data,
- or the definition uses unsupported dynamic configuration. Inspect it with
- `systemctl [--user] show <unit> --all`, `launchctl print <domain>/<label>`, or
- `schtasks /Query /TN <task> /XML`. Linux environment files, PAM/dynamic users,
- start-time hooks and alternate root filesystems require operator review;
- arbitrary shell launchers and modified Windows launcher scripts are not
- interpreted by `ensure`. Restore an explicit supported definition through an
- intentional service-management operation before retrying.
-
-These refusals do not start a service, rewrite configuration, or launch an
-unmanaged replacement. Standard explicitly bound default and custom-root installs
-remain eligible; a successful start request still must pass live readiness checks.
-
-On POSIX, local bootstrap requires an owner-only profile directory. Newly reserved
-homes are created with mode `0700`; existing permissions are never changed by
-`ensure`. An existing home readable by other users returns
-`inaccessible / unsafe_control_permissions`. Review the directory's intended
-sharing policy and explicitly make it private before retrying local attachment.
-
-| Exit code | Meaning |
-|-----------|---------|
-| `0` | Compatible session runtime ready. |
-| `2` | Invalid invocation, including invalid timeout or unknown arguments. |
-| `3` | Incompatible runtime protocol or capabilities. |
-| `4` | Authorization or profile mismatch. |
-| `5` | Deadline reached; startup may still be pending. |
-| `6` | Runtime draining or update in progress. |
-| `7` | Inaccessible runtime, conflicting supervisor, or startup failure. |
-
-A service start command or process creation is not a readiness acknowledgement.
-A gateway that has not exposed the session-authority capability can remain
-`starting` until the deadline even while its messaging adapters work. Do not treat
-exit `5` as permission to replace that owner. On Windows, a Startup-folder-only
-installation requires login rather than an unmanaged fallback; failure to detach
-from a parent job is reported instead of retried with weaker process isolation.
-
-Service persistence is separately opt-in during setup. Imports and noninteractive
-setup do not install a missing service based on an imported preference. See
-[optional service installation](../developer-guide/gateway-internals.md#optional-service-installation).
+`hermes gateway ensure [--json] [--timeout 60]` discovers or starts the active profile's
+session runtime and prints one JSON object (`state`, `reason_code`, and an `endpoint` only
+once authenticated discovery reports compatible readiness; never tickets or credentials).
+It waits for an existing or starting owner instead of replacing it and never installs a
+service. Exit `0` means ready; any other code is a refusal or a deadline, never permission
+to start a replacement. Service identity checks, the home-permission policy behind
+`unsafe_control_permissions`, and every exit code:
+[Gateway internals: `hermes gateway ensure`](../developer-guide/gateway-internals.md#hermes-gateway-ensure).
## `hermes lsp`
diff --git a/website/docs/user-guide/features/delegation.md b/website/docs/user-guide/features/delegation.md
index b76aeab2740..56a8b4a841a 100644
--- a/website/docs/user-guide/features/delegation.md
+++ b/website/docs/user-guide/features/delegation.md
@@ -552,6 +552,32 @@ delegate_task(
**One-shot runs are capped separately.** `hermes chat -q` / `--oneshot` sessions may spawn at most `delegation.oneshot_max_children` subagents in total (default `2`, `0` = unlimited). A one-shot run has no later turn to receive results, and in benchmark trajectories most of its spawns were "independently review my own work" rather than parallel work — each such child re-pays a cold system prompt and re-reads the repo. Interactive and gateway sessions are unaffected.
+## Finite chat runs
+
+When chat answers and exits (`-Q`, `chat --oneshot`, or a query with non-TTY
+stdio), `delegate_task` waits for its children and returns their results to the
+parent in the same turn. Batch children still run in parallel, subject to
+`delegation.max_concurrent_children`. The parent can use those results in its
+final response before the CLI exits.
+
+- **Automatic joining:** no opt-in or background-mode override is needed.
+ Interactive TTY chat and messaging sessions keep background delegation.
+- **Per-input policy:** the CLI records finite consumption with the admitted prompt,
+ including when resuming an interactive session. It does not change that session's
+ creation policy, sibling viewers, or the daemon environment.
+- **Existing safeguards:** delegation limits, timeouts, cancellation, and
+ `approvals.single_query_mode` (`-q` turns; `hermes -z` turns are unattended) still apply.
+ Joining does not auto-approve commands or guarantee successful child outcomes.
+ Inspect results and verify artifacts. Managed/safe workers still reject child
+ delegation until their child-registration contract is available.
+- **Separate limits:** `--run-budget` remains unsupported by gateway chat; it is not
+ required for joining. `terminal.oneshot_completion_wait_seconds` is not a
+ delegation timeout. Canonical terminal notifications remain gateway-owned.
+
+Closing the CLI detaches rather than terminating its gateway-owned turn. Child
+execution is still process-local to that owner: use a durable scheduler for work
+that must survive an owner restart.
+
## Lifetime and Durability
:::warning Background completion durability is not durable execution