Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

Offer to install a missing agent CLI in local mode (#317)

Christopher Kevin58e617c2623f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bab78f9f..96c708be 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ All notable changes to SkillEvaluator are documented in this file.
### Added
+- In local mode (`--env-mode local`), a missing Claude Code, Codex, or OpenCode
+ CLI is offered as a pinned npm install into the SkillEvaluator runtime folder;
+ without a terminal, the command is printed instead.
+
- Support Python 3.14 alongside Python 3.12 and 3.13, including installation
guidance and CI coverage for tests and built packages.
- Add reusable GitLab CI onboarding and configurable Tier 1 quality thresholds,
diff --git a/src/skillevaluator/cli.py b/src/skillevaluator/cli.py
index 82128eed..3ea19216 100644
--- a/src/skillevaluator/cli.py
+++ b/src/skillevaluator/cli.py
@@ -939,6 +939,42 @@ _TIER_BANNERS = {
}
+def _offer_local_runtime_install(raw_agents: str | None) -> None:
+ """Before a local-mode run, offer to install each missing agent CLI (pinned, managed root)."""
+ import shlex
+ import sys
+
+ from skillevaluator.provider_config import ProviderConfigurationError, resolve_llm_provider
+ from skillevaluator.tier3.commands import resolve_agents
+ from skillevaluator.tier3.harbor.local_runtime import (
+ install_local_runtime,
+ managed_install_argv,
+ managed_runtime_prefix,
+ missing_local_runtimes,
+ )
+
+ # Without a provider Tier 3 cannot run, so there is nothing to install yet; Tier 3 reports why.
+ try:
+ agents = resolve_agents(raw_agents, provider=resolve_llm_provider().provider)
+ except (ProviderConfigurationError, ValueError):
+ return
+ for agent in missing_local_runtimes(agents):
+ argv = managed_install_argv(agent)
+ console.print(f"[yellow]Local mode needs the {agent} CLI, and it is not installed.[/yellow]")
+ console.print(f" [dim]{shlex.join(argv)}[/dim]", highlight=False, soft_wrap=True)
+ if not sys.stdin.isatty():
+ console.print(" [dim]Run the command above, or use --env-mode docker.[/dim]")
+ continue
+ if not click.confirm(f" Install it into {managed_runtime_prefix(agent)}?", default=True):
+ continue
+ with console.status(f"Installing {agent}…"):
+ error = install_local_runtime(agent)
+ if error:
+ console.print(f" [red]✗ {error}[/red]", highlight=False)
+ else:
+ console.print(f" [green]✓ {agent} installed[/green]")
+
+
def _ensure_autopilot_dataset(skill_path: Path, *, quiet: bool = False, progress: str = "auto") -> str | None:
"""Ensure an evaluation source exists, generating one when missing.
@@ -2124,6 +2160,9 @@ def validate(
_print_run_banner(target_path, resolved_type, getattr(policy, "profile", None))
_print_tier_banner(_TIER_BANNERS["tier1"])
+ if run_tier3 and env_mode == "local":
+ _offer_local_runtime_install(agents)
+
# Autopilot source generation must precede every tier's publication-target
# capture so one combined report cannot bind otherwise valid tier evidence
# to different source trees. Generation remains advisory: retain any error
@@ -3015,6 +3054,7 @@ def evaluate(
)
try:
if env_mode == "local":
+ _offer_local_runtime_install(agents)
from rich.panel import Panel
from rich.text import Text
diff --git a/src/skillevaluator/tier3/harbor/local_runtime.py b/src/skillevaluator/tier3/harbor/local_runtime.py
index e6a60df0..7ccbaab1 100644
--- a/src/skillevaluator/tier3/harbor/local_runtime.py
+++ b/src/skillevaluator/tier3/harbor/local_runtime.py
@@ -5,8 +5,9 @@
Local mode runs the vendor agent CLIs (claude-code, codex, opencode) that are
already installed on the host or under ``SKILLEVALUATOR_RUNTIME_DIR``. This
-module discovers them on ``PATH``; it never downloads or installs anything.
-When a CLI is missing, it returns the vendor's own install command as a hint.
+module discovers them on ``PATH``. Discovery never installs anything; only
+:func:`install_local_runtime`, run after the operator confirms, installs the
+pinned npm release into the dedicated runtime root.
"""
from __future__ import annotations
@@ -21,6 +22,7 @@ from collections.abc import Mapping, Sequence
from errno import ELOOP
from pathlib import Path
from subprocess import SubprocessError, TimeoutExpired
+from types import MappingProxyType
from typing import Any
from skillevaluator.tier3.harbor.local_sandbox import SandboxUnavailable
@@ -53,6 +55,16 @@ _AGENT_COMMANDS: dict[str, tuple[str, ...]] = {
"opencode": ("opencode",),
}
+# npm packages and the releases SkillEvaluator was validated with. Harbor pins
+# these inside containers; a managed local install uses the same release.
+_AGENT_PACKAGES: dict[str, str] = {
+ "claude-code": "@anthropic-ai/claude-code",
+ "codex": "@openai/codex",
+ "opencode": "opencode-ai",
+}
+PINNED_RUNTIME_VERSIONS: Mapping[str, str] = MappingProxyType({"claude-code": "2.1.292", "codex": "0.161.0"})
+RUNTIME_INSTALL_TIMEOUT_SECONDS = 600
+
# Vendor install hints shown when a CLI is missing. Local mode never runs these
# for the user — it only prints them — so there is no download-and-exec surface.
_AGENT_INSTALL_HINTS: dict[str, str] = {
@@ -500,6 +512,43 @@ def missing_local_runtimes(
return missing
+def managed_runtime_prefix(agent: str, *, runtime_root: Path | None = None) -> Path:
+ """The npm prefix that holds ``agent``'s managed CLI."""
+ return validate_runtime_root(runtime_root or default_runtime_root()) / agent
+
+
+def managed_install_argv(agent: str, *, runtime_root: Path | None = None) -> list[str]:
+ """The npm command that installs ``agent``'s pinned CLI into the managed runtime root."""
+ version = PINNED_RUNTIME_VERSIONS.get(agent)
+ package = _AGENT_PACKAGES[agent] + (f"@{version}" if version else "")
+ prefix = managed_runtime_prefix(agent, runtime_root=runtime_root)
+ return ["npm", "install", "--global", "--prefix", str(prefix), "--no-audit", "--no-fund", package]
+
+
+def install_local_runtime(
+ agent: str,
+ *,
+ runtime_root: Path | None = None,
+ timeout: float = RUNTIME_INSTALL_TIMEOUT_SECONDS,
+) -> str | None:
+ """Install ``agent``'s pinned CLI under the runtime root; return an error, or ``None`` on success."""
+ npm = shutil.which("npm")
+ if npm is None:
+ return "npm not found: install Node.js 18 or newer (https://nodejs.org), then retry"
+ argv = managed_install_argv(agent, runtime_root=runtime_root)
+ try:
+ result = subprocess.run([npm, *argv[1:]], capture_output=True, text=True, timeout=timeout, check=False)
+ except (OSError, SubprocessError) as exc:
+ return f"npm install failed: {type(exc).__name__}"
+ if result.returncode != 0:
+ lines = (result.stderr or result.stdout or "").strip().splitlines()
+ return f"npm install failed (exit {result.returncode})" + (f": {lines[-1][:200]}" if lines else "")
+ if find_runtime_command(agent, runtime_root=runtime_root) is None:
+ prefix = managed_runtime_prefix(agent, runtime_root=runtime_root)
+ return f"npm install finished, but no {' or '.join(_AGENT_COMMANDS[agent])} command was found under {prefix}"
+ return None
+
+
def local_runtime_install_command(agents: Sequence[str], **_ignored: object) -> str:
"""Return the vendor install hint(s) for the given agent(s)."""
hints = [_AGENT_INSTALL_HINTS.get(agent, f"install the '{agent}' CLI and put it on PATH") for agent in agents]
diff --git a/src/skillevaluator/tier3/harbor/runner.py b/src/skillevaluator/tier3/harbor/runner.py
index 08372995..0bfd2def 100644
--- a/src/skillevaluator/tier3/harbor/runner.py
+++ b/src/skillevaluator/tier3/harbor/runner.py
@@ -115,6 +115,7 @@ from skillevaluator.tier3.harbor.gke_environment import (
is_gke_workload_identity_allowed,
)
from skillevaluator.tier3.harbor.kubeconfig import _resolve_single_kubeconfig
+from skillevaluator.tier3.harbor.local_runtime import PINNED_RUNTIME_VERSIONS
from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS, score_policy_for_metrics
from skillevaluator.tier3.harbor.progress import (
MIN_EXACT_SECRET_CHARS,
@@ -1322,8 +1323,8 @@ _HARBOR_LAUNCH_ENV = MappingProxyType({"HARBOR_TELEMETRY": "0", "PYTHON_DOTENV_D
# releases SkillEvaluator was validated with, so trials do not change when a
# new CLI ships. Local mode runs the operator's installed CLI instead, and its
# wrappers check a minimum version for the selected model.
-_CODEX_VERSION = "0.161.0"
-_CLAUDE_CODE_VERSION = "2.1.292"
+_CODEX_VERSION = PINNED_RUNTIME_VERSIONS["codex"]
+_CLAUDE_CODE_VERSION = PINNED_RUNTIME_VERSIONS["claude-code"]
# Harbor 0.22's Codex agent ran with ``model_reasoning_effort=high``; later
# releases defer to Codex's own default. Pin the effort SkillEvaluator was
# validated with so scores and cost stay comparable across Harbor upgrades.
diff --git a/tests/tier3/test_local_runtime_install.py b/tests/tier3/test_local_runtime_install.py
new file mode 100644
index 00000000..cbe20662
--- /dev/null
+++ b/tests/tier3/test_local_runtime_install.py
@@ -0,0 +1,79 @@
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+import subprocess
+from pathlib import Path
+from types import SimpleNamespace
+
+import pytest
+
+from skillevaluator import cli, provider_config
+from skillevaluator.tier3.harbor import local_runtime
+from skillevaluator.tier3.harbor.local_runtime import install_local_runtime, managed_install_argv
+
+
+def test_install_argv_pins_release_under_managed_root(tmp_path):
+ argv = managed_install_argv("claude-code", runtime_root=tmp_path)
+ assert argv[:5] == ["npm", "install", "--global", "--prefix", str(tmp_path.resolve() / "claude-code")]
+ assert argv[-1] == "@anthropic-ai/[email protected]"
+ assert managed_install_argv("opencode", runtime_root=tmp_path)[-1] == "opencode-ai"
+
+
+def test_install_without_npm(monkeypatch, tmp_path):
+ monkeypatch.setattr(local_runtime.shutil, "which", lambda _name, **_kwargs: None)
+ assert "npm not found" in install_local_runtime("codex", runtime_root=tmp_path)
+
+
+def _fake_npm(monkeypatch, returncode, create_bin):
+ calls = []
+
+ def run(argv, **_kwargs):
+ calls.append(argv)
+ if create_bin:
+ bin_dir = Path(argv[4]) / "bin"
+ bin_dir.mkdir(parents=True)
+ (bin_dir / "codex").write_text("#!/bin/sh\n")
+ (bin_dir / "codex").chmod(0o755)
+ return subprocess.CompletedProcess(argv, returncode, "", "E404 not found\n")
+
+ real_which = local_runtime.shutil.which
+ monkeypatch.setattr(
+ local_runtime.shutil,
+ "which",
+ lambda name, **kwargs: "/usr/bin/npm" if name == "npm" else real_which(name, **kwargs),
+ )
+ monkeypatch.setattr(local_runtime.subprocess, "run", run)
+ return calls
+
+
+def test_install_success_finds_cli(monkeypatch, tmp_path):
+ calls = _fake_npm(monkeypatch, 0, create_bin=True)
+ assert install_local_runtime("codex", runtime_root=tmp_path) is None
+ assert calls[0][0] == "/usr/bin/npm" and calls[0][-1] == "@openai/[email protected]"
+
+
+def test_install_failure_reports_npm_error(monkeypatch, tmp_path):
+ _fake_npm(monkeypatch, 1, create_bin=False)
+ assert install_local_runtime("codex", runtime_root=tmp_path) == "npm install failed (exit 1): E404 not found"
+
+
+def test_install_reports_missing_cli_after_success(monkeypatch, tmp_path):
+ _fake_npm(monkeypatch, 0, create_bin=False)
+ assert "no codex command was found" in install_local_runtime("codex", runtime_root=tmp_path)
+
+
+def test_offer_waits_for_a_provider(monkeypatch):
+ def no_provider():
+ raise provider_config.ProviderConfigurationError("SKILL_EVAL_LLM_API_KEY is not set")
+
+ monkeypatch.setattr(provider_config, "resolve_llm_provider", no_provider)
+ monkeypatch.setattr(local_runtime, "missing_local_runtimes", lambda *_a, **_k: pytest.fail("checked runtimes"))
+ cli._offer_local_runtime_install(None)
+
+
+def test_offer_uses_the_provider_default_agent(monkeypatch):
+ seen = []
+ monkeypatch.setattr(provider_config, "resolve_llm_provider", lambda: SimpleNamespace(provider="anthropic"))
+ monkeypatch.setattr(local_runtime, "missing_local_runtimes", lambda agents, **_k: seen.append(agents) or {})
+ cli._offer_local_runtime_install(None)
+ assert seen == [["claude-code"]]