diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b4172de2..3a515a5e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,14 @@ All notable changes to SkillEvaluator are documented in this file. ### Added -- Tier 3 datasets can declare deterministic behavior checks for script invocation and success, workspace files, and final-response text. +- A reproducible public terminal starter runs the released CLI against the + bundled text-analyzer skill, checks real script/report output and a seeded + quality regression, and retains an editable task, fixture and run receipt. + The walkthrough connects setup, interpretation, live-evaluation prerequisites, + troubleshooting and adaptation; contributor guidance clarifies environment + setup, example verification and the existing DCO policy. +- Tier 3 datasets can declare deterministic behavior checks for script invocation and success, workspace files, and final-response text. - `tier3 import-metrics` accepts versioned, normalized per-case custom scores from external evaluations and writes clearly labeled JSON/Markdown reports. Imports validate identities, metric metadata and values, retain declared diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 911ae97a6..3d7a85adb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,6 +11,23 @@ Contributions are welcome through GitHub pull requests. - Run `make lint`, `make test`, and `make build` locally. - Update [CHANGELOG.md](CHANGELOG.md) when the change affects users. +For environment setup, focused tests, documentation checks and the review +workflow, read the [contributor guide](docs/developer-guide.mdx). For a runnable +public skill and task, start with the [terminal starter](examples/starter/README.md). + +## Documentation And Example Contributions + +- Run every command you change against the documented release or checkout and + say which you tested. Do not claim support on platforms you did not verify. +- Keep example inputs public and portable. Include expected-output checks and + label seeded failures and missing evidence; a fixture is not a live benchmark. +- For this starter, run `uv run python scripts/demo_starter.py --output reports/contribution-demo` + and `uv run pytest tests/test_demo_starter.py`. Use a new output directory on + subsequent runs. Retain reports locally and summarize exactly what ran in + the pull request; do not commit generated reports or transcripts. +- Validate docs with the pinned Fern CLI as described in the contributor guide. +- Explain recovery from missing dependencies, credentials and incomplete runs. + ## Pull Requests Use the pull request template, keep each pull request focused, and explain the @@ -20,6 +37,9 @@ you confirm that you have the right to contribute it under the ## Signing Your Work +The contribution requirement is the Developer Certificate of Origin (DCO) +sign-off below, not a Contributor License Agreement (CLA). + - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. diff --git a/docs/AGENTS.md b/docs/AGENTS.md index ccedcc5db..659238c9e 100644 --- a/docs/AGENTS.md +++ b/docs/AGENTS.md @@ -12,6 +12,7 @@ folder holds MDX pages published to @@ -78,6 +91,29 @@ python tests/reporting/browser_navigation_checks.py browser-checks The script renders its own fixture reports, then writes screenshots and `navigation-results.json` to `browser-checks/`. To use an installed Chrome instead of Playwright's Chromium, set `SKILLEVALUATOR_TEST_BROWSER` to the browser's executable or pass `--browser`. +## Documentation and starter changes + +The [terminal starter](starter-demo.mdx) uses a public skill, task and input with +real CLI output checks. For changes to it, run: + +```bash +uv run python scripts/demo_starter.py --output reports/contribution-demo +uv run pytest tests/test_demo_starter.py +uv run ruff check scripts/demo_starter.py tests/test_demo_starter.py +``` + +Choose a new output directory for each replay. To verify the released route, +also run the pinned command in the starter guide. Report the evaluator version, +platform and exact commands tested in your pull request. Keep generated reports +out of commits. Describe seeded failures and incomplete evidence honestly; do +not reuse historical scores as a fresh run or silently change expectations to +make a check green. A fresh-user review should ask someone unfamiliar with the +tool to explain the passing, regressed and incomplete outputs before showing +the walkthrough's answers, and record what confused them in the pull request. +The focused test intentionally runs the checkout's evaluator, so a scoring +change on main can fail it even when the released replay still passes. Review +both results before changing expectations. + ## Code style and dependencies Ruff owns linting — `make lint` is the project's lint gate. CI runs `ruff check` over the whole repository, so lint the files you touch even outside `src` and `tests`. diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx index 878d83f9e..74bd810b7 100644 --- a/docs/quickstart.mdx +++ b/docs/quickstart.mdx @@ -11,6 +11,10 @@ quality check, or add NVIDIA Build to get feedback from a model. | [Run without an LLM](#run-without-an-llm) | Git and uv | A deterministic quality score and findings | | [Use NVIDIA Build](#use-nvidia-build) | Git, uv, and an NVIDIA Build API key | Model-backed rubric scores and feedback | +For an executable terminal replay with checked outputs, an editable task, a +deliberate regression and report interpretation, use the +[reproducible starter demo](starter-demo.mdx). It uses the same bundled skill. + ## Get the example Install [uv](https://docs.astral.sh/uv/getting-started/installation/) and Git, diff --git a/docs/starter-demo.mdx b/docs/starter-demo.mdx new file mode 100644 index 000000000..4ff13641b --- /dev/null +++ b/docs/starter-demo.mdx @@ -0,0 +1,176 @@ +--- +title: "Reproducible Terminal Demo" +description: "Replay a public starter, check its real outputs, distinguish a passing check from complete evidence, and adapt the same skill and task." +--- + +Use one example from terminal replay to your own skill. This demo uses the public +`text-analyzer` reference skill, a two-line text fixture, and the released 0.8.0 +CLI. It does not require an account, key, scanner, Docker runtime or GPU. + +## Replay and run the same example + +Install [Git](https://git-scm.com/downloads) and +[uv](https://docs.astral.sh/uv/getting-started/installation/). These commands use +Python 3.13, provisioned by uv, and avoid shell-specific environment variable +syntax. The replay below is validated on Linux. Native macOS and Windows +replay still need validation; cross-platform Python alone does not establish +that coverage. + +```bash +git clone --depth 1 https://github.com/NVIDIA/SkillEvaluator.git +cd SkillEvaluator +uv run --isolated --no-project --python 3.13 --with "skillevaluator @ https://github.com/NVIDIA/SkillEvaluator/releases/download/v0.8.0/skillevaluator-0.8.0-py3-none-any.whl" python scripts/demo_starter.py --output reports/starter +``` + +The demo files come from your checkout; `--isolated --no-project --with` uses +the public release wheel, not an editable development install. The 0.8.0 wheel +is available on [GitHub Releases](https://github.com/NVIDIA/SkillEvaluator/releases/tag/v0.8.0); +do not assume the same version is already on PyPI. Installation needs +internet access. The demo then runs locally. For standalone pip installations +and supported Python versions, see [Installation](installation.mdx). + +The runner prints each command and its real terminal output. It copies the +installed skill into `reports/starter/text-analyzer`, stages the public input +and task, runs the analysis script, and evaluates quality. It also makes a +separate intentionally shortened documentation copy to demonstrate a regression. +Your source checkout and the installed reference skill are not edited. + +The final line starts with `PASS: starter output and quality regression checked`. +An expected `Error: quality check failed` appears earlier for the seeded +regression. The runner itself exits 0 only after the report checks succeed. +It never overwrites an existing output directory: use `--output reports/starter-2` +to repeat it. + +This executable replay is the demo source, not a video recording. To produce the +same demonstration, run the command above; `quality.txt` and `regressed.txt` +retain the terminal output, and `receipt.json` records the version and time. +Expected scalar values live in +[`examples/starter/expected.json`](https://github.com/NVIDIA/SkillEvaluator/blob/main/examples/starter/expected.json); +they are checked against new results, not substituted for them. Historical +benchmark scores are not evidence for this run. + +## Interpret the reports + +| Question | Fresh output | What it means | +| --- | --- | --- | +| Did the script do the task? | `analysis.json`: 4 words, 2 lines, 27 characters, 2 sentences; `hello` appears twice | The direct script agrees with the public fixture. No agent was involved. | +| Did the quality check pass? | `quality/skillevaluator-quality.json`: `overall_status: passed`, score 84.5, grade B, exit 0 | The original documentation meets the demo's explicit `--min-score 80` gate. Read findings even when it passes. | +| Did quality regress? | `regressed/skillevaluator-quality.json`: `overall_status: failed`, score 71, grade C, exit 1 | Removing guidance lowered static quality below the same threshold. This seeded example is not a measurement of agent performance. | +| Is the passing skill ready to publish? | The passing report has `publication_status: incomplete`, `publication.eligible: false` and `publication.reasons` | No: required security, deduplication and live execution evidence is missing. A successful command does not imply complete evidence. | + +In the released CLI, the passing command can print `All validations passed` +without mentioning publication completeness. Open the **JSON** to see +`publication_status` and its reasons; the demo runner also prints an explicit +`publication INCOMPLETE` reminder. Do not infer publication readiness from the +terminal PASS line alone. + +The failing quality report has `publication_status: fail`; a known failure takes +precedence over missing evidence. Do not interpret incomplete evidence as a +zero score, a pass, or proof of a skill defect. Fix execution/setup problems and +rerun before drawing performance conclusions. For live agent results, compare +with-skill and without-skill outcomes, inspect failed attempts and coverage, and +use the verdict and completion fields together; see [Reports & Results](reports.mdx). + +### Replay a single command manually + +From the repository root after the demo, use the same copied skill and threshold: + +```bash +uv run --isolated --no-project --python 3.13 --with "skillevaluator @ https://github.com/NVIDIA/SkillEvaluator/releases/download/v0.8.0/skillevaluator-0.8.0-py3-none-any.whl" skillevaluator quality-check reports/starter/text-analyzer --min-score 80 -r cli -r json -o reports/manual-quality +``` + +The runner invokes this installed Click CLI through the same Python interpreter +with `python -m skillevaluator.cli`; it does not mock the evaluator or render a +prebuilt report. The usual quality threshold is 70; this demo deliberately uses +80 so the seeded regression fails. + +## Add model feedback or a live agent + +For fresh model-backed instruction feedback on this same skill, configure an +account and key using [NVIDIA Build](quickstart.mdx#use-nvidia-build) or another +[public provider](configuration.mdx). Never put a key in a report or fixture. +Then run: + +```bash +uv run --isolated --no-project --python 3.13 --with "skillevaluator[llm] @ https://github.com/NVIDIA/SkillEvaluator/releases/download/v0.8.0/skillevaluator-0.8.0-py3-none-any.whl" skillevaluator models --limit 100 +uv run --isolated --no-project --python 3.13 --with "skillevaluator[llm] @ https://github.com/NVIDIA/SkillEvaluator/releases/download/v0.8.0/skillevaluator-0.8.0-py3-none-any.whl" skillevaluator rubric-eval reports/starter/text-analyzer -r cli -r json -o reports/starter-rubric +``` + +Model catalogs and account access change. A visible catalog entry does not +guarantee inference access. If the default model returns HTTP 404 or 410, select +a model available to your account with `SKILL_EVAL_LLM_MODEL` as described in +[configuration](configuration.mdx). Authentication errors, rate limits, and +unavailable models are not low rubric scores. Inspect the JSON findings for +`llm_unavailable`; do not present a fallback response as a completed evaluation. + +For example, a fresh public Build rubric run was verified with +`SKILL_EVAL_LLM_MODEL=nvidia/nemotron-3.5-bolt-e4b`. Set the variable in the same +shell before the rubric command (`export SKILL_EVAL_LLM_MODEL=nvidia/nemotron-3.5-bolt-e4b` +on POSIX shells, or `$env:SKILL_EVAL_LLM_MODEL="nvidia/nemotron-3.5-bolt-e4b"` in +PowerShell). This is an instruction-feedback example, not a promised score or +an agent benchmark. If the response has `llm_invalid_response`, the call reached +the model but did not produce valid rubric evidence; retain it and retry with a +supported model rather than interpreting it as a completed low-scoring run. + +Rubric feedback is not agent uplift. For the paired agent experiment, keep the +same copied task and input and follow the +[live evaluation prerequisites](tier3-live-evaluation.mdx#before-you-start). +After installing the `tier3` extra, configuring evaluator/agent credentials and +starting Docker, run: + +```bash +uv run --isolated --no-project --python 3.13 --with "skillevaluator[tier3] @ https://github.com/NVIDIA/SkillEvaluator/releases/download/v0.8.0/skillevaluator-0.8.0-py3-none-any.whl" skillevaluator doctor --env-mode docker +uv run --isolated --no-project --python 3.13 --with "skillevaluator[tier3] @ https://github.com/NVIDIA/SkillEvaluator/releases/download/v0.8.0/skillevaluator-0.8.0-py3-none-any.whl" skillevaluator tier3 evaluate reports/starter/text-analyzer --n-attempts 1 +``` + +The authored task is `evals/evals.json`; `evals/files/input.txt` is staged into +the sandbox at `/workspace/input/input.txt`. Read both before paying for agent +runs. One tiny task is a plumbing example, not representative coverage or +independent validation of a grader. Model and sandbox usage can incur charges. +Read [Eval Datasets](eval-datasets.mdx) for additional cases, grading and policy, +and retain all completed attempts and errors rather than publishing only a score. + +## Adapt the example + +1. Copy `reports/starter/text-analyzer` to a new skill directory. Keep output + reports outside that directory; do not start from the regressed copy. +2. Change `SKILL.md`, the script, and `evals/files/input.txt` to your use case. + Update the task prompt and expected outcome together. Preserve the input's + final newline if you still expect 27 characters. +3. Check the script independently, then run `quality-check` on your directory. + Inspect individual findings rather than optimizing only the aggregate score. +4. For agent impact, add varied realistic cases and independently checked + outcomes, then repeat the paired live evaluation. Do not carry the starter's + scores or expected values over to your own skill. + +### Check your understanding + +Before looking at answers, open the two JSON reports and answer: + +- Which command failed, and why is the demo's final exit still 0? +- Can the passing skill claim an agent benefit or publication eligibility? +- What changed between the original and regressed copy? Which findings explain + the score change? + +Answers: the intentionally shortened copy fails the 80 gate; the runner expects +that failure. No agent benefit or publication readiness was established. +Only the copied documentation changed, not the script, task, or input. Inspect +`quality_summary` and `finding_groups` for the changed quality findings. These +self-checks are not a substitute for feedback from a first-time human user. + +## Recover and continue + +| Symptom | Action | +| --- | --- | +| Python or dependencies cannot download | Check internet/proxy access and uv installation; see [installation](installation.mdx). No key is needed for the keyless route. | +| Output directory already exists | Keep it as evidence; use a new `--output` path. Nothing is overwritten. | +| A checked score or report field differs | Read the retained JSON/text, confirm `receipt.json` if present and the installed version; do not blindly update expectations. A failed demo does not write a success receipt. | +| Analysis count differs | Check file contents, encoding and newlines; the input is UTF-8 plain text with a final newline. | +| Scanner or sandbox is missing | The keyless demo does not need either. Follow [scanner setup](installation.mdx#system-tools) or [agent setup](agents-and-sandboxes.mdx) before adding those stages. | +| Template reference asks you to sign in | Use the [public template reference](https://github.com/NVIDIA/SkillEvaluator/blob/main/ci/templates/README.md) and [versioned bundles](https://github.com/NVIDIA/SkillEvaluator/tree/main/ci/bundles/0.8.0), not a private mirror. Check bundle files against `SHA256SUMS.txt`. | + +The public template reference and versioned downloadable bundles were consolidated +in [the public template update](https://github.com/NVIDIA/SkillEvaluator/pull/328). +They require no private account. For repository automation, continue with +[Repository Integration](repository-integration.mdx); for improvements to this +starter, see [Contributing](developer-guide.mdx). diff --git a/examples/starter/README.md b/examples/starter/README.md new file mode 100644 index 000000000..54af35c22 --- /dev/null +++ b/examples/starter/README.md @@ -0,0 +1,36 @@ +# Public terminal starter + +Run from the repository root with [uv](https://docs.astral.sh/uv/getting-started/installation/) +and Git installed. The CLI is pinned to the public 0.8.0 release wheel; the demo files +come from this checkout. No API key, scanner, GPU or Docker is needed. + +```bash +uv run --isolated --no-project --python 3.13 --with "skillevaluator @ https://github.com/NVIDIA/SkillEvaluator/releases/download/v0.8.0/skillevaluator-0.8.0-py3-none-any.whl" python scripts/demo_starter.py --output reports/starter +``` + +The runner copies the installed `text-analyzer` reference skill into the output +directory, adds this folder's task and input fixture, then executes the real +text-analysis script and CLI. It compares their results to `expected.json`: + +- The fixture has 4 words, 2 lines, 27 characters and 2 sentences. +- Original documentation scores 84.5/100 (B) and passes the explicit 80 threshold. +- A separate, deliberately shortened copy scores 71/100 (C) and fails that same + threshold. The runner expects that command's exit code 1, then exits 0 itself. +- The passing report still has `publication_status: incomplete`: static quality + is not security coverage or evidence that an agent benefits from the skill. + +These are deterministic quality checks, **not** agent-impact scores or a live +benchmark. No saved or historical report is replayed as new evidence. All JSON +reports and terminal text are freshly generated. `receipt.json` records the +installed version and timestamp only after all checks pass. + +The copied skill is editable and includes `evals/evals.json` and +`evals/files/input.txt`. The demo directly checks the script, not an agent's +ability to execute the task. Live evaluation requires additional setup. + +Use a new output directory for every run; existing directories are never +overwritten. Reports stay outside the skill. Do not update expected scores just +to silence a failure: inspect the report findings and the evaluator version. + +See the [complete walkthrough](../../docs/starter-demo.mdx) for installation, +manual replay, report interpretation, live evaluation, recovery and adaptation. diff --git a/examples/starter/evals.json b/examples/starter/evals.json new file mode 100644 index 000000000..98e6f20e6 --- /dev/null +++ b/examples/starter/evals.json @@ -0,0 +1,16 @@ +{ + "skill_name": "text-analyzer", + "evals": [ + { + "id": "text-analyzer-starter-001", + "prompt": "Analyze /workspace/input/input.txt with text-analyzer. Return the word count, line count, character count, sentence count and most frequent word.", + "expected_output": "4 words, 2 lines, 27 characters, 2 sentences; hello is the most frequent word with 2 occurrences.", + "expected_skill": "text-analyzer", + "expected_script": "analyze_text.py", + "assertions": [ + "The agent reads text-analyzer/SKILL.md and runs scripts/analyze_text.py with --file and --json.", + "The returned statistics match the input fixture, including its final newline." + ] + } + ] +} diff --git a/examples/starter/expected.json b/examples/starter/expected.json new file mode 100644 index 000000000..68b2c2d13 --- /dev/null +++ b/examples/starter/expected.json @@ -0,0 +1,16 @@ +{ + "analysis": { + "word_count": 4, + "line_count": 2, + "character_count": 27, + "sentence_count": 2, + "average_word_length": 5.75, + "top_words": [ + {"word": "hello", "count": 2}, + {"word": "world", "count": 1}, + {"word": "skills", "count": 1} + ] + }, + "quality": {"score": 84.5, "grade": "B", "status": "passed", "exit_code": 0, "publication": "incomplete"}, + "regressed": {"score": 71.0, "grade": "C", "status": "failed", "exit_code": 1, "publication": "fail"} +} diff --git a/examples/starter/input.txt b/examples/starter/input.txt new file mode 100644 index 000000000..885f07940 --- /dev/null +++ b/examples/starter/input.txt @@ -0,0 +1,2 @@ +Hello world. +Hello skills. diff --git a/fern/docs.yml b/fern/docs.yml index 5ae2ffdd5..8a1b5c27f 100644 --- a/fern/docs.yml +++ b/fern/docs.yml @@ -32,6 +32,9 @@ navigation: - page: Quickstart path: ../docs/quickstart.mdx slug: quickstart + - page: Reproducible Terminal Demo + path: ../docs/starter-demo.mdx + slug: starter-demo - page: Installation path: ../docs/installation.mdx slug: installation diff --git a/scripts/demo_starter.py b/scripts/demo_starter.py new file mode 100644 index 000000000..25f0275e1 --- /dev/null +++ b/scripts/demo_starter.py @@ -0,0 +1,160 @@ +#!/usr/bin/env python3 +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Run the public starter through the installed CLI and check retained output.""" + +import argparse +import json +import os +import shlex +import shutil +import subprocess +import sys +from datetime import UTC, datetime +from importlib.metadata import version +from importlib.resources import as_file, files +from pathlib import Path + +FIXTURES = Path(__file__).resolve().parents[1] / "examples" / "starter" +REGRESSED_SKILL = """--- +name: text-analyzer +description: Text statistics. +--- + +# Text Analyzer + +Run scripts/analyze_text.py. +""" + + +def require(condition: bool, message: str) -> None: + if not condition: + raise ValueError(message) + + +def run(command: list[str], log: Path, expected_exit: int) -> None: + print(f"\n$ {shlex.join(command)}", flush=True) + result = subprocess.run( + command, + capture_output=True, + text=True, + encoding="utf-8", + env={**os.environ, "PYTHONIOENCODING": "utf-8"}, + check=False, + ) + log.write_text(result.stdout + result.stderr, encoding="utf-8") + sys.stdout.buffer.write((result.stdout + result.stderr).encode("utf-8")) + sys.stdout.flush() + require(result.returncode == expected_exit, f"Expected exit {expected_exit}, got {result.returncode}; see {log}") + + +def check_quality(report: dict, expected: dict) -> None: + require(report["overall_status"] == expected["status"], "Unexpected quality status") + require(report["overall_passed"] == (expected["exit_code"] == 0), "Unexpected quality verdict") + quality = report["quality_summary"][0] + require( + quality["overall_score"] == expected["score"], + "Quality score changed; review findings before updating expectations", + ) + require(quality["grade"] == expected["grade"], "Unexpected quality grade") + require(report["publication_status"] == expected["publication"], "Unexpected publication status") + require( + not report["publication"]["eligible"] and bool(report["publication"]["reasons"]), + "Missing publication explanation", + ) + + +def demo(output: Path) -> dict: + expected = json.loads((FIXTURES / "expected.json").read_text(encoding="utf-8")) + output.mkdir(parents=True, exist_ok=False) + skill = output / "text-analyzer" + reference = files("skillevaluator.tier3.reference_skills").joinpath("text-analyzer") + with as_file(reference) as source: + skill.mkdir() + shutil.copy2(source / "SKILL.md", skill / "SKILL.md") + shutil.copytree(source / "scripts", skill / "scripts", ignore=shutil.ignore_patterns("__pycache__")) + (skill / "evals" / "files").mkdir(parents=True) + shutil.copy2(FIXTURES / "evals.json", skill / "evals" / "evals.json") + shutil.copy2(FIXTURES / "input.txt", skill / "evals" / "files" / "input.txt") + + run( + [ + sys.executable, + str(skill / "scripts" / "analyze_text.py"), + "--file", + str(skill / "evals" / "files" / "input.txt"), + "--json", + ], + output / "analysis.json", + 0, + ) + actual = json.loads((output / "analysis.json").read_text(encoding="utf-8")) + require(actual == expected["analysis"], "Text-analysis output differs from the reviewed fixture") + + regressed = output / "regressed-text-analyzer" + shutil.copytree(skill, regressed) + (regressed / "SKILL.md").write_text(REGRESSED_SKILL, encoding="utf-8") + for label, target in (("quality", skill), ("regressed", regressed)): + run( + [ + sys.executable, + "-m", + "skillevaluator.cli", + "quality-check", + str(target), + "--min-score", + "80", + "-r", + "cli", + "-r", + "json", + "-o", + str(output / label), + ], + output / f"{label}.txt", + expected[label]["exit_code"], + ) + report = json.loads((output / label / "skillevaluator-quality.json").read_text(encoding="utf-8")) + check_quality(report, expected[label]) + + receipt = { + "generated_at": datetime.now(UTC).isoformat(), + "skillevaluator_version": version("skillevaluator"), + "python_version": sys.version.split()[0], + "checks": [ + "text output matches fixture", + "quality passes at 80", + "seeded documentation regression fails at 80", + "publication remains incomplete", + ], + "live_agent_evaluation": "not run", + } + (output / "receipt.json").write_text(json.dumps(receipt, indent=2) + "\n", encoding="utf-8") + print("\nPASS: starter output and quality regression checked; publication INCOMPLETE (no live agent evaluation).") + print(f"Reports and editable starter: {output}") + return receipt + + +def main() -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--output", + type=Path, + default=Path("reports/starter"), + help="New directory; existing paths are never overwritten", + ) + args = parser.parse_args() + try: + demo(args.output.resolve()) + except (OSError, ValueError, KeyError, IndexError) as exc: + print( + f"Demo failed: {exc}. Keep the output for diagnosis and retry with a new --output directory.", + file=sys.stderr, + ) + return 1 + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/test_demo_starter.py b/tests/test_demo_starter.py new file mode 100644 index 000000000..8f0bc19da --- /dev/null +++ b/tests/test_demo_starter.py @@ -0,0 +1,98 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +import copy +import json +import os +import subprocess +import sys +from pathlib import Path + +import pytest +from scripts.demo_starter import FIXTURES, check_quality + +ROOT = Path(__file__).resolve().parents[1] + + +@pytest.mark.parametrize("page", ["docs/starter-demo.mdx", "examples/starter/README.md"]) +def test_released_commands_do_not_reuse_the_editable_checkout(page): + text = (ROOT / page).read_text() + commands = [line for line in text.splitlines() if line.startswith("uv run ") and "--with " in line] + assert commands + for command in commands: + assert "--isolated --no-project" in command + assert "https://github.com/NVIDIA/SkillEvaluator/releases/download/" in command + assert ".whl" in command + + +def test_starter_runs_real_cli_and_preserves_sources(tmp_path): + output = tmp_path / "starter with spaces" + source = ROOT / "src/skillevaluator/tier3/reference_skills/text-analyzer/SKILL.md" + original = source.read_bytes() + command = [sys.executable, str(ROOT / "scripts/demo_starter.py"), "--output", str(output)] + result = subprocess.run( + command, + cwd=tmp_path, + capture_output=True, + text=True, + encoding="utf-8", + env={**os.environ, "PYTHONIOENCODING": "cp1252"}, + check=False, + ) + assert result.returncode == 0, result.stdout + result.stderr + assert "PASS: starter output" in result.stdout + assert source.read_bytes() == original + expected = json.loads((FIXTURES / "expected.json").read_text()) + assert json.loads((output / "analysis.json").read_text()) == expected["analysis"] + for label in ("quality", "regressed"): + report = json.loads((output / label / "skillevaluator-quality.json").read_text()) + check_quality(report, expected[label]) + assert (output / f"{label}.txt").is_file() + receipt = json.loads((output / "receipt.json").read_text()) + assert receipt["live_agent_evaluation"] == "not run" + assert receipt["skillevaluator_version"] + dataset = json.loads((output / "text-analyzer/evals/evals.json").read_text()) + assert dataset["skill_name"] == "text-analyzer" + assert "27 characters" in dataset["evals"][0]["expected_output"] + assert (output / "text-analyzer/evals/files/input.txt").read_text() == (FIXTURES / "input.txt").read_text() + + before = (output / "receipt.json").read_bytes() + repeat = subprocess.run(command, cwd=tmp_path, capture_output=True, text=True, check=False) + assert repeat.returncode == 1 + assert "new --output directory" in repeat.stderr + assert (output / "receipt.json").read_bytes() == before + + +@pytest.fixture +def quality_report(): + return { + "overall_status": "passed", + "overall_passed": True, + "quality_summary": [{"overall_score": 84.5, "grade": "B"}], + "publication_status": "incomplete", + "publication": {"eligible": False, "reasons": ["Live evaluation did not run"]}, + } + + +@pytest.mark.parametrize( + ("section", "key", "value"), + [ + (None, "overall_status", "failed"), + (None, "overall_passed", False), + ("quality_summary", "overall_score", 100), + ("quality_summary", "grade", "A"), + (None, "publication_status", "pass"), + ("publication", "eligible", True), + ("publication", "reasons", []), + ], +) +def test_output_checks_reject_changed_or_misleading_results(quality_report, section, key, value): + expected = json.loads((FIXTURES / "expected.json").read_text())["quality"] + check_quality(quality_report, expected) + changed = copy.deepcopy(quality_report) + target = changed if section is None else changed[section] + if section == "quality_summary": + target = target[0] + target[key] = value + with pytest.raises(ValueError): + check_quality(changed, expected)