Files
hermes-agent/tools/plugin_guard.py
alt-glitch 5b7b215a0d refactor(plugins): plugin install scan moves from tools/ to hermes_cli/
tools/ holds model tools. These two files register none: they are the
security scan that `hermes plugins install`, `update` and `validate` run
on a plugin tree, and every caller is a hermes_cli plugin command. They
move to hermes_cli:

  tools/plugin_guard.py         -> hermes_cli/plugins_install_scan.py
  tools/plugin_guard_context.py -> hermes_cli/plugins_install_scan_context.py

Their three test files move with them to tests/hermes_cli/. Every importer
changes its import line in place, so no module is imported earlier or
later than before.

tools.plugin_guard keeps working. tests/compat/old_updater_surface.json
lists three of its names, because a `hermes update` from v0.21.6 to
v0.23.1 keeps running old code after the checkout swap and imports
tools.plugin_guard from the new tree (hermes_cli/plugins_cmd.py:209 at
v0.23.1). This is the first use of the compat table: one MOVES key, one
REQUIRED_NAMES row, and tools/plugin_guard.py written by
scripts/move/generate_shims.py. That file makes the old name the same
module object as the new one, so an old updater still runs the real scan.
tools.plugin_guard_context is on no frozen list and gets nothing.

Behaviour is unchanged. Neither file has a logger.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py; comments that named the old module stems were fixed
by hand; the two gateway contract files are regenerated from the
docstring that names the module.
2026-11-17 06:41:24 +05:30

33 lines
1.4 KiB
Python
Generated

try: # Generated by scripts/move/generate_shims.py; do not edit.
"""``tools.plugin_guard`` moved to ``hermes_cli.plugins_install_scan``."""
import importlib
import importlib.util
import runpy
import sys
from pathlib import Path
def _forward():
if __name__ == "__main__" or sys.argv[:1] == ["-m"] or importlib.util.find_spec("hermes_agent") is None:
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from hermes_agent.compat import install
install()
return None if __name__ == "__main__" else importlib.import_module("hermes_cli.plugins_install_scan")
try:
_module = _forward()
except Exception:
if sys.argv[:1] != ["-m"] and __name__ != "__main__": # an entry launch; a plain import stays light
raise
import hermes_bootstrap # repairs a killed update and relaunches when it restored something
_module = _forward()
if __name__ == "__main__":
runpy.run_module("hermes_cli.plugins_install_scan", run_name="__main__", alter_sys=True)
else:
if getattr(sys.modules.get(__name__), "__dict__", None) is globals():
sys.modules[__name__] = _module
_identity = ('__name__', '__file__', '__spec__', '__loader__', '__package__', '__path__', '__cached__', '__builtins__')
globals().update({k: v for k, v in vars(_module).items() if k not in _identity})
finally:
pass