Compare commits

..
Author SHA1 Message Date
Brooklyn Nicholson 237807ad3a Include git SHA in /version output via banner label helper.
Reuses format_banner_version_label() so CLI, TUI, gateway, and desktop show upstream/local commit when available.
2026-06-05 19:39:58 -05:00
Brooklyn Nicholson d95c76aa37 Add /version slash command across CLI, gateway, TUI, and desktop.
Surfaces Hermes Agent version info on demand without leaving chat; works mid-run like /help and /update.
2026-06-05 19:38:32 -05:00
16 changed files with 86 additions and 285 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
{
"id": "hermes-agent",
"name": "Hermes Agent",
"version": "0.16.0",
"version": "0.15.1",
"description": "Self-improving open-source AI agent by Nous Research with ACP editor integration, persistent memory, skills, and rich tool support.",
"repository": "https://github.com/NousResearch/hermes-agent",
"website": "https://hermes-agent.nousresearch.com/docs/user-guide/features/acp",
@@ -9,7 +9,7 @@
"license": "MIT",
"distribution": {
"uvx": {
"package": "hermes-agent[acp]==0.16.0",
"package": "hermes-agent[acp]==0.15.1",
"args": ["hermes-acp"]
}
}
@@ -15,6 +15,7 @@ describe('desktop slash command curation', () => {
expect(isDesktopSlashSuggestion('/branch')).toBe(true)
expect(isDesktopSlashSuggestion('/skin')).toBe(true)
expect(isDesktopSlashSuggestion('/usage')).toBe(true)
expect(isDesktopSlashSuggestion('/version')).toBe(true)
expect(isDesktopSlashSuggestion('/yolo')).toBe(true)
expect(isDesktopSlashCommand('/yolo')).toBe(true)
})
@@ -43,6 +43,7 @@ const DESKTOP_COMMAND_META = [
['/title', 'Rename the current session'],
['/undo', 'Remove the last user/assistant exchange'],
['/usage', 'Show token usage for this session'],
['/version', 'Show Hermes Agent version'],
['/yolo', 'Toggle YOLO — auto-approve dangerous commands']
] as const
+4
View File
@@ -9015,6 +9015,10 @@ class HermesCLI:
elif canonical == "update":
if self._handle_update_command():
return False
elif canonical == "version":
from hermes_cli.main import _print_version_info
_print_version_info(check_updates=True)
elif canonical == "paste":
self._handle_paste_command()
elif canonical == "image":
+11
View File
@@ -7932,6 +7932,8 @@ class GatewayRunner:
return await self._handle_profile_command(event)
if _cmd_def_inner.name == "update":
return await self._handle_update_command(event)
if _cmd_def_inner.name == "version":
return await self._handle_version_command(event)
# Catch-all: any other recognized slash command reached the
# running-agent guard. Reject gracefully rather than falling
@@ -8288,6 +8290,9 @@ class GatewayRunner:
if canonical == "update":
return await self._handle_update_command(event)
if canonical == "version":
return await self._handle_version_command(event)
if canonical == "debug":
return await self._handle_debug_command(event)
@@ -10913,6 +10918,12 @@ class GatewayRunner:
return event.platform_update_id <= recorded_uid
async def _handle_version_command(self, event: MessageEvent) -> str:
"""Handle /version — show the running Hermes Agent version."""
from hermes_cli.banner import format_banner_version_label
return format_banner_version_label()
async def _handle_help_command(self, event: MessageEvent) -> str:
"""Handle /help command - list available commands."""
from hermes_cli.commands import gateway_help_lines
+2 -2
View File
@@ -14,8 +14,8 @@ Provides subcommands for:
import os
import sys
__version__ = "0.16.0"
__release_date__ = "2026.6.5"
__version__ = "0.15.1"
__release_date__ = "2026.5.29"
def _ensure_utf8():
+2
View File
@@ -216,6 +216,7 @@ COMMAND_REGISTRY: list[CommandDef] = [
CommandDef("image", "Attach a local image file for your next prompt", "Info",
cli_only=True, args_hint="<path>"),
CommandDef("update", "Update Hermes Agent to the latest version", "Info"),
CommandDef("version", "Show Hermes Agent version", "Info", aliases=("v",)),
CommandDef("debug", "Upload debug report (system info + logs) and get shareable links", "Info"),
# Exit
@@ -349,6 +350,7 @@ ACTIVE_SESSION_BYPASS_COMMANDS: frozenset[str] = frozenset(
"steer",
"stop",
"update",
"version",
}
)
+3 -1
View File
@@ -6647,7 +6647,9 @@ def cmd_import(args):
def _print_version_info(*, check_updates: bool = True) -> None:
print(f"Hermes Agent v{__version__} ({__release_date__})")
from hermes_cli.banner import format_banner_version_label
print(format_banner_version_label())
print(f"Project: {PROJECT_ROOT}")
# Show Python version
+1 -1
View File
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "hermes-agent"
version = "0.16.0"
version = "0.15.1"
description = "The self-improving AI agent — creates skills from experience, improves them during use, and runs anywhere"
readme = "README.md"
# Upper bound is load-bearing, not cosmetic. uv resolves the project's
-2
View File
@@ -40,8 +40,6 @@ IGNORED_PATTERNS = [
re.compile(r"^Claude", re.IGNORECASE),
re.compile(r"^Copilot$", re.IGNORECASE),
re.compile(r"^Cursor(\s+Agent)?$", re.IGNORECASE),
re.compile(r"^Codex$", re.IGNORECASE),
re.compile(r"^github-advanced-security(\[bot\])?$", re.IGNORECASE),
re.compile(r"^GitHub\s*Actions?$", re.IGNORECASE),
re.compile(r"^github-actions(\[bot\])?$", re.IGNORECASE),
re.compile(r"^dependabot", re.IGNORECASE),
-10
View File
@@ -1167,16 +1167,6 @@ AUTHOR_MAP = {
"chenzeshi@live.com": "chen1749144759",
"mor.aleksandr@yahoo.com": "MorAlekss",
"276649498+ztexydt-cqh@users.noreply.github.com": "ztexydt-cqh",
# v0.16.0 additions
"teknium@nous.dev": "teknium1",
"alaamohanad169@gmail.com": "alaamohanad169-ship-it",
"archer@ouyangdeMac-mini.local": "Archerouyang", # display name 欧阳
"batosk2@gmail.com": "Sarbai", # git email for PR #33438 author (display: Брагарник Дмитро)
"info@aminvakil.com": "aminvakil",
"nikpolale@gmail.com": "polnikale",
"sarveshagl1327@gmail.com": "sarvesh1327", # salvaged via #38655
"sohyuanchin@gmail.com": "wysie",
"bedirhan@codeway.co": "bedirhancode",
"ash@users.noreply.github.com": "ash",
"andrewho.sf@gmail.com": "andrewhosf",
# April 2026 Honcho bug-fix consolidation (#15381)
+28
View File
@@ -0,0 +1,28 @@
"""Tests for the /version slash command."""
from unittest.mock import patch
from cli import HermesCLI
from hermes_cli.commands import GATEWAY_KNOWN_COMMANDS, resolve_command
def test_version_command_is_registered():
cmd = resolve_command("version")
assert cmd is not None
assert cmd.name == "version"
assert cmd.category == "Info"
assert resolve_command("v") is cmd
def test_version_is_gateway_known():
assert "version" in GATEWAY_KNOWN_COMMANDS
assert "v" in GATEWAY_KNOWN_COMMANDS
def test_process_command_version_prints_version_info():
cli_obj = HermesCLI.__new__(HermesCLI)
with patch("hermes_cli.main._print_version_info") as mock_print:
assert cli_obj.process_command("/version") is True
mock_print.assert_called_once_with(check_updates=True)
+12
View File
@@ -0,0 +1,12 @@
"""Tests for gateway /version command."""
import asyncio
from hermes_cli.banner import format_banner_version_label
def test_gateway_version_command_returns_release_line():
from gateway.run import GatewayRunner
result = asyncio.run(GatewayRunner._handle_version_command(None, None)) # type: ignore[arg-type]
assert result == format_banner_version_label()
-160
View File
@@ -1,160 +0,0 @@
"""Regression tests for the rg/grep error guard in content search.
The guard in ``_search_with_rg`` / ``_search_with_grep`` had two defects on
``origin/main`` (see PR replacing #39710):
1. **Unreachable on a hard error.** Both methods pipe the search through
``| head`` with no ``pipefail``, so the pipeline reported head's exit code
(0), masking rg/grep's error code (2). The guard never fired, and the
error text — merged into stdout by ``_exec`` (``stderr=subprocess.STDOUT``)
— was parsed as bogus match lines instead of being surfaced.
2. **Would have nuked partial results if it ever did fire.** A broad
``exit_code == 2`` check discards real matches whenever rg/grep also hit a
non-fatal error (e.g. one unreadable file in a tree that otherwise
matched), which both tools signal with exit 2.
The fix adds ``set -o pipefail`` so the real exit code propagates, splits
tool diagnostics from match output by *shape*, and only surfaces an error
when exit==2 AND no usable match payload remains.
These tests drive the real methods through the real local terminal backend.
"""
import os
import shutil
import pytest
from tools.file_operations import (
ShellFileOperations,
_split_tool_diagnostics,
)
from tools.environments.local import LocalEnvironment
def _ops(root):
return ShellFileOperations(LocalEnvironment(cwd=str(root)), cwd=str(root))
@pytest.fixture
def match_tree(tmp_path):
"""A tree with several files all containing 'needle'."""
for i in range(5):
(tmp_path / f"f{i}.txt").write_text(f"needle line {i}\n")
return tmp_path
@pytest.fixture
def partial_error_tree(tmp_path):
"""A tree with matches plus one unreadable file (forces exit 2 + matches)."""
for i in range(4):
(tmp_path / f"f{i}.txt").write_text(f"needle line {i}\n")
sub = tmp_path / "sub"
sub.mkdir()
locked = sub / "locked.txt"
locked.write_text("needle in locked\n")
os.chmod(locked, 0o000)
yield tmp_path
os.chmod(locked, 0o755) # let pytest clean up tmp_path
# Run every test once per available backend method.
_METHODS = ["_search_with_grep"]
if shutil.which("rg"):
_METHODS.append("_search_with_rg")
def _search(ops, method, pattern, path, **kw):
fn = getattr(ops, method)
return fn(pattern, str(path), kw.get("file_glob"), kw.get("limit", 50),
kw.get("offset", 0), kw.get("output_mode", "content"),
kw.get("context", 0))
@pytest.mark.parametrize("method", _METHODS)
class TestSearchErrorGuard:
def test_happy_path_returns_matches(self, method, match_tree):
res = _search(_ops(match_tree), method, "needle", match_tree)
assert res.error is None
assert len(res.matches) == 5
def test_hard_error_is_surfaced(self, method, match_tree):
# An invalid regex makes rg/grep exit 2 with only diagnostics in
# stdout. The guard MUST surface it — not return empty matches.
res = _search(_ops(match_tree), method, "[", match_tree)
assert res.error is not None, "search error was silently swallowed"
assert "Search failed" in res.error
assert not res.matches
def test_partial_error_keeps_matches(self, method, partial_error_tree):
# rg/grep exit 2 because of the unreadable file, but the readable
# files matched. Those matches must be preserved, not discarded.
res = _search(_ops(partial_error_tree), method, "needle", partial_error_tree)
assert res.error is None, f"partial error wrongly surfaced: {res.error!r}"
assert len(res.matches) >= 4
def test_no_match_is_empty_not_error(self, method, match_tree):
res = _search(_ops(match_tree), method, "zzznomatchzzz", match_tree)
assert res.error is None
assert not res.matches
def test_truncation_no_false_error(self, method, tmp_path):
# head truncates a large result set. With pipefail, grep exits 141
# (SIGPIPE) on truncation; the strict `== 2` guard must ignore it.
big = tmp_path / "big.txt"
big.write_text("".join(f"needle {i}\n" for i in range(3000)))
res = _search(_ops(tmp_path), method, "needle", tmp_path, limit=5)
assert res.error is None, f"truncated success wrongly errored: {res.error!r}"
assert len(res.matches) == 5
def test_files_only_excludes_diagnostics(self, method, partial_error_tree):
# files_only mode must not list a diagnostic line as a fake file path.
res = _search(_ops(partial_error_tree), method, "needle",
partial_error_tree, output_mode="files_only")
assert res.error is None
assert res.files, "expected matching files"
assert all("Permission denied" not in f and "locked.txt" not in f
for f in res.files), f"diagnostic leaked into files: {res.files}"
def test_count_mode_with_partial_error(self, method, partial_error_tree):
res = _search(_ops(partial_error_tree), method, "needle",
partial_error_tree, output_mode="count")
assert res.error is None
assert res.total_count >= 4
class TestSplitToolDiagnostics:
"""Unit coverage for the shape-based diagnostic/payload splitter."""
def test_pure_error_has_empty_payload(self):
out = "rg: regex parse error:\n (?:[)\n ^\nerror: unclosed character class\n"
diagnostics, payload = _split_tool_diagnostics(out)
assert payload.strip() == ""
assert "regex parse error" in diagnostics
def test_partial_error_separates_matches(self):
out = ("rg: sub/locked.txt: Permission denied (os error 13)\n"
"a.txt:1:needle here\nb.txt:2:needle there\n")
diagnostics, payload = _split_tool_diagnostics(out)
assert "Permission denied" in diagnostics
assert "a.txt:1:needle here" in payload
assert "b.txt:2:needle there" in payload
assert "Permission denied" not in payload
def test_files_only_is_payload(self):
diagnostics, payload = _split_tool_diagnostics("src/a.py\nsrc/b.py\n")
assert diagnostics == ""
assert payload == "src/a.py\nsrc/b.py"
def test_count_lines_are_payload(self):
diagnostics, payload = _split_tool_diagnostics("src/a.py:3\nsrc/b.py:1\n")
assert diagnostics == ""
assert "src/a.py:3" in payload
def test_context_lines_and_separator_are_payload(self):
out = "a.py:5:hit\na.py-6-after\n--\nb.py:9:hit\n"
diagnostics, payload = _split_tool_diagnostics(out)
assert diagnostics == ""
assert "--" in payload
assert "a.py-6-after" in payload
+18 -106
View File
@@ -285,63 +285,6 @@ class ExecuteResult:
exit_code: int = 0
def _split_tool_diagnostics(output: str) -> tuple[str, str]:
"""Separate rg/grep diagnostic lines from real match output.
``_exec`` runs commands with ``stderr=subprocess.STDOUT``, so error and
warning text from ``rg``/``grep`` is interleaved with match lines in a
single stream. Diagnostics must not be parsed as matches, and on a hard
failure they are the error message to surface.
Returns ``(diagnostics, payload)`` where ``payload`` contains only lines
that look like real search output — a match line (``file:line:content``),
a files-only path, a count line, or a context line/separator. Everything
else (tool-prefixed errors, rg's multi-line ``regex parse error`` block
with its indented carets, blank lines) is folded into ``diagnostics``.
Classifying by *shape* rather than by error prefix is what lets the
exit-2 guard distinguish a pure failure (no usable payload → surface the
error) from a partial failure (some files matched, one was unreadable →
keep the matches). It also means error text can never be mis-parsed as a
match, a latent bug that predates the exit-code fix.
"""
diagnostics: list[str] = []
payload: list[str] = []
for line in output.split('\n'):
if not line.strip():
continue
# Tool diagnostics always carry the "<tool>: " prefix (e.g.
# "rg: <file>: Permission denied", "grep: Invalid regular
# expression", "rg: regex parse error:"). Check this first: a real
# match path can legitimately contain "-<digit>" (e.g. a tmp dir like
# ".../pytest-686/..."), which the shape regex would otherwise treat
# as a match line.
stripped = line.lstrip()
if stripped.startswith("rg: ") or stripped.startswith("grep: "):
diagnostics.append(line)
continue
# Otherwise classify by output shape. rg's regex-parse-error block
# also emits an indented caret line and a trailing "error: ..." line
# with no tool prefix; neither matches a search-output shape, so they
# fall through to diagnostics.
# match / count : "<path>:<...>" (has a colon; rg -c uses path:count)
# files_only : "<path>" (no whitespace, no leading colon)
# context line : "<path>-<line>-" or the "--" group separator
if line == "--" or _SEARCH_OUTPUT_RE.match(line):
payload.append(line)
else:
diagnostics.append(line)
return '\n'.join(diagnostics), '\n'.join(payload)
# A real rg/grep output line starts with a path token and is followed by a
# ``:`` (match/count), a ``-`` (context), or nothing (files_only). Tool
# diagnostics ("rg: ...", "grep: ...", "error: ...", indented carets) never
# match because the path token forbids whitespace and a leading tool prefix
# like "rg" is followed by ": " (space) which the negated class rejects.
_SEARCH_OUTPUT_RE = re.compile(r'^([A-Za-z]:)?[^\s:][^\n]*?[:\-]\d|^[^\s:][^\s]*$')
def _parse_search_context_line(line: str) -> tuple[str, int, str] | None:
"""Parse grep/rg context output in ``path-line-content`` format.
@@ -2095,40 +2038,24 @@ class ShellFileOperations(FileOperations):
fetch_limit = limit + offset + 200 if context > 0 else limit + offset
cmd_parts.extend(["|", "head", "-n", str(fetch_limit)])
# `set -o pipefail` so rg's exit status propagates through `| head`.
# Without it the pipeline reports head's status (0), masking rg's
# error code (2) and making the guard below unreachable. rg handles a
# truncating head cleanly (exit 0 on SIGPIPE), so pipefail does not
# introduce false errors on a successful-but-truncated search.
cmd = "set -o pipefail; " + " ".join(cmd_parts)
cmd = " ".join(cmd_parts)
result = self._exec(cmd, timeout=60)
# _exec merges stderr into stdout (stderr=subprocess.STDOUT), so rg's
# diagnostic lines ("rg: <file>: <error>", "rg: regex parse error:")
# are interleaved with match output. Split them out: diagnostics must
# not be parsed as matches, and on a hard error they ARE the message.
diagnostics, payload = _split_tool_diagnostics(result.stdout)
# rg exit codes: 0=matches found, 1=no matches, 2=error. rg returns 2
# even on partial errors (e.g. one unreadable file in a tree that
# otherwise matched), so only surface an error when exit==2 AND no
# usable match payload remains. Otherwise we keep the real matches.
if result.exit_code == 2 and not payload.strip():
error_msg = diagnostics.strip() or result.stdout.strip() or "Search error"
# rg exit codes: 0=matches found, 1=no matches, 2=error
if result.exit_code == 2 and not result.stdout.strip():
error_msg = result.stderr.strip() if hasattr(result, 'stderr') and result.stderr else "Search error"
return SearchResult(error=f"Search failed: {error_msg}", total_count=0)
# Parse the diagnostic-free payload so error text never becomes a match.
stdout = payload
# Parse results based on output mode
if output_mode == "files_only":
all_files = [f for f in stdout.strip().split('\n') if f]
all_files = [f for f in result.stdout.strip().split('\n') if f]
total = len(all_files)
page = all_files[offset:offset + limit]
return SearchResult(files=page, total_count=total)
elif output_mode == "count":
counts = {}
for line in stdout.strip().split('\n'):
for line in result.stdout.strip().split('\n'):
if ':' in line:
parts = line.rsplit(':', 1)
if len(parts) == 2:
@@ -2147,7 +2074,7 @@ class ShellFileOperations(FileOperations):
# so naive split(":") breaks. Use regex to handle both platforms.
_match_re = re.compile(r'^([A-Za-z]:)?(.*?):(\d+):(.*)$')
matches = []
for line in stdout.strip().split('\n'):
for line in result.stdout.strip().split('\n'):
if not line or line == "--":
continue
@@ -2211,38 +2138,23 @@ class ShellFileOperations(FileOperations):
fetch_limit = limit + offset + (200 if context > 0 else 0)
cmd_parts.extend(["|", "head", "-n", str(fetch_limit)])
# `set -o pipefail` so grep's exit status propagates through `| head`
# (without it the pipeline reports head's 0, masking grep's error 2).
# A truncating head makes grep exit 141 (SIGPIPE) on an otherwise
# successful search; the strict `== 2` guard below ignores that, so
# pipefail does not turn truncated results into false errors.
cmd = "set -o pipefail; " + " ".join(cmd_parts)
cmd = " ".join(cmd_parts)
result = self._exec(cmd, timeout=60)
# _exec merges stderr into stdout, so grep's diagnostic lines
# ("grep: <file>: <error>") are interleaved with matches. Split them
# out so they're never parsed as matches and so a hard error has a
# clean message.
diagnostics, payload = _split_tool_diagnostics(result.stdout)
# grep exit codes: 0=matches found, 1=no matches, 2=error. grep
# returns 2 on partial errors (e.g. an unreadable file) even when
# other files matched, so only surface an error when exit==2 AND no
# usable match payload remains.
if result.exit_code == 2 and not payload.strip():
error_msg = diagnostics.strip() or result.stdout.strip() or "Search error"
# grep exit codes: 0=matches found, 1=no matches, 2=error
if result.exit_code == 2 and not result.stdout.strip():
error_msg = result.stderr.strip() if hasattr(result, 'stderr') and result.stderr else "Search error"
return SearchResult(error=f"Search failed: {error_msg}", total_count=0)
stdout = payload
if output_mode == "files_only":
all_files = [f for f in stdout.strip().split('\n') if f]
all_files = [f for f in result.stdout.strip().split('\n') if f]
total = len(all_files)
page = all_files[offset:offset + limit]
return SearchResult(files=page, total_count=total)
elif output_mode == "count":
counts = {}
for line in stdout.strip().split('\n'):
for line in result.stdout.strip().split('\n'):
if ':' in line:
parts = line.rsplit(':', 1)
if len(parts) == 2:
@@ -2260,7 +2172,7 @@ class ShellFileOperations(FileOperations):
# so naive split(":") breaks. Use regex to handle both platforms.
_match_re = re.compile(r'^([A-Za-z]:)?(.*?):(\d+):(.*)$')
matches = []
for line in stdout.strip().split('\n'):
for line in result.stdout.strip().split('\n'):
if not line or line == "--":
continue
Generated
+1 -1
View File
@@ -1390,7 +1390,7 @@ wheels = [
[[package]]
name = "hermes-agent"
version = "0.16.0"
version = "0.15.1"
source = { editable = "." }
dependencies = [
{ name = "croniter" },