Files
hermes-agent/tools/plugin_guard.py
alt-glitch f28a67ffcb
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
Docs Search Monitor / probe (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
fix(move): a generated old-path file run as a script drops its own folder from sys.path
Run as `python tools/<name>.py`, Python puts tools/ first on sys.path. The
generated file put the checkout root in front and left tools/ behind it,
so the moved module it runs as __main__ imported tools/mcp/ in place of
the installed mcp package. The file now removes its own folder before it
adds the root. An import, a -m run and an isolated (-I) run are unchanged.
2026-11-30 21:40:07 +05:30

35 lines
1.6 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:
if __name__ == "__main__" and Path(sys.path[0]).resolve() == Path(__file__).resolve().parent:
del sys.path[0] # run as a path: a folder here named like an installed package would be imported in its place
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