config_check_diagnostics.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334
  1. """Read-only diagnostics for saved toolsets and bundled platform selections."""
  2. from __future__ import annotations
  3. from collections.abc import Callable
  4. from typing import Any
  5. def config_check_diagnostics(config: dict[str, Any], get_env_value: Callable[[str], str | None]) -> list[str]:
  6. """Report saved selections that would otherwise be lost in startup output.
  7. Toolset names are judged by the resolver ``hermes config migrate`` also uses, disabled platforms
  8. by the runtime's own ``plugins.disabled`` reader and the manifest-name gate of
  9. ``plugins_discovery.gate_manifest``. A configured credential is only a reason to *mention* a
  10. disabled platform; disabling it may have been intentional.
  11. """
  12. from hermes_cli.config import _platform_manifest_env_entries, _platform_plugin_manifests
  13. from hermes_cli.plugins_discovery import _get_disabled_plugins
  14. from hermes_cli.toolset_validation import saved_toolset_resolver, validate_platform_toolsets
  15. diagnostics = validate_platform_toolsets(config.get("platform_toolsets"), saved_toolset_resolver(config))
  16. disabled = _get_disabled_plugins()
  17. for name, manifest in _platform_plugin_manifests(source="bundled"):
  18. key = f"platforms/{name}"
  19. if not {key, str(manifest.get("name"))} & disabled:
  20. continue
  21. required = [env for env, _secret, _meta in _platform_manifest_env_entries(manifest, optional=False)]
  22. if required and all(get_env_value(env) for env in required):
  23. diagnostics.append(
  24. f"platform plugin '{key}' is disabled while its required credentials are configured. "
  25. f"Run `hermes plugins enable {key}` if you want it active."
  26. )
  27. return diagnostics