Skip to content

The agent that grows with you

fix(doctor): clarify Docker npm audit remediation

KoNit-Ke21caa27b75a
diff --git a/hermes_cli/doctor.py b/hermes_cli/doctor.py
index 337df2e1f8d..b2972b05662 100644
--- a/hermes_cli/doctor.py
+++ b/hermes_cli/doctor.py
@@ -161,7 +161,7 @@ def _print_summary(should_fix: bool, total: Finding) -> None:
print(color(f" Found {len(remaining)} issue(s) to address:", Colors.YELLOW, Colors.BOLD))
print()
print(numbered)
- if not should_fix:
+ if not should_fix and total.issues:
print(color(" Tip: run 'hermes doctor --fix' to auto-fix what's possible.", Colors.DIM))
else:
print(color("─" * 60, Colors.GREEN))
diff --git a/hermes_cli/doctor_tools.py b/hermes_cli/doctor_tools.py
index 7bb2a3ea24d..a493dcff75e 100644
--- a/hermes_cli/doctor_tools.py
+++ b/hermes_cli/doctor_tools.py
@@ -414,7 +414,7 @@ def _plural(n: int) -> str:
return "vulnerability" if n == 1 else "vulnerabilities"
-def _audit_one(npm_bin: str, npm_dir, label: str, audit_extra: list[str], issues: list[str]) -> None:
+def _audit_one(npm_bin: str, npm_dir, label: str, audit_extra: list[str], manual_issues: list[str]) -> None:
"""Run one `npm audit --json` and report; any failure is silently skipped.
Every row here audits a tree whose versions come from a COMMITTED lockfile
@@ -449,7 +449,10 @@ def _audit_one(npm_bin: str, npm_dir, label: str, audit_extra: list[str], issues
"errors with an arborist crash it's a known npm bug — clears via a lockfile bump")
else:
check_info(f" ^ {detail}; report/pin the fix in package-lock.json — see #116774")
- issues.append(f"{label} has {total} npm {_plural(total)}")
+ manual_issues.append(
+ f"{label} has {total} npm {_plural(total)}; wait for an upstream lockfile fix, then update "
+ "your installation (Docker: pull a rebuilt image)"
+ )
else:
check_ok(f"{label} deps", f"({moderate} moderate {_plural(moderate)})")
except Exception:
@@ -487,7 +490,7 @@ def _check_npm_audit(should_fix: bool, f: Finding) -> None:
):
# Workspace-scoped audits check the root node_modules; standalone dirs check their own.
if ((PROJECT_ROOT if audit_extra else npm_dir) / "node_modules").exists():
- _audit_one(npm_bin, npm_dir, label, audit_extra, f.issues)
+ _audit_one(npm_bin, npm_dir, label, audit_extra, f.manual_issues)
if _is_termux():
check_info("Termux compatibility fallbacks:")
for note in _TERMUX_INSTALL_ALL_FALLBACK_NOTES:
diff --git a/tests/hermes_cli/test_doctor_audit_remedy.py b/tests/hermes_cli/test_doctor_audit_remedy.py
index c0055f9f98f..5d79486af1e 100644
--- a/tests/hermes_cli/test_doctor_audit_remedy.py
+++ b/tests/hermes_cli/test_doctor_audit_remedy.py
@@ -16,6 +16,7 @@ from unittest.mock import patch
from hermes_cli import doctor_tools
+from hermes_cli.doctor_report import Finding
def _audit_json(critical=0, high=0, moderate=0):
@@ -44,7 +45,21 @@ def test_root_remedy_never_prescribes_local_audit_fix(capsys):
assert "run: cd" not in out
assert "npm audit fix" not in out
assert "lockfile bump" in out
- assert issues == ["Browser tools (agent-browser) has 2 npm vulnerabilities"]
+ assert issues == [
+ "Browser tools (agent-browser) has 2 npm vulnerabilities; wait for an upstream lockfile fix, then update "
+ "your installation (Docker: pull a rebuilt image)"
+ ]
+
+
+def test_npm_audit_only_finding_does_not_offer_doctor_fix(capsys):
+ """npm lockfile findings need an upstream image or lockfile update (#136806)."""
+ from hermes_cli import doctor
+
+ doctor._print_summary(False, Finding(manual_issues=["web workspace has 1 npm vulnerability"]))
+
+ out = capsys.readouterr().out
+ assert "web workspace has 1 npm vulnerability" in out
+ assert "hermes doctor --fix" not in out