Skip to content

The agent that grows with you

feat(ci): new config keys and slash commands must ship with docs

Teknium4e8fe569e4ec
diff --git a/scripts/ci/check_docs_drift.py b/scripts/ci/check_docs_drift.py
new file mode 100644
index 00000000000..facad378018
--- /dev/null
+++ b/scripts/ci/check_docs_drift.py
@@ -0,0 +1,190 @@
+#!/usr/bin/env python3
+"""Docs drift ratchet: every DEFAULT_CONFIG key and slash command must be documented.
+
+A config key counts as documented when the docs mention its dotted path (``agent.max_turns``),
+a placeholder path covers it (``auxiliary.<task>.timeout``), or a YAML example in the docs nests
+it under the right parents. A slash command counts when ``/name`` appears in
+``website/docs/reference/slash-commands.md``.
+
+What was undocumented when the ratchet landed lives in ``docs_drift_baseline.json``. Only NEW
+gaps fail; documenting a baselined item or deleting it never breaks anything (``--update``
+prunes the baseline). Pure stdlib + repo imports, no network, deterministic.
+
+ python scripts/ci/check_docs_drift.py # exit 1 on new undocumented items
+ python scripts/ci/check_docs_drift.py --update # rewrite the baseline to current gaps
+"""
+from __future__ import annotations
+
+import argparse
+import json
+import re
+import sys
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[2]
+DOCS = ROOT / "website" / "docs"
+SLASH_PAGE = DOCS / "reference" / "slash-commands.md"
+BASELINE = Path(__file__).with_name("docs_drift_baseline.json")
+_FENCE = re.compile(r"```ya?ml[^\n]*\n(.*?)```", re.DOTALL)
+_DOTTED = re.compile(r"(?<![\w.])[A-Za-z_][\w-]*(?:\.[A-Za-z_][\w-]*)+")
+_PLACEHOLDER = re.compile(r"(?<![\w.])((?:[a-z_][\w-]*\.)+(?:<[\w-]+>|\*)(?:\.(?:[a-z_][\w-]*|\*))*)")
+# Globs only count inside inline code (`auxiliary.*.provider`): bare `*` in prose is emphasis.
+_CODE_SPAN = re.compile(r"`([^`\n]+)`")
+
+
+def _docs_text() -> str:
+ return "\n".join(p.read_text(encoding="utf-8-sig") for p in sorted(DOCS.rglob("*.md*")))
+
+
+def config_leaves() -> list[str]:
+ if str(ROOT) not in sys.path:
+ sys.path.insert(0, str(ROOT))
+ from hermes_cli.config_defaults import DEFAULT_CONFIG
+
+ out: list[str] = []
+
+ def walk(d: dict, pre: tuple[str, ...]) -> None:
+ for k, v in d.items():
+ p = (*pre, str(k))
+ if str(k).startswith("_"):
+ continue # internal bookkeeping (_config_version), never user-facing
+ if isinstance(v, dict) and v:
+ walk(v, p)
+ else:
+ out.append(".".join(p))
+
+ walk(DEFAULT_CONFIG, ())
+ return sorted(out)
+
+
+def slash_commands() -> list[str]:
+ if str(ROOT) not in sys.path:
+ sys.path.insert(0, str(ROOT))
+ from hermes_cli.commands import COMMAND_REGISTRY
+
+ return sorted(c.name for c in COMMAND_REGISTRY if not getattr(c, "hidden", False))
+
+
+def _yaml_paths(text: str) -> set[str]:
+ import warnings
+
+ from hermes_yaml import safe_load
+ from ruamel.yaml.error import YAMLError
+
+ warnings.simplefilter("ignore") # ruamel's YAML 1.1 float notes on doc snippets are noise here
+ paths: set[str] = set()
+
+ def flat(d: dict, pre: tuple[str, ...]) -> None:
+ for k, v in d.items():
+ p = (*pre, str(k))
+ paths.add(".".join(p))
+ if isinstance(v, dict):
+ flat(v, p)
+
+ for m in _FENCE.finditer(text):
+ try:
+ doc = safe_load(m.group(1))
+ except YAMLError: # a partial or templated snippet documents nothing reliably
+ continue
+ if isinstance(doc, dict):
+ flat(doc, ())
+ return paths
+
+
+def _placeholder_patterns(text: str) -> list[re.Pattern[str]]:
+ """``a.<task>.b`` / ``a.*.b`` cover one segment; a trailing ``.*`` covers every leaf below."""
+ pats = set()
+ spans = [m.group(1) for m in _CODE_SPAN.finditer(text)]
+ for m in (p for s in spans for p in _PLACEHOLDER.finditer(s)):
+ segs = m.group(1).split(".")
+ tail = r"(?:\..+)?" if segs[-1] == "*" else ""
+ if tail:
+ segs = segs[:-1]
+ parts = [r"[^.]+" if re.fullmatch(r"<[\w-]+>|\*", s) else re.escape(s) for s in segs]
+ # `agent.*` in prose names a section, it doesn't document every key under it: a
+ # trailing glob needs two segments ahead of it (`auxiliary.<task>.*`, `display.pet.*`).
+ if len(parts) >= 2:
+ pats.add(r"\.".join(parts) + tail)
+ return [re.compile(p + r"$") for p in sorted(pats)]
+
+
+def _dotted_mentions(text: str) -> set[str]:
+ """Every dotted path written in the docs, plus each of its parent prefixes
+ (``a.b.c`` documents ``a.b`` too). One pass instead of a regex scan per key."""
+ seen: set[str] = set()
+ for m in _DOTTED.finditer(text):
+ parts = m.group(0).rstrip(".").split(".")
+ for i in range(2, len(parts) + 1):
+ seen.add(".".join(parts[:i]))
+ return seen
+
+
+def find_gaps() -> dict[str, list[str]]:
+ text = _docs_text()
+ mentions = _dotted_mentions(text) | _yaml_paths(text)
+ words = set(re.findall(r"(?<![\w.])[A-Za-z_][\w-]*(?![\w.])", text)) # top-level single-word keys
+ placeholders = _placeholder_patterns(text)
+
+ def documented(dotted: str) -> bool:
+ if dotted in mentions or ("." not in dotted and dotted in words):
+ return True
+ return any(p.match(dotted) for p in placeholders)
+
+ slash = SLASH_PAGE.read_text(encoding="utf-8-sig")
+ return {
+ "config": [k for k in config_leaves() if not documented(k)],
+ "slash_commands": [c for c in slash_commands()
+ if not re.search(r"`/" + re.escape(c) + r"(?![\w-])", slash)],
+ }
+
+
+def _load_baseline() -> dict[str, list[str]]:
+ if not BASELINE.exists():
+ return {"config": [], "slash_commands": []}
+ return json.loads(BASELINE.read_text(encoding="utf-8-sig"))
+
+
+def compare(gaps: dict[str, list[str]], baseline: dict[str, list[str]]) -> tuple[dict, dict]:
+ new = {k: sorted(set(v) - set(baseline.get(k, []))) for k, v in gaps.items()}
+ stale = {k: sorted(set(baseline.get(k, [])) - set(v)) for k, v in gaps.items()}
+ return new, stale
+
+
+def failure_message(new: dict[str, list[str]]) -> str:
+ lines = ["Undocumented user-facing surface (docs drift ratchet):"]
+ if new["config"]:
+ lines.append(" config keys (mention the dotted path, or add a YAML example, in website/docs/ "
+ "-- usually user-guide/configuration.md):")
+ lines += [f" {k}" for k in new["config"]]
+ if new["slash_commands"]:
+ lines.append(" slash commands (add a row to website/docs/reference/slash-commands.md):")
+ lines += [f" /{c}" for c in new["slash_commands"]]
+ lines.append("Deliberately undocumented? `python scripts/ci/check_docs_drift.py --update` adds it to "
+ "the baseline; reviewers see that in the diff.")
+ return "\n".join(lines)
+
+
+def main(argv: list[str] | None = None) -> int:
+ ap = argparse.ArgumentParser(description="Docs drift ratchet for config keys and slash commands.")
+ ap.add_argument("--update", action="store_true", help="rewrite the baseline to the current gaps")
+ args = ap.parse_args(argv)
+ gaps = find_gaps()
+ if args.update:
+ BASELINE.write_text(json.dumps(gaps, indent=1, sort_keys=True) + "\n", encoding="utf-8")
+ print(f"baseline: {len(gaps['config'])} config keys, {len(gaps['slash_commands'])} slash commands")
+ return 0
+ new, stale = compare(gaps, _load_baseline())
+ for kind, items in stale.items():
+ if items:
+ print(f"note: {len(items)} baselined {kind} now documented or removed; "
+ "`--update` shrinks the baseline")
+ if any(new.values()):
+ print(failure_message(new))
+ return 1
+ print(f"docs drift: ok ({len(gaps['config'])} config keys, {len(gaps['slash_commands'])} "
+ "slash commands still baselined)")
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/scripts/ci/docs_drift_baseline.json b/scripts/ci/docs_drift_baseline.json
new file mode 100644
index 00000000000..866f5c8de26
--- /dev/null
+++ b/scripts/ci/docs_drift_baseline.json
@@ -0,0 +1,137 @@
+{
+ "config": [
+ "agent.build_wait_timeout",
+ "agent.coding_context",
+ "agent.empty_response_guard.cost_threshold_usd",
+ "agent.empty_response_guard.enabled",
+ "agent.environment_hint",
+ "agent.environment_probe",
+ "agent.gateway_notify_interval",
+ "agent.gateway_startup_restore_drain_timeout",
+ "agent.gateway_startup_warmup_timeout",
+ "agent.gateway_timeout_warning",
+ "agent.intent_ack_continuation",
+ "agent.parallel_tool_call_guidance",
+ "agent.reasoning_echo",
+ "agent.sanitizer_heal_escalation_threshold",
+ "agent.task_completion_guidance",
+ "attachments.storage",
+ "bot_mode.turn_wait_seconds",
+ "browser.allow_unsafe_evaluate",
+ "browser.extension_control.developer_mode",
+ "compression.abort_on_summary_failure",
+ "compression.max_attempts",
+ "computer_use.ax_max_elements",
+ "computer_use.capture_after_mode",
+ "computer_use.max_image_dimension",
+ "context.memory_trim.cooldown_seconds",
+ "context.memory_trim.enabled",
+ "context.memory_trim.info_log_min_delta_mb",
+ "context.memory_trim.log_every_n",
+ "cron.output_retention",
+ "cron.session_db_timeout_seconds",
+ "dashboard.compute_host_heartbeat_secs",
+ "dashboard.compute_host_respawn_max",
+ "database.journal_size_limit",
+ "database.wal_autocheckpoint",
+ "delegation.inherit_mcp_toolsets",
+ "delegation.max_summary_chars",
+ "delegation.subagent_auto_approve",
+ "desktop.auto_continue.enabled",
+ "desktop.auto_continue.freshness_minutes",
+ "desktop.auto_continue.max_attempts",
+ "desktop.disable_gpu",
+ "desktop.password_store",
+ "desktop.renderer_accessibility",
+ "discord.approval_mentions",
+ "discord.dm_role_auth_guild",
+ "discord.server_actions",
+ "display.battery",
+ "display.busy_steer_ack_enabled",
+ "display.cli_refresh_interval",
+ "display.copy_shortcut",
+ "display.ephemeral_system_ttl",
+ "display.final_response_markdown",
+ "display.friendly_tool_labels",
+ "display.inline_diffs",
+ "display.persist_prompts",
+ "display.persistent_output",
+ "display.persistent_output_max_lines",
+ "display.platforms.slack.streaming",
+ "display.reasoning_full",
+ "display.resume_exchanges",
+ "display.resume_max_assistant_chars",
+ "display.resume_max_assistant_lines",
+ "display.resume_max_user_chars",
+ "display.resume_skip_tool_only",
+ "display.tui_agents_nudge",
+ "display.tui_auto_resume_recent",
+ "display.tui_native",
+ "display.turn_completion_explainer",
+ "display.user_message_preview.first_lines",
+ "display.user_message_preview.last_lines",
+ "doctor.live_probe_timeout",
+ "gateway.restart_loop_guard.max_gap_seconds",
+ "gateway.restart_loop_guard.max_restarts",
+ "gateway.restart_loop_guard.window_seconds",
+ "gateway.scale_to_zero.idle_timeout_minutes",
+ "kanban.notify_in_gateway",
+ "kanban.worker_log_backup_count",
+ "kanban.worker_log_rotate_bytes",
+ "local_runtime.models_max",
+ "local_runtime.port",
+ "logging.backup_count",
+ "logging.level",
+ "logging.max_size_mb",
+ "mattermost.free_response_channels",
+ "mattermost.require_mention",
+ "max_live_sessions",
+ "mcp.auto_reload_on_config_change",
+ "mcp_discovery_timeout",
+ "mcp_single_query_discovery_timeout",
+ "moa.active_preset",
+ "moa.save_traces",
+ "moa.trace_dir",
+ "models_dev.url",
+ "monitoring.gateway_health_export.diagnostic_events_enabled",
+ "monitoring.gateway_health_export.export_interval_seconds",
+ "monitoring.gateway_health_export.logs_export_interval_seconds",
+ "monitoring.gateway_health_export.metrics_enabled",
+ "monitoring.gateway_health_export.resource_attributes.deployment.environment.name",
+ "monitoring.gateway_health_export.resource_attributes.service.name",
+ "monitoring.gateway_health_export.warning_error_events_enabled",
+ "monitoring.install_id",
+ "nous.guest",
+ "paste_collapse_char_threshold",
+ "paste_collapse_threshold",
+ "paste_collapse_threshold_fallback",
+ "security.acked_advisories",
+ "security.protected_instruction_extra_patterns",
+ "security.protected_instruction_files",
+ "sessions.auto_archive_days",
+ "sessions.fts_optimize_notice",
+ "sessions.show_subagents",
+ "stt.elevenlabs.diarize",
+ "stt.elevenlabs.language_code",
+ "stt.elevenlabs.model_id",
+ "stt.elevenlabs.tag_audio_events",
+ "telegram.extra.allow_cjk_rich_messages",
+ "telegram.extra.rich_drafts",
+ "telegram.extra.rich_messages",
+ "telemetry.shared_metrics.endpoint",
+ "terminal.daemon_term_grace_seconds",
+ "terminal.degraded_mode",
+ "terminal.docker_shm_size",
+ "terminal.modal_mode",
+ "tts.deepinfra.model",
+ "tts.deepinfra.voice",
+ "updates.refresh_cua_driver",
+ "vault.bitwarden.binary_path",
+ "vault.onepassword.binary_path",
+ "voice.gpt_live.model",
+ "voice.thinking_sound",
+ "wake_word.sherpa.model_dir",
+ "x_search.reasoning_effort"
+ ],
+ "slash_commands": []
+}
diff --git a/tests/ci/test_docs_drift.py b/tests/ci/test_docs_drift.py
new file mode 100644
index 00000000000..89edc6d47ee
--- /dev/null
+++ b/tests/ci/test_docs_drift.py
@@ -0,0 +1,51 @@
+"""Docs drift ratchet: every DEFAULT_CONFIG key and slash command is documented, or baselined.
+
+The checker lives in scripts/ci/check_docs_drift.py; this test is how CI runs it (the Python lane
+already carries the repo's dependencies). Only NEW gaps fail."""
+from __future__ import annotations
+
+import importlib.util
+import sys
+from pathlib import Path
+
+import pytest
+
+ROOT = Path(__file__).resolve().parents[2]
+SCRIPT = ROOT / "scripts" / "ci" / "check_docs_drift.py"
+
+
[email protected](scope="module")
+def drift():
+ spec = importlib.util.spec_from_file_location("check_docs_drift", SCRIPT)
+ assert spec is not None and spec.loader is not None
+ module = importlib.util.module_from_spec(spec)
+ sys.modules["check_docs_drift"] = module
+ spec.loader.exec_module(module)
+ return module
+
+
[email protected](scope="module")
+def gaps(drift):
+ return drift.find_gaps()
+
+
+def test_no_new_undocumented_config_keys_or_slash_commands(drift, gaps):
+ new, _ = drift.compare(gaps, drift._load_baseline())
+ assert not any(new.values()), drift.failure_message(new)
+ # Documenting a baselined key never fails a PR (that would punish the fix); the script
+ # prints a note and `--update` prunes the baseline whenever someone gets to it.
+
+
+def test_detects_each_documentation_form(drift, monkeypatch):
+ docs = (
+ "Set `agent.max_turns` to cap a run.\n"
+ "Every `auxiliary.<task>.timeout` is in seconds; `display.pet.*` tunes the pet.\n"
+ "```yaml\ncompression:\n threshold: 0.5\n```\n"
+ "This sentence has emphasis on *agent.* things.\n"
+ )
+ monkeypatch.setattr(drift, "_docs_text", lambda: docs)
+ monkeypatch.setattr(drift, "config_leaves", lambda: [
+ "agent.max_turns", "auxiliary.vision.timeout", "display.pet.size",
+ "compression.threshold", "agent.secret_knob", "auxiliary.vision.api_key"])
+ monkeypatch.setattr(drift, "slash_commands", list)
+ assert drift.find_gaps()["config"] == ["agent.secret_knob", "auxiliary.vision.api_key"]
diff --git a/website/docs/developer-guide/contributing.md b/website/docs/developer-guide/contributing.md
index 1704cbc1fe7..f0253fe0a0f 100644
--- a/website/docs/developer-guide/contributing.md
+++ b/website/docs/developer-guide/contributing.md
@@ -352,6 +352,7 @@ refactor/description # Code restructuring
3. **Check cross-platform impact**: Consider macOS, Linux, WSL2, and native Windows. If you touch file I/O, process management, terminal handling, subprocesses, or signals, run `scripts/check-windows-footguns.py`.
4. **Keep PRs focused**: One logical change per PR
5. **Prompt or tool-schema changes**: if `tests/ci/test_prompt_surface.py` fails, your change alters the system prompt or a tool schema that every session sends. Regenerate with `scripts/run-in-hermes-env python scripts/ci/prompt_surface.py render` and commit the snapshot. Changes there need a maintainer approval (see [Prompt Assembly](./prompt-assembly.md#reviewing-changes-to-the-prompt-surface)).
+6. **New config keys or slash commands**: if `tests/ci/test_docs_drift.py` fails, a `DEFAULT_CONFIG` key or slash command you added has no docs. Mention the dotted key (`agent.max_turns`) or show it in a YAML example under `website/docs/` (usually `user-guide/configuration.md`), and add slash commands to `reference/slash-commands.md`. If a key really should stay undocumented, `python scripts/ci/check_docs_drift.py --update` adds it to `scripts/ci/docs_drift_baseline.json` where reviewers see it. Keys that were undocumented when the check landed are already baselined; documenting one never fails.
### PR Description
diff --git a/website/docs/reference/slash-commands.md b/website/docs/reference/slash-commands.md
index 2095e7f5f89..aa14bc2e20a 100644
--- a/website/docs/reference/slash-commands.md
+++ b/website/docs/reference/slash-commands.md
@@ -247,6 +247,7 @@ The messaging gateway supports the following built-in commands inside Telegram,
| `/new [name]` (alias: `/reset`) | Start a new session (fresh session ID + history). Optional `[name]` sets the initial session title. Append `now`, `--yes`, or `-y` to skip the confirmation modal — e.g. `/reset now`, `/new --yes my-experiment`. |
| `/status` | Show session info, followed by a local **Session recap** block (recent turn counts, top tools used, files touched, latest prompt + reply). |
| `/stop` | Kill all running background processes and interrupt the running agent. |
+| `/pause [reason \| off]` | Global emergency stop, the in-chat form of [`hermes pause`](./cli-commands.md): puts new cron, kanban and gateway work on hold until `/pause off`. In-flight work finishes normally, and slash commands keep working while paused, so a messaging-only operator can always lift it. |
| `/model [provider:model]` | Show or change the model. Supports provider switches (`/model zai:glm-5`), custom endpoints (`/model custom:model`), named custom providers (`/model custom:local:qwen`), auto-detect (`/model custom`), OpenRouter account presets (`/model @preset/<slug>` — account-scoped, skips the public model-listing check), and user-defined aliases (`/model fav`, `/model grok` — see [Custom model aliases](#custom-model-aliases)). Use `--global` to persist the change to config.yaml; a successful `--global` pick (typed or picker) also drops this chat's session-only override, so config.yaml alone decides the model after a gateway restart (a chat with a `channel_overrides` model keeps the override, since the channel setting would otherwise outrank config.yaml; the CLI/TUI deliberately keep their per-session pin so resume restores the model that chat used). **Note:** `/model` can only switch between already-configured providers. To add a new provider or set up API keys, use `hermes model` from your terminal (outside the chat session). **Cost note:** a mid-session model switch resets the prompt cache (the cache key includes the model), so the next message re-reads the whole conversation at full input price. |
| `/codex-runtime [auto\|codex_app_server\|on\|off]` | Toggle the optional [Codex app-server runtime](../user-guide/features/codex-app-server-runtime). Persists to `model.openai_runtime` in config.yaml and evicts the cached agent so the next message picks up the new runtime. Effective on next session. |
| `/personality [name]` | Set a personality overlay for the session. `/personality none` (or `default` / `neutral`) clears it. |
@@ -316,7 +317,7 @@ The messaging gateway supports the following built-in commands inside Telegram,
- `/skills` is **CLI-only for search/browse/install**; its write-approval review subcommands (`pending`, `approve`, `reject`, `diff`, `approval`) also work on messaging platforms when `skills.write_approval` is on. `/memory` works on **both** surfaces.
- `/verbose` is **CLI-only by default**, but can be enabled for messaging platforms by setting `display.tool_progress_command: true` in `config.yaml`. When enabled, it cycles the `display.tool_progress` mode and saves to config.
- `/focus` and `/verbose` share one suppression path (`display.tool_progress`), so they can never contradict each other: `/focus on` pins tool progress to `off` and stashes your mode under `display.focus_saved_tool_progress`; `/focus off` restores it; cycling `/verbose` while focus is on takes the mode back and clears the focus badge. Focus view is display-only — it never changes conversation history, the system prompt, or anything sent to the model, so it has zero prompt-cache impact.
-- `/sethome`, `/restart`, `/approve`, `/deny`, `/topic`, `/platform`, and `/commands` are **messaging-only** commands.
+- `/sethome`, `/restart`, `/approve`, `/deny`, `/topic`, `/platform`, `/pause`, and `/commands` are **messaging-only** commands.
- `/status`, `/egress`, `/version`, `/whoami`, `/bg`, `/btw`, `/queue`, `/steer`, `/voice`, `/reload-mcp`, `/reload-skills`, `/rollback`, `/diff`, `/debug`, `/fast`, `/approvals`, `/busy`, `/footer`, `/curator`, `/kanban`, `/topup`, `/login`, `/suggestions`, `/blueprint`, `/learn`, `/init`, `/sessions`, `/loop`, and `/yolo` work in **both** the CLI and the messaging gateway.
- `/voice join`, `/voice channel`, and `/voice leave` are only meaningful on Discord.
- `/connectors` is **TUI-only**.