Skip to content

The agent that grows with you

refactor(hermes_cli): compact argparse builders (sessions/cron/gateway/skills) — one-line store_true flags via _flag; --help byte-identical

Teknium2b2684c8f922
diff --git a/hermes_cli/subcommands/cron.py b/hermes_cli/subcommands/cron.py
index 3e59ae2bf94..1808080aba0 100644
--- a/hermes_cli/subcommands/cron.py
+++ b/hermes_cli/subcommands/cron.py
@@ -7,6 +7,10 @@ from typing import Callable
from hermes_cli.subcommands._shared import add_accept_hooks_flag
+def _flag(parser, *names, help, **kw):
+ parser.add_argument(*names, action="store_true", help=help, **kw)
+
+
def build_cron_parser(subparsers, *, cmd_cron: Callable) -> None:
"""Attach the ``cron`` subcommand (and its sub-actions) to ``subparsers``."""
cron_parser = subparsers.add_parser(
@@ -14,7 +18,7 @@ def build_cron_parser(subparsers, *, cmd_cron: Callable) -> None:
cron_subparsers = cron_parser.add_subparsers(dest="cron_command")
cron_list = cron_subparsers.add_parser("list", help="List scheduled jobs")
- cron_list.add_argument("--all", action="store_true", help="Include disabled jobs")
+ _flag(cron_list, "--all", help="Include disabled jobs")
cron_create = cron_subparsers.add_parser(
"create", aliases=["add"], help="Create a scheduled job")
@@ -22,35 +26,29 @@ def build_cron_parser(subparsers, *, cmd_cron: Callable) -> None:
cron_create.add_argument(
"prompt", nargs="?", help="Optional self-contained prompt or task instruction")
cron_create.add_argument("--name", help="Optional human-friendly job name")
- cron_create.add_argument(
- "--deliver",
+ cron_create.add_argument("--deliver",
help="Delivery target: origin, local, telegram, discord, signal, "
"platform:chat_id, or bot-chat[:profile] (inject output into a "
"local profile's canonical Bot Chat as a message the bot responds to)")
- cron_create.add_argument(
- "--failure-deliver", dest="failure_deliver",
+ cron_create.add_argument("--failure-deliver", dest="failure_deliver",
help="Override target for FAILURE notices only (same grammar as "
"--deliver). 'local' suppresses failure notices entirely; run "
"state stays visible in `hermes cron list`. Omit = failures "
"follow --deliver.")
cron_create.add_argument("--repeat", type=int, help="Optional repeat count")
- cron_create.add_argument(
- "--skill", dest="skills", action="append",
+ cron_create.add_argument("--skill", dest="skills", action="append",
help="Attach a skill. Repeat to add multiple skills.")
- cron_create.add_argument(
- "--script",
+ cron_create.add_argument("--script",
help="Path to a script under ~/.hermes/scripts/. Default mode: "
"script stdout is injected into the agent's prompt each run. "
"With --no-agent: the script IS the job and its stdout is "
"delivered verbatim. .sh/.bash files run via bash, everything "
"else via Python.")
- cron_create.add_argument(
- "--no-agent", dest="no_agent", action="store_true", default=False,
+ _flag(cron_create, "--no-agent", dest="no_agent", default=False,
help="Skip the LLM entirely — run --script on schedule and deliver "
"its stdout directly. Empty stdout = silent. Classic watchdog "
"pattern (memory alerts, disk alerts, CI pings).")
- cron_create.add_argument(
- "--monitor-script", dest="monitor_script",
+ cron_create.add_argument("--monitor-script", dest="monitor_script",
help="Monitor mode: path to a cheap source script under "
"~/.hermes/scripts/ that runs each tick BEFORE the agent. "
"Unchanged output (exact-bytes hash) suppresses the agent run "
@@ -58,25 +56,20 @@ def build_cron_parser(subparsers, *, cmd_cron: Callable) -> None:
"diff into the prompt. Script output must be stable (no "
"timestamps). Mutually exclusive with --monitor-url; "
"incompatible with --no-agent.")
- cron_create.add_argument(
- "--monitor-url", dest="monitor_url",
+ cron_create.add_argument("--monitor-url", dest="monitor_url",
help="Monitor mode: http(s) URL fetched with a bounded GET each tick "
"instead of a script. Same hash-suppression semantics as "
"--monitor-script.")
- cron_create.add_argument(
- "--workdir",
+ cron_create.add_argument("--workdir",
help="Absolute path for the job to run from. Injects AGENTS.md / CLAUDE.md / .cursorrules from that directory and uses it as the cwd for terminal/file/code_exec tools. Omit to preserve old behaviour (no project context files).",
)
- cron_create.add_argument(
- "--model",
+ cron_create.add_argument("--model",
help="Pin this job to a specific inference model (user-owned; the "
"agent's cronjob tool cannot set this). Omit to follow "
"cron.model / model.default from config.yaml.")
- cron_create.add_argument(
- "--provider", dest="model_provider",
+ cron_create.add_argument("--provider", dest="model_provider",
help="Inference provider paired with --model (e.g. 'openrouter', 'nous').")
- cron_create.add_argument(
- "--reasoning-effort", dest="reasoning_effort",
+ cron_create.add_argument("--reasoning-effort", dest="reasoning_effort",
help="Pin this job's reasoning (thinking) effort: none, minimal, low, "
"medium, high, xhigh, max, or ultra. Overrides agent.reasoning_effort "
"and agent.reasoning_overrides for this job; unsupported levels are "
@@ -94,24 +87,18 @@ def build_cron_parser(subparsers, *, cmd_cron: Callable) -> None:
cron_edit.add_argument("--prompt", help="New prompt/task instruction")
cron_edit.add_argument("--name", help="New job name")
cron_edit.add_argument("--deliver", help="New delivery target")
- cron_edit.add_argument(
- "--failure-deliver", dest="failure_deliver",
+ cron_edit.add_argument("--failure-deliver", dest="failure_deliver",
help="Override target for failure notices (same grammar as --deliver; "
"'local' suppresses; '' clears the override)")
cron_edit.add_argument("--repeat", type=int, help="New repeat count")
- cron_edit.add_argument(
- "--skill", dest="skills", action="append",
+ cron_edit.add_argument("--skill", dest="skills", action="append",
help="Replace the job's skills with this set. Repeat to attach multiple skills.")
- cron_edit.add_argument(
- "--add-skill", dest="add_skills", action="append",
+ cron_edit.add_argument("--add-skill", dest="add_skills", action="append",
help="Append a skill without replacing the existing list. Repeatable.")
- cron_edit.add_argument(
- "--remove-skill", dest="remove_skills", action="append",
+ cron_edit.add_argument("--remove-skill", dest="remove_skills", action="append",
help="Remove a specific attached skill. Repeatable.")
- cron_edit.add_argument(
- "--clear-skills", action="store_true", help="Remove all attached skills from the job")
- cron_edit.add_argument(
- "--script",
+ _flag(cron_edit, "--clear-skills", help="Remove all attached skills from the job")
+ cron_edit.add_argument("--script",
help="Path to a script under ~/.hermes/scripts/. Pass empty string to clear. "
"With --no-agent the script IS the job; otherwise its stdout is "
"injected into the agent's prompt each run.")
@@ -119,37 +106,29 @@ def build_cron_parser(subparsers, *, cmd_cron: Callable) -> None:
"--no-agent", dest="no_agent", action="store_const", const=True, default=None,
help="Enable no-agent mode on this job (requires --script or an "
"existing script on the job).")
- cron_edit.add_argument(
- "--agent", dest="no_agent", action="store_const", const=False,
+ cron_edit.add_argument("--agent", dest="no_agent", action="store_const", const=False,
help="Disable no-agent mode on this job (reverts to LLM-driven execution).")
cron_edit.add_argument(
"--continuity", dest="continuity", action="store_const", const=True, default=None,
help="Turn on run-to-run continuity: each run sees the job's own "
"previous output (dedupe, continue where it left off).")
- cron_edit.add_argument(
- "--no-continuity", dest="continuity", action="store_const", const=False,
+ cron_edit.add_argument("--no-continuity", dest="continuity", action="store_const", const=False,
help=("Turn off run-to-run continuity (other context_from job refs are preserved)."))
- cron_edit.add_argument(
- "--monitor-script", dest="monitor_script",
+ cron_edit.add_argument("--monitor-script", dest="monitor_script",
help="Set/replace the monitor source script (see `hermes cron create "
"--monitor-script`). Pass empty string to clear.")
- cron_edit.add_argument(
- "--monitor-url", dest="monitor_url",
+ cron_edit.add_argument("--monitor-url", dest="monitor_url",
help=("Set/replace the monitor source URL. Pass empty string to clear."))
- cron_edit.add_argument(
- "--workdir",
+ cron_edit.add_argument("--workdir",
help="Absolute path for the job to run from (injects AGENTS.md etc. and sets terminal cwd). Pass empty string to clear.",
)
- cron_edit.add_argument(
- "--model",
+ cron_edit.add_argument("--model",
help="Pin this job to a specific inference model (user-owned; the "
"agent's cronjob tool cannot set this). Pass empty string to "
"clear the pin and follow cron.model / model.default.")
- cron_edit.add_argument(
- "--provider", dest="model_provider",
+ cron_edit.add_argument("--provider", dest="model_provider",
help="Inference provider paired with --model. Pass empty string to clear.")
- cron_edit.add_argument(
- "--reasoning-effort", dest="reasoning_effort",
+ cron_edit.add_argument("--reasoning-effort", dest="reasoning_effort",
help="Pin this job's reasoning (thinking) effort: none, minimal, low, "
"medium, high, xhigh, max, or ultra. Pass empty string to clear "
"the pin and follow config resolution.")
@@ -161,7 +140,7 @@ def build_cron_parser(subparsers, *, cmd_cron: Callable) -> None:
cron_resume = cron_subparsers.add_parser("resume", help="Resume a paused job")
cron_resume.add_argument("job_id", help="Job ID to resume")
cron_resume.add_argument("--at", dest="run_at", help="Re-arm at an ISO-8601 time")
- cron_resume.add_argument("--run-now", action="store_true", help="Re-arm to run now")
+ _flag(cron_resume, "--run-now", help="Re-arm to run now")
cron_run = cron_subparsers.add_parser("run", help="Run a job on the next scheduler tick")
cron_run.add_argument("job_id", help="Job ID to trigger")
@@ -181,8 +160,7 @@ def build_cron_parser(subparsers, *, cmd_cron: Callable) -> None:
# cron incidents — durable failure incidents (list/ack)
cron_incidents = cron_subparsers.add_parser(
"incidents", help="List or acknowledge durable cron failure incidents")
- cron_incidents.add_argument(
- "--state", choices=["detected", "alerted", "closed"],
+ cron_incidents.add_argument("--state", choices=["detected", "alerted", "closed"],
help="Filter incidents by lifecycle state")
cron_incidents.add_argument(
"incident_action", nargs="?", default="list", choices=["list", "ack"],
diff --git a/hermes_cli/subcommands/gateway.py b/hermes_cli/subcommands/gateway.py
index d812c569685..0eeb8dd0ccd 100644
--- a/hermes_cli/subcommands/gateway.py
+++ b/hermes_cli/subcommands/gateway.py
@@ -8,6 +8,10 @@ from typing import Callable
from hermes_cli.subcommands._shared import add_accept_hooks_flag
+def _flag(parser, *names, help, **kw):
+ parser.add_argument(*names, action="store_true", help=help, **kw)
+
+
def _add_compat_platform_flag(parser: argparse.ArgumentParser) -> None:
"""Accept stale `gateway <verb> --platform X` docs without advertising it.
@@ -18,37 +22,30 @@ def _add_compat_platform_flag(parser: argparse.ArgumentParser) -> None:
def _add_system_flag(parser: argparse.ArgumentParser) -> None:
- parser.add_argument(
- "--system", action="store_true", help="Target the Linux system-level gateway service")
+ _flag(parser, "--system", help="Target the Linux system-level gateway service")
def build_gateway_parser(
subparsers, *, cmd_gateway: Callable, cmd_proxy: Callable, cmd_gateway_enroll: Callable
) -> None:
"""Attach the ``gateway`` and ``proxy`` subcommands to ``subparsers``."""
- gateway_parser = subparsers.add_parser(
- "gateway", help="Messaging gateway management",
+ gateway_parser = subparsers.add_parser("gateway", help="Messaging gateway management",
description="Manage the messaging gateway (Telegram, Discord, WhatsApp, Weixin, and more)")
gateway_subparsers = gateway_parser.add_subparsers(dest="gateway_command")
gateway_run = gateway_subparsers.add_parser(
"run", help="Run gateway in foreground (recommended for WSL, Docker, Termux)")
- gateway_run.add_argument(
- "-v", "--verbose", action="count", default=0,
+ gateway_run.add_argument("-v", "--verbose", action="count", default=0,
help="Increase stderr log verbosity (-v=INFO, -vv=DEBUG)")
- gateway_run.add_argument(
- "-q", "--quiet", action="store_true", help="Suppress all stderr log output")
- gateway_run.add_argument(
- "--replace", action="store_true",
- help="Replace any existing gateway instance (useful for systemd)")
- gateway_run.add_argument(
- "--force", action="store_true",
+ _flag(gateway_run, "-q", "--quiet", help="Suppress all stderr log output")
+ _flag(
+ gateway_run, "--replace", help="Replace any existing gateway instance (useful for systemd)")
+ _flag(gateway_run, "--force",
help="Start a foreground gateway even when a systemd/launchd/s6 service "
"already supervises this profile. Without --force, the command "
"refuses because a second dispatcher escapes the service and can "
"corrupt shared gateway state.")
- gateway_run.add_argument(
- "--no-supervise", action="store_true",
+ _flag(gateway_run, "--no-supervise",
help="Inside the s6-overlay Docker image, normally `gateway run` is "
"automatically redirected to the supervised s6 service (so the "
"gateway gets auto-restart on crash, plus a supervised dashboard "
@@ -56,8 +53,7 @@ def build_gateway_parser(
"get the historical pre-s6 foreground behavior: the gateway is "
"the container's main process and the container exits with the "
"gateway's exit code. No effect outside an s6 container.")
- gateway_run.add_argument(
- "--external-supervisor", action="store_true",
+ _flag(gateway_run, "--external-supervisor",
help="Declare that an external process manager owns this foreground "
"gateway. In-chat restarts and updates exit back to that manager "
"instead of spawning a detached replacement. Use this when a "
@@ -68,54 +64,43 @@ def build_gateway_parser(
gateway_start = gateway_subparsers.add_parser(
"start", help="Start the installed systemd/launchd background service")
_add_system_flag(gateway_start)
- gateway_start.add_argument(
- "--all", action="store_true",
+ _flag(gateway_start, "--all",
help="Kill ALL stale gateway processes across all profiles before starting")
_add_compat_platform_flag(gateway_start)
gateway_stop = gateway_subparsers.add_parser("stop", help="Stop gateway service")
_add_system_flag(gateway_stop)
- gateway_stop.add_argument(
- "--all", action="store_true", help="Stop ALL gateway processes across all profiles")
+ _flag(gateway_stop, "--all", help="Stop ALL gateway processes across all profiles")
gateway_restart = gateway_subparsers.add_parser("restart", help="Restart gateway service")
_add_system_flag(gateway_restart)
- gateway_restart.add_argument(
- "--all", action="store_true",
+ _flag(gateway_restart, "--all",
help="Kill ALL gateway processes across all profiles before restarting")
_add_compat_platform_flag(gateway_restart)
gateway_status = gateway_subparsers.add_parser("status", help="Show gateway status")
- gateway_status.add_argument("--deep", action="store_true", help="Deep status check")
- gateway_status.add_argument(
- "-l", "--full", action="store_true",
+ _flag(gateway_status, "--deep", help="Deep status check")
+ _flag(gateway_status, "-l", "--full",
help="Show full, untruncated service/log output where supported")
_add_system_flag(gateway_status)
_add_compat_platform_flag(gateway_status)
gateway_install = gateway_subparsers.add_parser(
"install", help="Install gateway as a systemd/launchd background service")
- gateway_install.add_argument("--force", action="store_true", help="Force reinstall")
- gateway_install.add_argument(
- "--system", action="store_true",
+ _flag(gateway_install, "--force", help="Force reinstall")
+ _flag(gateway_install, "--system",
help="Install as a Linux system-level service (starts at boot)")
- gateway_install.add_argument(
- "--run-as-user", dest="run_as_user",
+ gateway_install.add_argument("--run-as-user", dest="run_as_user",
help="User account the Linux system service should run as")
- gateway_install.add_argument(
- "--start-now", dest="start_now", action="store_true", default=None,
+ _flag(gateway_install, "--start-now", dest="start_now", default=None,
help="Start the gateway service immediately after installing")
- gateway_install.add_argument(
- "--no-start-now", dest="start_now", action="store_false",
+ gateway_install.add_argument("--no-start-now", dest="start_now", action="store_false",
help="Do not start the gateway service after installing")
- gateway_install.add_argument(
- "--start-on-login", dest="start_on_login", action="store_true", default=None,
+ _flag(gateway_install, "--start-on-login", dest="start_on_login", default=None,
help="Enable the service to start automatically on login/boot")
- gateway_install.add_argument(
- "--no-start-on-login", dest="start_on_login", action="store_false",
+ gateway_install.add_argument("--no-start-on-login", dest="start_on_login", action="store_false",
help="Do not enable the service to start on login/boot")
- gateway_install.add_argument(
- "--elevated-handoff", dest="elevated_handoff", action="store_true", help=argparse.SUPPRESS)
+ _flag(gateway_install, "--elevated-handoff", dest="elevated_handoff", help=argparse.SUPPRESS)
gateway_uninstall = gateway_subparsers.add_parser("uninstall", help="Uninstall gateway service")
_add_system_flag(gateway_uninstall)
@@ -130,16 +115,13 @@ def build_gateway_parser(
"(e.g. hermes.service) left over from older installs. Profile "
"units (hermes-gateway-<profile>.service) and unrelated "
"third-party services are never touched.")
- gateway_migrate_legacy.add_argument(
- "--dry-run", dest="dry_run", action="store_true",
+ _flag(gateway_migrate_legacy, "--dry-run", dest="dry_run",
help="List what would be removed without doing it")
- gateway_migrate_legacy.add_argument(
- "-y", "--yes", dest="yes", action="store_true", help="Skip the confirmation prompt")
+ _flag(gateway_migrate_legacy, "-y", "--yes", dest="yes", help="Skip the confirmation prompt")
# enroll: redeem a single-use connector token for the per-gateway secret + per-tenant
# delivery key, written to .env. See docs/relay-connector-contract.md. EXPERIMENTAL.
- gateway_enroll = gateway_subparsers.add_parser(
- "enroll",
+ gateway_enroll = gateway_subparsers.add_parser("enroll",
help="Enroll this gateway with a relay connector (writes relay auth creds to .env)",
description="Redeem a single-use enrollment token with a relay connector. "
"Authenticates as your Nous Portal account (the connector derives the "
@@ -147,21 +129,17 @@ def build_gateway_parser(
"and per-tenant delivery key, and writes GATEWAY_RELAY_ID / "
"GATEWAY_RELAY_SECRET / GATEWAY_RELAY_DELIVERY_KEY into ~/.hermes/.env. "
"Requires being logged in (hermes setup). Not available in managed installs.")
- gateway_enroll.add_argument(
- "--token", default=None,
+ gateway_enroll.add_argument("--token", default=None,
help="The single-use enrollment token from the connector (delivered with "
"your gateway config). Also settable via GATEWAY_RELAY_ENROLL_TOKEN.")
- gateway_enroll.add_argument(
- "--connector-url", dest="connector_url", default=None,
+ gateway_enroll.add_argument("--connector-url", dest="connector_url", default=None,
help="The connector base/relay URL, e.g. wss://connector.example.com/relay "
"or https://connector.example.com. Also settable via GATEWAY_RELAY_URL "
"/ gateway.relay_url in config.yaml.")
- gateway_enroll.add_argument(
- "--gateway-id", dest="gateway_id", default=None,
+ gateway_enroll.add_argument("--gateway-id", dest="gateway_id", default=None,
help="A stable id for this gateway instance (kill-switch granularity). "
"Defaults to gw-<hostname>.")
- gateway_enroll.add_argument(
- "--wake-url", dest="wake_url", default=None,
+ gateway_enroll.add_argument("--wake-url", dest="wake_url", default=None,
help="Phase 5 §5.2 wake URL: a reachable URL the connector pokes "
"(payload-free GET) to wake this gateway when buffered work arrives "
"while it's idle/suspended, so it reconnects and drains. Persisted as "
@@ -181,11 +159,9 @@ def build_gateway_parser(
proxy_subparsers = proxy_parser.add_subparsers(dest="proxy_command")
proxy_start = proxy_subparsers.add_parser("start", help="Run the proxy in the foreground")
- proxy_start.add_argument(
- "--provider", default="nous",
+ proxy_start.add_argument("--provider", default="nous",
help="Upstream provider: nous or xai (default: nous). See `hermes proxy providers`.")
- proxy_start.add_argument(
- "--host", default=None,
+ proxy_start.add_argument("--host", default=None,
help="Bind address (default: 127.0.0.1). Use 0.0.0.0 to expose on LAN.")
proxy_start.add_argument("--port", type=int, default=None, help="Bind port (default: 8645)")
diff --git a/hermes_cli/subcommands/sessions.py b/hermes_cli/subcommands/sessions.py
index 21db89fd599..3a4c9b573ba 100644
--- a/hermes_cli/subcommands/sessions.py
+++ b/hermes_cli/subcommands/sessions.py
@@ -8,6 +8,10 @@ from typing import Callable
from hermes_cli.subcommands._shared import add_json_flag, add_yes_flag
+def _flag(parser, *names, help, **kw):
+ parser.add_argument(*names, action="store_true", help=help, **kw)
+
+
def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
"""Attach the ``sessions`` subcommand to ``subparsers``."""
sessions_parser = subparsers.add_parser(
@@ -18,8 +22,7 @@ def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
sessions_list = sessions_subparsers.add_parser("list", help="List recent sessions")
sessions_list.add_argument("--source", help="Filter by source (cli, telegram, discord, etc.)")
sessions_list.add_argument("--limit", type=int, default=20, help="Max sessions to show")
- sessions_list.add_argument(
- "--workspace", metavar="NEEDLE",
+ sessions_list.add_argument("--workspace", metavar="NEEDLE",
help="Only sessions in one workspace: a git repo root or project dir "
"(matched by path substring or basename).")
@@ -65,43 +68,34 @@ def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
sessions_export = sessions_subparsers.add_parser(
"export", help="Export sessions to JSONL, Markdown, or QMD")
- sessions_export.add_argument(
- "output", nargs="?",
+ sessions_export.add_argument("output", nargs="?",
help="Output path. JSONL: file path (use - for stdout, required). "
"md/qmd: output directory (default: <hermes home>/session-exports)")
sessions_export.add_argument(
"--format", choices=["jsonl", "md", "qmd", "html", "trace"], default="jsonl",
help="Export format (default: jsonl). 'trace' emits Claude Code JSONL "
"for the Hugging Face Agent Trace Viewer")
- sessions_export.add_argument(
- "--upload", action="store_true",
+ _flag(sessions_export, "--upload",
help="trace only: upload to your Hugging Face traces dataset instead "
"of writing a local file (needs HF_TOKEN)")
- sessions_export.add_argument(
- "--public", action="store_true",
+ _flag(sessions_export, "--public",
help="trace --upload only: create/update a public dataset instead of private")
- sessions_export.add_argument(
- "--no-redact", action="store_true",
+ _flag(sessions_export, "--no-redact",
help=("trace only: skip the forced secret redaction; only use after manual review"))
- sessions_export.add_argument(
- "--only", choices=["user-prompts"],
+ sessions_export.add_argument("--only", choices=["user-prompts"],
help="Export only a filtered view (user-prompts: one prompt record "
"per line for jsonl, headed sections for md)")
sessions_export.add_argument("--session-id", help="Session ID or unique prefix to export")
_add_session_filter_args(
sessions_export, "Only export sessions older than AGE (duration like '5h'/'2d', "
"bare number of days, or an ISO timestamp)")
- sessions_export.add_argument(
- "--redact", action="store_true",
+ _flag(sessions_export, "--redact",
help="Redact secrets (API keys, tokens, credentials) from exported content")
- sessions_export.add_argument(
- "--lineage", choices=["single", "logical"], default="single",
+ sessions_export.add_argument("--lineage", choices=["single", "logical"], default="single",
help="md/qmd only: export one row or its compression lineage")
- sessions_export.add_argument(
- "--delete-after-verified", action="store_true",
+ _flag(sessions_export, "--delete-after-verified",
help="md/qmd only: after verified single-session export, delete that session (needs --yes)")
- sessions_export.add_argument(
- "--force", action="store_true", help="md/qmd only: overwrite an existing export file")
+ _flag(sessions_export, "--force", help="md/qmd only: overwrite an existing export file")
sessions_delete = sessions_subparsers.add_parser("delete", help="Delete a specific session")
sessions_delete.add_argument("session_id", help="Session ID to delete")
@@ -113,14 +107,11 @@ def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
sessions_prune, "Delete sessions older than AGE — days if bare number, or a duration "
"like '5h'/'2d'/'1w', or an ISO timestamp (bare prune with no filters "
"defaults to 90 days; any filter matches all ages)")
- sessions_prune.add_argument(
- "--include-archived", action="store_true",
+ _flag(sessions_prune, "--include-archived",
help="Also delete archived sessions (excluded by default)")
- sessions_prune.add_argument(
- "--include-pinned", action="store_true",
+ _flag(sessions_prune, "--include-pinned",
help="Also delete pinned sessions (excluded by default — pin is a keep flag)")
- sessions_prune.add_argument(
- "--never-active", action="store_true",
+ _flag(sessions_prune, "--never-active",
help="Instead of ended sessions, delete keyed gateway rows that were "
"opened and never used (no messages, tokens, tool calls or title) "
"and are older than AGE (default 30 days). Ordinary prune can "
@@ -135,8 +126,7 @@ def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
sessions_subparsers.add_parser(
"optimize", help="Reclaim disk space: merge FTS5 segments + VACUUM (no data change)")
- sessions_clean_markers = sessions_subparsers.add_parser(
- "clean-markers",
+ sessions_clean_markers = sessions_subparsers.add_parser("clean-markers",
help="Permanently clear stale tool-call marker content left by sessions from before #78148",
description="Before the #78148 fix, a local tool-call template could persist a "
"bare bracketed marker (e.g. \"[memory]\") as an assistant turn's "
@@ -146,15 +136,12 @@ def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
"re-scanning/re-repairing the same rows on every resume. Only the "
"content column is touched; tool_calls and every other column on "
"the row are left untouched.")
- sessions_clean_markers.add_argument(
- "--dry-run", action="store_true", default=False,
+ _flag(sessions_clean_markers, "--dry-run", default=False,
help="Report the affected row count without writing")
- sessions_clean_markers.add_argument(
- "--no-backup", action="store_true", default=False,
+ _flag(sessions_clean_markers, "--no-backup", default=False,
help="Skip the timestamped state.db backup taken before writing (not recommended)")
- sessions_optimize_storage = sessions_subparsers.add_parser(
- "optimize-storage",
+ sessions_optimize_storage = sessions_subparsers.add_parser("optimize-storage",
help="Migrate the search index to the compact v23 layout (reclaims disk on large DBs)",
description="Rebuild the full-text search index in the compact v23 "
"external-content layout. On large databases this reclaims a "
@@ -164,12 +151,9 @@ def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
"stays responsive, and VACUUMs at the end. Safe to interrupt and "
"re-run — it resumes where it left off. No conversation data is "
"changed; only the search index is rebuilt.")
- sessions_optimize_storage.add_argument(
- "--no-vacuum", action="store_true", default=False,
- help="Skip the final VACUUM (index is rebuilt but freed pages aren't returned to the OS until a later VACUUM)",
- )
- sessions_optimize_storage.add_argument(
- "--yes", "-y", action="store_true", default=False,
+ _flag(sessions_optimize_storage, "--no-vacuum", default=False,
+ help="Skip the final VACUUM (index is rebuilt but freed pages aren't returned to the OS until a later VACUUM)")
+ _flag(sessions_optimize_storage, "--yes", "-y", default=False,
help="Skip the disk-space confirmation prompt")
sessions_repair = sessions_subparsers.add_parser(
@@ -178,12 +162,9 @@ def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
"messages_fts already exists'), which makes Desktop/Dashboard show "
"no sessions. A backup is made first; sessions and messages are "
"preserved and the FTS search index is rebuilt if needed.")
- sessions_repair.add_argument(
- "--check-only", action="store_true",
+ _flag(sessions_repair, "--check-only",
help="Only report whether the database opens cleanly; do not modify it")
- sessions_repair.add_argument(
- "--no-backup", action="store_true",
- help="Skip the timestamped backup copy (not recommended)")
+ _flag(sessions_repair, "--no-backup", help="Skip the timestamped backup copy (not recommended)")
sessions_repair_routing = sessions_subparsers.add_parser(
"repair-routing", help="Re-stamp gateway sessions that lost their routing identity",
@@ -195,10 +176,8 @@ def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
"orphan from the keyed predecessor it continues, and only when "
"that predecessor is unambiguous. Reports without touching the "
"database unless --apply is given.")
- sessions_repair_routing.add_argument(
- "--apply", action="store_true", help="Perform the adoptions (default: report only)")
- sessions_repair_routing.add_argument(
- "--max-gap-seconds", type=float, default=None,
+ _flag(sessions_repair_routing, "--apply", help="Perform the adoptions (default: report only)")
+ sessions_repair_routing.add_argument("--max-gap-seconds", type=float, default=None,
help="Window between a keyed predecessor's last activity and an "
"orphan's start for them to count as the same conversation "
"(default: 900)")
@@ -210,22 +189,17 @@ def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
"copied before SQLite opens anything. Canonical rows are rebuilt "
"into a new output database; derived search indexes are recreated "
"and the active database is never replaced automatically.")
- sessions_recover.add_argument(
- "--source", type=Path, required=True,
+ sessions_recover.add_argument("--source", type=Path, required=True,
help="Source state.db or preserved backup to inspect/recover")
sessions_recover.add_argument(
"--output", type=Path, help="New recovery database path (required unless --inspect-only)")
- sessions_recover.add_argument(
- "--inspect-only", action="store_true",
+ _flag(sessions_recover, "--inspect-only",
help="Only report canonical table readability; do not create an output database")
- sessions_recover.add_argument(
- "--work-dir", type=Path,
+ sessions_recover.add_argument("--work-dir", type=Path,
help="Existing directory for the disposable source copy (defaults beside the output)")
- sessions_recover.add_argument(
- "--chunk-size", type=int, default=1000,
+ sessions_recover.add_argument("--chunk-size", type=int, default=1000,
help="Rows committed per recovery batch (default: 1000)")
- sessions_recover.add_argument(
- "--allow-partial", action="store_true",
+ _flag(sessions_recover, "--allow-partial",
help="Best-effort salvage across damaged row ranges; the output remains "
"separate and every skipped range is recorded")
sessions_recover.add_argument(
@@ -262,8 +236,7 @@ def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
"describes the SKILL, not the request. This regenerates those "
"titles from what the user actually typed. Lists what it would "
"change unless --apply is passed.")
- sessions_retitle.add_argument(
- "--apply", action="store_true", help="Write the new titles (default: dry run)")
+ _flag(sessions_retitle, "--apply", help="Write the new titles (default: dry run)")
sessions_retitle.add_argument(
"--limit", type=int, default=200, help="Maximum sessions to examine (default: 200)")
@@ -279,8 +252,7 @@ def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
"or Codex CLI (~/.codex/sessions) into the Hermes session store "
"so it can be resumed with 'hermes --resume <id>'. The foreign "
"files are only read, never modified.")
- sessions_import.add_argument(
- "--from", dest="from_source", choices=["claude", "codex"],
+ sessions_import.add_argument("--from", dest="from_source", choices=["claude", "codex"],
help="Which tool to import from (default: pick across both)")
sessions_import.add_argument(
"path", nargs="?", help="Path to a specific session JSONL file (skips the picker)")
diff --git a/hermes_cli/subcommands/skills.py b/hermes_cli/subcommands/skills.py
index 4ca98f4aff4..7f32096938f 100644
--- a/hermes_cli/subcommands/skills.py
+++ b/hermes_cli/subcommands/skills.py
@@ -7,6 +7,10 @@ from typing import Callable
from hermes_cli.subcommands._shared import add_json_flag, add_yes_flag
+def _flag(parser, *names, help, **kw):
+ parser.add_argument(*names, action="store_true", help=help, **kw)
+
+
# Registry sources, then provider filters (GitHub taps stored under source="github").
_SOURCE_CHOICES = [
"all", "official", "skills-sh", "well-known", "github", "clawhub", "lobehub", "browse-sh",
@@ -21,17 +25,14 @@ def build_skills_parser(subparsers, *, cmd_skills: Callable) -> None:
)
skills_subparsers = skills_parser.add_subparsers(dest="skills_action")
- skills_trust = skills_subparsers.add_parser(
- "trust",
+ skills_trust = skills_subparsers.add_parser("trust",
help="Trust a project so its repo-local skills (./.hermes/skills, ./.agents/skills) load")
- skills_trust.add_argument(
- "path", nargs="?", default=None,
+ skills_trust.add_argument("path", nargs="?", default=None,
help="Project root to trust (default: enclosing git checkout of cwd)")
skills_untrust = skills_subparsers.add_parser(
"untrust", help="Revoke project-skill trust for a repo")
- skills_untrust.add_argument(
- "path", nargs="?", default=None,
+ skills_untrust.add_argument("path", nargs="?", default=None,
help="Project root to untrust (default: enclosing git checkout of cwd)")
skills_browse = skills_subparsers.add_parser(
@@ -39,31 +40,26 @@ def build_skills_parser(subparsers, *, cmd_skills: Callable) -> None:
skills_browse.add_argument("--page", type=int, default=1, help="Page number (default: 1)")
skills_browse.add_argument(
"--size", type=int, default=20, help="Results per page (default: 20)")
- skills_browse.add_argument(
- "--source", default="all", choices=_SOURCE_CHOICES,
+ skills_browse.add_argument("--source", default="all", choices=_SOURCE_CHOICES,
help="Filter by source or provider (e.g. nvidia, openai) (default: all)")
skills_search = skills_subparsers.add_parser("search", help="Search skill registries")
skills_search.add_argument("query", help="Search query")
- skills_search.add_argument(
- "--source", default="all", choices=_SOURCE_CHOICES,
+ skills_search.add_argument("--source", default="all", choices=_SOURCE_CHOICES,
help="Filter by source or provider (e.g. nvidia, openai)")
skills_search.add_argument("--limit", type=int, default=25, help="Max results")
add_json_flag(
skills_search, "Output JSON instead of a table (full identifiers, scripting-friendly)")
skills_install = skills_subparsers.add_parser("install", help="Install a skill")
- skills_install.add_argument(
- "identifier",
+ skills_install.add_argument("identifier",
help="Skill identifier (e.g. openai/skills/skill-creator) or a direct HTTP(S) URL to a SKILL.md file",
)
skills_install.add_argument("--category", default="", help="Category folder to install into")
- skills_install.add_argument(
- "--name", default="",
+ skills_install.add_argument("--name", default="",
help="Override the skill name (useful when installing from a URL whose SKILL.md has no `name:` frontmatter)",
)
- skills_install.add_argument(
- "--force", action="store_true", help="Install despite blocked scan verdict")
+ _flag(skills_install, "--force", help="Install despite blocked scan verdict")
add_yes_flag(skills_install, "Skip confirmation prompt (needed in TUI mode)")
skills_inspect = skills_subparsers.add_parser(
@@ -72,8 +68,7 @@ def build_skills_parser(subparsers, *, cmd_skills: Callable) -> None:
skills_list = skills_subparsers.add_parser("list", help="List installed skills")
skills_list.add_argument("--source", default="all", choices=["all", "hub", "builtin", "local"])
- skills_list.add_argument(
- "--enabled-only", action="store_true",
+ _flag(skills_list, "--enabled-only",
help="Hide disabled skills. Use with -p <profile> to see exactly "
"which skills will load for that profile.")
@@ -84,30 +79,25 @@ def build_skills_parser(subparsers, *, cmd_skills: Callable) -> None:
skills_update = skills_subparsers.add_parser("update", help="Update installed hub skills")
skills_update.add_argument(
"name", nargs="?", help="Specific skill to update (default: all outdated skills)")
- skills_update.add_argument(
- "--force", action="store_true",
+ _flag(skills_update, "--force",
help="Overwrite skills you have edited locally (they are skipped by default)")
skills_audit = skills_subparsers.add_parser("audit", help="Re-scan installed hub skills")
skills_audit.add_argument("name", nargs="?", help="Specific skill to audit (default: all)")
- skills_audit.add_argument(
- "--deep", action="store_true",
- help="Run AST-level analysis on Python files (opt-in diagnostic)")
+ _flag(skills_audit, "--deep", help="Run AST-level analysis on Python files (opt-in diagnostic)")
skills_uninstall = skills_subparsers.add_parser(
"uninstall", help="Remove a hub-installed skill")
skills_uninstall.add_argument("name", help="Skill name to remove")
add_yes_flag(skills_uninstall)
- skills_reset = skills_subparsers.add_parser(
- "reset",
+ skills_reset = skills_subparsers.add_parser("reset",
help="Reset a bundled skill — clears 'user-modified' tracking so updates work again",
description="Clear a bundled skill's entry from the sync manifest (~/.hermes/skills/.bundled_manifest) "
"so future 'hermes update' runs stop marking it as user-modified. Pass --restore to also "
"replace the current copy with the bundled version.")
skills_reset.add_argument("name", help="Skill name to reset (e.g. google-workspace)")
- skills_reset.add_argument(
- "--restore", action="store_true",
+ _flag(skills_reset, "--restore",
help="Also delete the current copy and re-copy the bundled version")
add_yes_flag(skills_reset, "Skip confirmation prompt when using --restore")
@@ -133,17 +123,14 @@ def build_skills_parser(subparsers, *, cmd_skills: Callable) -> None:
"into the active profile. By default nothing already on disk is "
"touched. Pass --remove to ALSO delete bundled skills that are "
"unmodified (user-edited and hub/local skills are never removed).")
- skills_opt_out.add_argument(
- "--remove", action="store_true",
- help="Also delete already-present unmodified bundled skills")
+ _flag(skills_opt_out, "--remove", help="Also delete already-present unmodified bundled skills")
add_yes_flag(skills_opt_out, "Skip confirmation prompt when using --remove")
skills_opt_in = skills_subparsers.add_parser(
"opt-in", help="Re-enable bundled-skill seeding (undo opt-out)",
description="Remove the .no-bundled-skills marker so bundled skills are seeded "
"again on the next `hermes update`. Pass --sync to re-seed now.")
- skills_opt_in.add_argument(
- "--sync", action="store_true",
+ _flag(skills_opt_in, "--sync",
help="Re-seed bundled skills immediately instead of waiting for update")
skills_repair_official = skills_subparsers.add_parser(
@@ -154,8 +141,7 @@ def build_skills_parser(subparsers, *, cmd_skills: Callable) -> None:
"a restore backup first. Use name 'all' to repair every optional skill.")
skills_repair_official.add_argument(
"name", help="Official optional skill folder/frontmatter name, or 'all'")
- skills_repair_official.add_argument(
- "--restore", action="store_true",
+ _flag(skills_repair_official, "--restore",
help="Restore from official optional source, backing up existing matching copies")
add_yes_flag(skills_repair_official, "Skip confirmation prompt when using --restore")
@@ -174,8 +160,7 @@ def build_skills_parser(subparsers, *, cmd_skills: Callable) -> None:
snap_import = snapshot_subparsers.add_parser(
"import", help="Import and install skills from a file")
snap_import.add_argument("input", help="Input JSON file path")
- snap_import.add_argument(
- "--force", action="store_true", help="Force install despite caution verdict")
+ _flag(snap_import, "--force", help="Force install despite caution verdict")
skills_tap = skills_subparsers.add_parser("tap", help="Manage skill sources")
tap_subparsers = skills_tap.add_subparsers(dest="tap_action")