chore: remove dead code — 28 unused functions/classes across 16 files
Vulture + per-symbol verification (whole-repo grep incl. tests, string literals, getattr, decorator/registry/argparse dispatch) confirmed each of these has zero callers anywhere — not reachable via any dynamic-dispatch path, not referenced by tests, not re-exported. Removed: - acp_adapter/tools.py: _build_patch_mode_content - agent/anthropic_adapter.py: read_claude_managed_key (diagnostics-only, never called) - agent/bedrock_adapter.py: get_bedrock_model_ids - agent/browser_registry.py: get_active_browser_provider - agent/chat_completion_helpers.py: _take_request_client (x2 nested closures, never invoked) - gateway/platforms/weixin.py: _rewrite_headers_for_weixin, _rewrite_table_block_for_weixin - hermes_cli/banner.py: _skin_branding - hermes_cli/debug.py: _delete_hint - hermes_cli/gateway.py: _setup_email, _setup_sms, _setup_yuanbao (platform keys absent from the _builtin_setup_fn dispatch dict; handled by the _setup_standard_platform fallback) - hermes_cli/kanban_db.py: set_max_runtime, active_run - hermes_cli/kanban_diagnostics.py: severity_of_highest, _latest_clean_event_ts - hermes_cli/main.py: _build_provider_choices, cmd_portal (portal subcommand is wired via portal_cli.add_parser, not this wrapper) - hermes_cli/model_switch.py: CustomAutoResult (orphaned by the switch_model() extraction) - hermes_cli/models.py: format_model_pricing_table, fetch_nous_account_tier - hermes_cli/portal_cli.py: _nous_portal_base_url - hermes_cli/proxy/server.py: handle_models_fallback (defined but never registered on the router) - tools/computer_use/cua_backend.py: _parse_element, _is_arm_mac - tools/file_operations.py: _get_safe_write_root (prod uses the imported agent.file_safety.get_safe_write_root directly) - tools/skills_tool.py: _load_category_description Also dropped two imports left unused by the removals: - tools/file_operations.py: get_safe_write_root alias - tools/computer_use/cua_backend.py: import platform Pure deletion: -551 LOC. No behavior change. Test files covering the edited modules pass (640/640); the broader suite's pre-existing/env-dependent failures reproduce unchanged on origin/main.
This commit is contained in:
@@ -22,7 +22,6 @@ import base64
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
@@ -77,12 +76,6 @@ _ELEMENT_LINE_RE = re.compile(
|
||||
|
||||
def _is_macos() -> bool:
|
||||
return sys.platform == "darwin"
|
||||
|
||||
|
||||
def _is_arm_mac() -> bool:
|
||||
return _is_macos() and platform.machine() == "arm64"
|
||||
|
||||
|
||||
def cua_driver_binary_available() -> bool:
|
||||
"""True if `cua-driver` is on $PATH or HERMES_CUA_DRIVER_CMD resolves."""
|
||||
return bool(shutil.which(_CUA_DRIVER_CMD))
|
||||
@@ -705,29 +698,3 @@ class CuaDriverBackend(ComputerUseBackend):
|
||||
message = data
|
||||
return ActionResult(ok=ok, action=name, message=message,
|
||||
meta=data if isinstance(data, dict) else {})
|
||||
|
||||
|
||||
def _parse_element(d: Dict[str, Any]) -> UIElement:
|
||||
bounds = d.get("bounds") or (0, 0, 0, 0)
|
||||
if isinstance(bounds, dict):
|
||||
bounds = (
|
||||
int(bounds.get("x", 0)),
|
||||
int(bounds.get("y", 0)),
|
||||
int(bounds.get("w", bounds.get("width", 0))),
|
||||
int(bounds.get("h", bounds.get("height", 0))),
|
||||
)
|
||||
elif isinstance(bounds, (list, tuple)) and len(bounds) == 4:
|
||||
bounds = tuple(int(v) for v in bounds)
|
||||
else:
|
||||
bounds = (0, 0, 0, 0)
|
||||
return UIElement(
|
||||
index=int(d.get("index", 0)),
|
||||
role=str(d.get("role", "") or ""),
|
||||
label=str(d.get("label", "") or ""),
|
||||
bounds=bounds, # type: ignore[arg-type]
|
||||
app=str(d.get("app", "") or ""),
|
||||
pid=int(d.get("pid", 0) or 0),
|
||||
window_id=int(d.get("windowId", 0) or 0),
|
||||
attributes={k: v for k, v in d.items()
|
||||
if k not in {"index", "role", "label", "bounds", "app", "pid", "windowId"}},
|
||||
)
|
||||
|
||||
@@ -37,7 +37,6 @@ from tools.binary_extensions import BINARY_EXTENSIONS
|
||||
from agent.file_safety import (
|
||||
build_write_denied_paths,
|
||||
build_write_denied_prefixes,
|
||||
get_safe_write_root as _shared_get_safe_write_root,
|
||||
is_write_denied as _shared_is_write_denied,
|
||||
)
|
||||
|
||||
@@ -112,19 +111,6 @@ def _normalize_line_endings(text: str, target: str) -> str:
|
||||
if target == "\r\n":
|
||||
return lf_normalized.replace("\n", "\r\n")
|
||||
return text
|
||||
|
||||
|
||||
def _get_safe_write_root() -> Optional[str]:
|
||||
"""Return the resolved HERMES_WRITE_SAFE_ROOT path, or None if unset.
|
||||
|
||||
When set, all write_file/patch operations are constrained to this
|
||||
directory tree. Writes outside it are denied even if the target is
|
||||
not on the static deny list. Opt-in hardening for gateway/messaging
|
||||
deployments that should only touch a workspace checkout.
|
||||
"""
|
||||
return _shared_get_safe_write_root()
|
||||
|
||||
|
||||
def _is_write_denied(path: str) -> bool:
|
||||
"""Return True if path is on the write deny list."""
|
||||
return _shared_is_write_denied(path)
|
||||
|
||||
@@ -627,51 +627,6 @@ def _find_all_skills(*, skip_disabled: bool = False) -> List[Dict[str, Any]]:
|
||||
def _sort_skills(skills: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
||||
"""Keep every skill listing path ordered the same way."""
|
||||
return sorted(skills, key=lambda s: (s.get("category") or "", s["name"]))
|
||||
|
||||
|
||||
def _load_category_description(category_dir: Path) -> Optional[str]:
|
||||
"""
|
||||
Load category description from DESCRIPTION.md if it exists.
|
||||
|
||||
Args:
|
||||
category_dir: Path to the category directory
|
||||
|
||||
Returns:
|
||||
Description string or None if not found
|
||||
"""
|
||||
desc_file = category_dir / "DESCRIPTION.md"
|
||||
if not desc_file.exists():
|
||||
return None
|
||||
|
||||
try:
|
||||
content = desc_file.read_text(encoding="utf-8")
|
||||
# Parse frontmatter if present
|
||||
frontmatter, body = _parse_frontmatter(content)
|
||||
|
||||
# Prefer frontmatter description, fall back to first non-header line
|
||||
description = frontmatter.get("description", "")
|
||||
if not description:
|
||||
for line in body.strip().split("\n"):
|
||||
line = line.strip()
|
||||
if line and not line.startswith("#"):
|
||||
description = line
|
||||
break
|
||||
|
||||
# Truncate to reasonable length
|
||||
if len(description) > MAX_DESCRIPTION_LENGTH:
|
||||
description = description[: MAX_DESCRIPTION_LENGTH - 3] + "..."
|
||||
|
||||
return description if description else None
|
||||
except (UnicodeDecodeError, PermissionError) as e:
|
||||
logger.debug("Failed to read category description %s: %s", desc_file, e)
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
"Error parsing category description %s: %s", desc_file, e, exc_info=True
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
def skills_list(category: str = None, task_id: str = None) -> str:
|
||||
"""
|
||||
List all available skills (progressive disclosure tier 1 - minimal metadata).
|
||||
|
||||
Reference in New Issue
Block a user