The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(hermes_cli): inline single-use plumbing helpers (portable manifest read, pulled-revision record, entrypoint listing, timeout block)
Tekniumd127749b2366
diff --git a/hermes_cli/plugins_cmd.py b/hermes_cli/plugins_cmd.pyindex 8d54841d48a..23548f5587d 100644--- a/hermes_cli/plugins_cmd.py+++ b/hermes_cli/plugins_cmd.py@@ -271,12 +271,6 @@ def _load_yaml_manifest(manifest_file: Path):return yaml.safe_load(f) or {}-def _read_portable_manifest(plugin_dir: Path) -> dict:- """Validated Agent Plugins v1 ``plugin.json`` manifest (diagnostics dropped); raises on failure."""- from hermes_cli.agent_plugins import read_agent_plugin_manifest- return read_agent_plugin_manifest(plugin_dir)[0]--def _read_manifest(plugin_dir: Path) -> dict:"""Read a native or portable manifest, preferring native YAML."""manifest_file = _native_manifest_file(plugin_dir)@@ -284,7 +278,8 @@ def _read_manifest(plugin_dir: Path) -> dict:if not _has_portable_manifest(plugin_dir):return {}try:- return _read_portable_manifest(plugin_dir)+ from hermes_cli.agent_plugins import read_agent_plugin_manifest+ return read_agent_plugin_manifest(plugin_dir)[0]except Exception as e:logger.warning("Failed to read plugin.json in %s: %s", plugin_dir, e)return {}@@ -794,7 +789,12 @@ def _pull_plugin_update(target: Path, pinned_msg, not_git_msg, before_pull=None)ok, output = _git_pull_plugin_dir(target)if not ok:raise PluginOperationError(output)- _record_pulled_revision(target, metadata, install_record)+ # Store the new HEAD in the plugin's install-metadata record (if it has one).+ git_exe = _resolve_git_executable() if install_record else None+ if git_exe:+ install_record["revision"] = _git_head_revision(target, git_exe)+ metadata[target.name] = install_record+ _write_install_metadata(metadata)return output@@ -863,15 +863,6 @@ def _post_pull_housekeeping(target: Path, console) -> None:_copy_example_files(target, console)-def _record_pulled_revision(target: Path, metadata: dict, install_record: dict) -> None:- """After a pull, store the new HEAD in the plugin's install-metadata record (if it has one)."""- git_exe = _resolve_git_executable() if install_record else None- if git_exe:- install_record["revision"] = _git_head_revision(target, git_exe)- metadata[target.name] = install_record- _write_install_metadata(metadata)--def _remove_plugin_core(target: Path) -> None:"""Remove one plugin and its metadata without splitting their state."""metadata = _read_install_metadata()@@ -1221,7 +1212,8 @@ def _read_manifest_info(d: Path, prefix: str):if not _has_portable_manifest(d):return Nonetry:- manifest = _read_portable_manifest(d)+ from hermes_cli.agent_plugins import read_agent_plugin_manifest+ manifest = read_agent_plugin_manifest(d)[0]name = manifest["name"]except Exception:return None@@ -1290,24 +1282,18 @@ def _discover_all_plugins() -> list:seen: dict = {}# memory/, context_engine/ and model-providers/ load through dedicated registries, not the# PluginManager opt-in surface, so listing them as toggleable plugins would mislead.- from hermes_cli.plugins import get_bundled_plugins_dir+ from hermes_cli.plugins import discover_entrypoint_manifests, get_bundled_plugins_dirfor base, source, skip in ((get_bundled_plugins_dir(), "bundled", {"memory", "context_engine", "model-providers"}),(_plugins_dir(), "user", set()),):_scan_level(base, source, skip, "", 0, seen)- for name, version, description, path in _discover_entrypoint_plugins():- seen[name] = (name, version, description, "entrypoint", path, name)+ # Entry-point plugins are installed as Python packages, so they have no plugin directory.+ for m in discover_entrypoint_manifests():+ seen[m.name] = (m.name, m.version, m.description, "entrypoint", m.path, m.name)return list(seen.values())-def _discover_entrypoint_plugins() -> list[tuple[str, str, str, str]]:- """``(name, version, summary, target)`` for ``hermes_agent.plugins`` entry points — installed- as Python packages, so they have no plugin directory."""- from hermes_cli.plugins import discover_entrypoint_manifests- return [(m.name, m.version, m.description, m.path) for m in discover_entrypoint_manifests()]--def _plugin_status(name: str, enabled: set, disabled: set, key: str = "") -> str:"""User-facing activation state for a plugin name or key."""if name in disabled or key in disabled:@@ -1461,10 +1447,7 @@ def _configure_category_spec(spec) -> bool:def _provider_categories() -> list:"""``[(title, current_label, configure_fn), ...]`` rows for the composite UI."""- return [- (spec[0], spec[3]() or spec[1], functools.partial(_configure_category_spec, spec))- for spec in _PROVIDER_CATEGORY_SPECS- ]+ return [(s[0], s[3]() or s[1], functools.partial(_configure_category_spec, s)) for s in _PROVIDER_CATEGORY_SPECS]# ── Composite plugins UI ────────────────────────────────────────────────────────────────────diff --git a/hermes_cli/plugins_dispatch.py b/hermes_cli/plugins_dispatch.pyindex 0ab832883b7..2db2d309cb7 100644--- a/hermes_cli/plugins_dispatch.py+++ b/hermes_cli/plugins_dispatch.py@@ -136,11 +136,6 @@ def _hook_uses_callback_timeout(hook_name: str, timeout: float) -> bool:return hook_name in _HOOK_TIMEOUT_BOUNDED_HOOKS or hook_name in _HOOK_TIMEOUT_FAIL_CLOSED_HOOKS-def _pre_tool_call_timeout_block() -> Dict[str, str]:- """Fail-closed directive when a policy callback times out or is still running."""- return {"action": "block", "message": _PRE_TOOL_CALL_TIMEOUT_BLOCK_MESSAGE}--class PluginDispatchMixin:@staticmethoddef _invoke_hook_callback(callback: Callable, payload: Dict[str, Any]) -> Any:@@ -180,8 +175,8 @@ class PluginDispatchMixin:if use_timeout:ret = self._run_hook_callback_bounded(hook_name, cb, kwargs, timeout)if ret is _HOOK_SKIPPED:- if fail_closed:- results.append(_pre_tool_call_timeout_block())+ if fail_closed: # policy hook: fail closed with a block directive+ results.append({"action": "block", "message": _PRE_TOOL_CALL_TIMEOUT_BLOCK_MESSAGE})continueelse:ret = self._invoke_hook_callback(cb, kwargs)