The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(tools): dedup stat check, secret-capture walrus, comment reflow
Teknium9bcf3069eb8f
diff --git a/tools/skills_tool.py b/tools/skills_tool.pyindex c1fb829b8d3..26a910da990 100644--- a/tools/skills_tool.py+++ b/tools/skills_tool.py@@ -41,7 +41,7 @@ _SKILLS_CACHE_TTL_SECONDS = 30.0def _skills_scan_signature(dirs_to_scan, disabled) -> tuple:- """O(#dirs + #categories) stat-based change signature. The platform is read via+ """O(#dirs + #categories) stat-based change signature; platform is read via``agent.skill_utils.sys`` so test patches are honored."""from agent import skill_utils as _skill_utilssig = []@@ -316,10 +316,9 @@ def _resolve_plugin_skill(name, file_path, task_id, preprocess):def _under_any(path: Path, dirs) -> bool:"""True when ``path`` (resolved where possible) lives under one of ``dirs``."""- try:+ resolved = path+ with suppress(Exception):resolved = path.resolve()- except Exception:- resolved = pathreturn any(resolved.is_relative_to(d) for d in dirs)@@ -525,8 +524,8 @@ def skill_view(skills. ``preprocess`` applies the configured SKILL.md template / inline shell rendering;slash/preload callers render the message themselves."""try:- # Validate before the ':' dispatch so a Windows drive path (C:\skills\foo)- # can't be reinterpreted as a plugin namespace.+ # Validate before the ':' dispatch so a Windows drive path (C:\skills\foo) can't be+ # reinterpreted as a plugin namespace.if lookup_error := _skill_lookup_path_error(name):return _fail(lookup_error, hint=_LOOKUP_HINT)local_category_name: str | None = None@@ -534,8 +533,8 @@ def skill_view(served, local_category_name = _resolve_plugin_skill(name, file_path, task_id, preprocess)if served is not None:return served- # The fall-through form (namespace/bare) joins onto each search dir too;- # re-validate it since `bare` is not namespace-checked.+ # The fall-through form (namespace/bare) joins onto each search dir too; re-validate it+ # since `bare` is not namespace-checked.if local_category_name and (lookup_error := _skill_lookup_path_error(local_category_name)):return _fail(lookup_error, hint=_LOOKUP_HINT)project_dirs, all_dirs, active_skills_dir = _skill_search_dirs()diff --git a/tools/skills_tool_dedup.py b/tools/skills_tool_dedup.pyindex 5de13b17d46..7796f0ed77f 100644--- a/tools/skills_tool_dedup.py+++ b/tools/skills_tool_dedup.py@@ -66,10 +66,10 @@ def _check_skill_view_dedup(task_id, name, file_path) -> str | None:continuetry:st = os.stat(src)- if (st.st_mtime_ns, st.st_size) != (mtime_ns, size):- cache.pop(key, None)- return None+ changed = (st.st_mtime_ns, st.st_size) != (mtime_ns, size)except OSError:+ changed = True+ if changed:cache.pop(key, None)return Nonereturn json.dumps({diff --git a/tools/skills_tool_setup.py b/tools/skills_tool_setup.pyindex 8023a1bd12c..2b6e6f0bffb 100644--- a/tools/skills_tool_setup.py+++ b/tools/skills_tool_setup.py@@ -102,14 +102,12 @@ def _capture_required_environment_variables(if not missing_entries:return _capture_result([])missing_names = [entry["name"] for entry in missing_entries]- # Messaging-platform gateway surfaces can't prompt for a secret, so they get- # the "unsupported" hint. Interactive gateway surfaces (desktop app / TUI) set- # HERMES_INTERACTIVE (same flag tools/approval.py uses) and register a callback- # routing to a secure secret.request overlay, so they fall through and prompt.+ # Messaging-platform gateway surfaces can't prompt for a secret, so they get the "unsupported"+ # hint. Interactive gateway surfaces (desktop app / TUI) set HERMES_INTERACTIVE (same flag+ # tools/approval.py uses) and register a callback routing to a secure secret.request overlay.if _is_gateway_surface() and not env_var_enabled("HERMES_INTERACTIVE"):return _capture_result(missing_names, gateway_setup_hint=_gateway_setup_hint())- callback = _st._secret_capture_callback- if callback is None:+ if (callback := _st._secret_capture_callback) is None:return _capture_result(missing_names)remaining_names: List[str] = []for entry in missing_entries: