diff --git a/.agents/plugins/marketplace.json b/.agents/plugins/marketplace.json new file mode 100644 index 00000000..dc549b4f --- /dev/null +++ b/.agents/plugins/marketplace.json @@ -0,0 +1,20 @@ +{ + "name": "nvidia-official", + "interface": { + "displayName": "NVIDIA Official" + }, + "plugins": [ + { + "name": "nvidia-skills", + "source": { + "source": "local", + "path": "./plugins/nvidia-skills" + }, + "policy": { + "installation": "AVAILABLE", + "authentication": "ON_INSTALL" + }, + "category": "Developer Tools" + } + ] +} diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json new file mode 100644 index 00000000..829a6030 --- /dev/null +++ b/.claude-plugin/marketplace.json @@ -0,0 +1,18 @@ +{ + "name": "nvidia-official", + "owner": { + "name": "NVIDIA", + "url": "https://github.com/NVIDIA/skills" + }, + "metadata": { + "description": "NVIDIA plugin marketplace — install the curated NVIDIA plugins and skills from this catalog repo.", + "version": "1.0.0" + }, + "plugins": [ + { + "name": "nvidia-skills", + "source": "./plugins/nvidia-skills", + "description": "Build with NVIDIA agent skills." + } + ] +} diff --git a/.github/scripts/build-plugins.py b/.github/scripts/build-plugins.py new file mode 100755 index 00000000..ebe7bdcf --- /dev/null +++ b/.github/scripts/build-plugins.py @@ -0,0 +1,613 @@ +#!/usr/bin/env python3 +""" +Build plugin packages from plugins.d/ and per-plugin .skills-manifest.yml files. + +Inputs (hand-maintained): + plugins.d/_defaults.yml + Shared default fields applied to every catalog plugin (author, license, + homepage, brand color, policy URLs, etc.). Per-plugin yaml fields + override these. Filenames starting with `_` are treated as includes and + are never built into a plugin themselves. + + plugins.d/.yml + Catalog plugin spec. Drives full regeneration of plugins// + (skills/ tree, .claude-plugin/plugin.json, .codex-plugin/plugin.json) + and its entry in both marketplace.json files. + + plugins//.skills-manifest.yml + Per-plugin skill manifest for hand-curated plugins. Only the skills/ + tree is rebuilt; plugin.jsons, assets, README, and the marketplace + entry stay hand-edited. + + plugins//assets/ Hand-maintained logo/image assets. + plugins//README.md Optional plugin-specific notes. + +Generated outputs (committed): + plugins//skills// Real dir or symlink (see below) + plugins//.claude-plugin/plugin.json (catalog plugins only) + plugins//.codex-plugin/plugin.json (catalog plugins only) + .claude-plugin/marketplace.json (catalog plugin entries; others preserved) + .agents/plugins/marketplace.json (catalog plugin entries; others preserved) + +How the skills/ tree gets populated is selected by `skill_files:` in +plugins.d/.yml (defaults to `copy` via plugins.d/_defaults.yml): + + copy rsync each curated skill into plugins//skills//. + Real files. Required for `codex plugin add` (Codex 0.132 + silently drops symlinks during install). + symlink Relative symlink plugins//skills/ → + ../../../skills//. No duplicated SKILL.md; + the plugin tree stays in sync with the canonical catalog + automatically. Works for `claude plugin install` and + `npx skills add`. NOT compatible with Codex local install. + +Usage: + build-plugins.py Build everything. + build-plugins.py --check Build, then fail if the working tree changed + (CI drift guard). + build-plugins.py --only NAME Restrict to a single plugin name. +""" +from __future__ import annotations + +import argparse +import json +import os +import re +import shutil +import subprocess +import sys +from pathlib import Path +from typing import Any + +import yaml + +REPO_ROOT = Path(__file__).resolve().parents[2] +PLUGINS_D = REPO_ROOT / "plugins.d" +PLUGINS_D_DEFAULTS = PLUGINS_D / "_defaults.yml" +PLUGINS_DIR = REPO_ROOT / "plugins" +SKILLS_DIR = REPO_ROOT / "skills" +CLAUDE_MARKETPLACE = REPO_ROOT / ".claude-plugin" / "marketplace.json" +AGENTS_MARKETPLACE = REPO_ROOT / ".agents" / "plugins" / "marketplace.json" + +# Default policy block written for every plugin entry in +# .agents/plugins/marketplace.json. Mirrors the existing convention. +AGENTS_PLUGIN_POLICY = { + "installation": "AVAILABLE", + "authentication": "ON_INSTALL", +} + + +# ---------------------------- helpers ---------------------------------------- + + +def log(msg: str) -> None: + print(msg, flush=True) + + +def die(msg: str, code: int = 1) -> None: + print(f"error: {msg}", file=sys.stderr, flush=True) + sys.exit(code) + + +def error(msg: str) -> None: + """Like die() but does not exit. For recoverable per-item failures + that should be loud in logs but not block the rest of the build.""" + print(f"error: {msg}", file=sys.stderr, flush=True) + + +def read_yaml(path: Path) -> dict[str, Any]: + """Strict YAML read — dies on parse error or non-mapping root. + Use for files whose absence/corruption is structural (e.g. + plugins.d/_defaults.yml). For per-plugin yaml files, prefer + read_yaml_lenient so one bad file does not block the rest.""" + with path.open() as f: + data = yaml.safe_load(f) + if not isinstance(data, dict): + die(f"{path}: expected a YAML mapping at top level") + return data + + +def read_yaml_lenient(path: Path) -> dict[str, Any] | None: + """Soft YAML read — returns None on parse error or non-mapping root, + logs an error to stderr. Caller decides whether to skip the file.""" + try: + with path.open() as f: + data = yaml.safe_load(f) + except yaml.YAMLError as e: + error(f"{path}: YAML parse error: {e}") + return None + if not isinstance(data, dict): + error( + f"{path}: expected a YAML mapping at top level, got " + f"{type(data).__name__}" + ) + return None + return data + + +def read_json(path: Path) -> Any: + with path.open() as f: + return json.load(f) + + +def write_json(path: Path, data: Any) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + with path.open("w", encoding="utf-8") as f: + json.dump(data, f, indent=4, ensure_ascii=False) + f.write("\n") + + +def make_relative_symlink(target: Path, link: Path) -> None: + """Create a symlink at `link` pointing at `target`, using a path relative + to `link`'s parent directory so the link survives repo relocation.""" + link.parent.mkdir(parents=True, exist_ok=True) + if link.is_symlink() or link.exists(): + link.unlink() + rel = os.path.relpath(target, link.parent) + os.symlink(rel, link, target_is_directory=True) + + +def expand_skill_paths(entries: list[str]) -> list[tuple[str, Path]]: + """ + Expand each entry into a list of (skill_basename, absolute_source_path). + + - "skills/cuopt/cuopt-install/" → [("cuopt-install", REPO/skills/cuopt/cuopt-install)] + - "skills/cuopt/" → all immediate children of skills/cuopt that contain SKILL.md + + Soft-fails any entry that would otherwise abort the build because of an + upstream catalog change (rename, removal, compliance-driven SKILL.md + drop, basename collision). The plugin ships with whatever curated + skills DID resolve, the warnings are surfaced in stdout, and the daily + sync PR is not blocked by curation drift in plugins.d/.yml. + Hard config errors (bad YAML, invalid plugin name, etc.) still die. + """ + out: list[tuple[str, Path]] = [] + for entry in entries: + rel = entry.rstrip("/") + src = (REPO_ROOT / rel).resolve() + if not src.exists(): + log( + f" ! warning: include_skills entry missing on disk, skipping: {entry} " + f"(upstream rename/removal? update plugins.d/.yml)" + ) + continue + if not src.is_dir(): + log( + f" ! warning: include_skills entry is not a directory, skipping: {entry}" + ) + continue + skill_md = src / "SKILL.md" + if skill_md.is_file(): + out.append((src.name, src)) + else: + children = sorted(p for p in src.iterdir() if p.is_dir()) + found = 0 + for child in children: + if (child / "SKILL.md").is_file(): + out.append((child.name, child)) + found += 1 + if found == 0: + log( + f" ! warning: no SKILL.md under {entry}, skipping " + f"(compliance enforcement may have dropped every skill here)" + ) + seen: dict[str, Path] = {} + deduped: list[tuple[str, Path]] = [] + for name, src in out: + if name in seen and seen[name] != src: + log( + f" ! warning: duplicate skill basename {name!r} across " + f"include_skills, keeping first: {seen[name]} (dropping {src})" + ) + continue + seen[name] = src + deduped.append((name, src)) + return deduped + + +VALID_MATERIALIZATIONS = ("copy", "symlink") + + +def rsync_dir(src: Path, dst: Path) -> None: + """rsync -a --delete src/ dst/ ; src must exist as a directory.""" + if not src.is_dir(): + die(f"source is not a directory: {src}") + dst.mkdir(parents=True, exist_ok=True) + subprocess.run( + ["rsync", "-a", "--delete", f"{src}/", f"{dst}/"], + check=True, + ) + + +def materialize_skills( + plugin_name: str, + entries: list[str], + mode: str = "copy", +) -> list[str]: + """Replace plugins//skills/ with the curated subset. Returns skill names. + + `mode` selects materialization strategy: + - "copy" rsync each skill into plugins//skills//. + Real files. Larger repo. Required for Codex local-install + (codex plugin add silently drops symlinks). + - "symlink" relative symlinks under plugins//skills/ → + ../../../skills//. No duplicate SKILL.md. + Works for Claude install and `npx skills add`. Currently + NOT supported by Codex local marketplace install. + """ + if mode not in VALID_MATERIALIZATIONS: + log( + f" ! warning: plugin {plugin_name!r}: invalid skill_files={mode!r}, " + f"falling back to 'copy' (allowed: {', '.join(VALID_MATERIALIZATIONS)})" + ) + mode = "copy" + plugin_dir = PLUGINS_DIR / plugin_name + target = plugin_dir / "skills" + if target.is_symlink() or target.exists(): + if target.is_symlink(): + target.unlink() + else: + shutil.rmtree(target) + target.mkdir(parents=True) + + pairs = expand_skill_paths(entries) + names: list[str] = [] + for name, src in pairs: + dst = target / name + if mode == "symlink": + make_relative_symlink(src, dst) + else: # copy + rsync_dir(src, dst) + names.append(name) + if mode == "symlink": + word = "symlink" if len(names) == 1 else "symlinks" + else: + word = "copy" if len(names) == 1 else "copies" + log(f" ✓ skills/ ({len(names)} {word})") + return names + + +# ---------------------------- catalog plugin --------------------------------- + + +def render_claude_plugin_json(spec: dict[str, Any]) -> dict[str, Any]: + out: dict[str, Any] = { + "name": spec["name"], + "version": str(spec.get("version", "1.0.0")), + "description": spec["description"], + } + if "display_name" in spec: + out["displayName"] = spec["display_name"] + if "author" in spec: + out["author"] = spec["author"] + if "homepage" in spec: + out["homepage"] = spec["homepage"] + if "repository" in spec: + out["repository"] = spec["repository"] + if "license" in spec: + out["license"] = spec["license"] + if "keywords" in spec: + out["keywords"] = list(spec["keywords"]) + # Skills tree is always inside the plugin (Codex rejects ".." paths, + # Anthropic spec requires "./" prefixes). Container path; Claude scans + # immediate children for SKILL.md. + out["skills"] = ["./skills/"] + return out + + +def render_codex_plugin_json(spec: dict[str, Any]) -> dict[str, Any]: + out: dict[str, Any] = { + "name": spec["name"], + "version": str(spec.get("version", "1.0.0")), + "description": spec["description"], + } + if "author" in spec: + out["author"] = spec["author"] + if "homepage" in spec: + out["homepage"] = spec["homepage"] + if "repository" in spec: + out["repository"] = spec["repository"] + if "license" in spec: + out["license"] = spec["license"] + if "keywords" in spec: + out["keywords"] = list(spec["keywords"]) + + # Skills tree is always inside the plugin (Codex rejects ".." paths). + out["skills"] = "./skills/" + + interface: dict[str, Any] = {} + if "display_name" in spec: + interface["displayName"] = spec["display_name"] + if "short_description" in spec: + interface["shortDescription"] = spec["short_description"] + if "long_description" in spec: + interface["longDescription"] = spec["long_description"] + if "author" in spec and "name" in spec["author"]: + interface["developerName"] = spec["author"]["name"] + if "category" in spec: + interface["category"] = spec["category"] + if "capabilities" in spec: + interface["capabilities"] = list(spec["capabilities"]) + for src_key, dst_key in ( + ("website_url", "websiteURL"), + ("privacy_policy_url", "privacyPolicyURL"), + ("terms_of_service_url", "termsOfServiceURL"), + ): + value = spec.get(src_key) + if value is None or value == "": + continue + interface[dst_key] = value + if "logo" in spec: + interface["logo"] = spec["logo"] + if "composer_icon" in spec: + interface["composerIcon"] = spec["composer_icon"] + if "screenshots" in spec: + interface["screenshots"] = list(spec["screenshots"]) + if "brand_color" in spec: + interface["brandColor"] = spec["brand_color"] + if "default_prompts" in spec: + interface["defaultPrompt"] = list(spec["default_prompts"]) + if interface: + out["interface"] = interface + return out + + +def build_catalog_plugin(spec: dict[str, Any]) -> str: + # `name` is already validated for kebab-case + uniqueness in discover() + # before specs reach this function. + name = spec["name"] + plugin_dir = PLUGINS_DIR / name + plugin_dir.mkdir(parents=True, exist_ok=True) + log(f"── catalog plugin: {name} ──") + + mode = spec.get("skill_files", "copy") + materialize_skills(name, spec.get("include_skills", []), mode=mode) + + write_json(plugin_dir / ".claude-plugin" / "plugin.json", render_claude_plugin_json(spec)) + log(" ✓ .claude-plugin/plugin.json") + write_json(plugin_dir / ".codex-plugin" / "plugin.json", render_codex_plugin_json(spec)) + log(" ✓ .codex-plugin/plugin.json") + + asset_fields = ["logo", "composer_icon"] + asset_paths: list[str] = [spec[f] for f in asset_fields if isinstance(spec.get(f), str)] + asset_paths += [s for s in (spec.get("screenshots") or []) if isinstance(s, str)] + for asset in asset_paths: + if not asset.startswith("./"): + continue + rel = asset[2:] + path = plugin_dir / rel + if not path.is_file(): + log(f" ! warning: asset declared but missing on disk: {path.relative_to(REPO_ROOT)}") + + return name + + +# ---------------------------- curated plugin --------------------------------- + + +def build_curated_plugin(plugin_dir: Path) -> str | None: + """ + A curated plugin is one with plugins//.skills-manifest.yml but + no plugins.d/.yml. We rebuild only its skills/ tree (mode + selected by `skill_files:` in the manifest, default `copy`) and + trust everything else to be hand-maintained. + + Returns the plugin name on success, or None if we skipped the build + due to a malformed manifest. The marketplace upsert preserves the + plugin's existing entry verbatim either way. + """ + manifest_path = plugin_dir / ".skills-manifest.yml" + name = plugin_dir.name + spec = read_yaml_lenient(manifest_path) + if spec is None: + error( + f" ! skipping curated plugin {name!r} — " + f"{manifest_path.relative_to(REPO_ROOT)} is unreadable; " + f"existing plugins/{name}/skills/ left untouched" + ) + return None + log(f"── curated plugin: {name} ──") + skills = spec.get("skills") or [] + if not skills: + log( + f" ! warning: {manifest_path.relative_to(REPO_ROOT)} has empty " + f"'skills' list; producing empty plugins/{name}/skills/" + ) + mode = spec.get("skill_files", "copy") + materialize_skills(name, skills, mode=mode) + return name + + +# ---------------------------- marketplaces ----------------------------------- + + +def is_marketplace_enabled(spec: dict[str, Any], marketplace_key: str) -> bool: + flags = spec.get("marketplace_enabled") or {} + return bool(flags.get(marketplace_key, True)) + + +def upsert_claude_marketplace( + catalog_specs: dict[str, dict[str, Any]], + curated_names: set[str], +) -> None: + if not CLAUDE_MARKETPLACE.is_file(): + die(f"missing {CLAUDE_MARKETPLACE.relative_to(REPO_ROOT)}") + data = read_json(CLAUDE_MARKETPLACE) + existing = data.get("plugins", []) + managed = set(catalog_specs.keys()) + + new_plugins: list[dict[str, Any]] = [] + for entry in existing: + name = entry.get("name") + if name in managed: + continue + if name in curated_names: + new_plugins.append(entry) + for name in sorted(catalog_specs): + spec = catalog_specs[name] + if not is_marketplace_enabled(spec, "claude"): + continue + new_plugins.append({ + "name": name, + "source": f"./plugins/{name}", + "description": spec["description"], + }) + new_plugins.sort(key=lambda p: p.get("name", "")) + data["plugins"] = new_plugins + write_json(CLAUDE_MARKETPLACE, data) + log(f" ✓ {CLAUDE_MARKETPLACE.relative_to(REPO_ROOT)} ({len(new_plugins)} plugin(s))") + + +def upsert_agents_marketplace( + catalog_specs: dict[str, dict[str, Any]], + curated_names: set[str], +) -> None: + if not AGENTS_MARKETPLACE.is_file(): + die(f"missing {AGENTS_MARKETPLACE.relative_to(REPO_ROOT)}") + data = read_json(AGENTS_MARKETPLACE) + existing = data.get("plugins", []) + managed = set(catalog_specs.keys()) + + new_plugins: list[dict[str, Any]] = [] + for entry in existing: + name = entry.get("name") + if name in managed: + continue + if name in curated_names: + new_plugins.append(entry) + for name in sorted(catalog_specs): + spec = catalog_specs[name] + if not is_marketplace_enabled(spec, "codex"): + continue + new_plugins.append({ + "name": name, + "source": {"source": "local", "path": f"./plugins/{name}"}, + "policy": dict(AGENTS_PLUGIN_POLICY), + "category": spec.get("category", "Developer Tools"), + }) + new_plugins.sort(key=lambda p: p.get("name", "")) + data["plugins"] = new_plugins + write_json(AGENTS_MARKETPLACE, data) + log(f" ✓ {AGENTS_MARKETPLACE.relative_to(REPO_ROOT)} ({len(new_plugins)} plugin(s))") + + +# ---------------------------- main ------------------------------------------- + + +def merge_with_defaults(defaults: dict[str, Any], plugin: dict[str, Any]) -> dict[str, Any]: + merged = dict(defaults) + merged.update(plugin) + return merged + + +def discover() -> tuple[dict[str, dict[str, Any]], list[Path]]: + # _defaults.yml is structural (every plugin merges from it); a parse + # failure there makes downstream merges meaningless, so keep strict. + defaults: dict[str, Any] = {} + if PLUGINS_D_DEFAULTS.is_file(): + defaults = read_yaml(PLUGINS_D_DEFAULTS) + + # Per-plugin yaml files are validated leniently: one bad/duplicate/ + # unnamed file logs an error and gets skipped; the rest of the + # catalog still builds. + catalog: dict[str, dict[str, Any]] = {} + if PLUGINS_D.is_dir(): + for ymlfile in sorted(PLUGINS_D.glob("*.yml")): + if ymlfile.name.startswith("_"): + continue + rel = ymlfile.relative_to(REPO_ROOT) + plugin_spec = read_yaml_lenient(ymlfile) + if plugin_spec is None: + error(f" ! skipping {rel} — YAML errors above") + continue + spec = merge_with_defaults(defaults, plugin_spec) + name = spec.get("name") + if not name: + error(f"{rel}: missing 'name', skipping") + continue + if not re.fullmatch(r"[a-z0-9][a-z0-9-]*", name): + error( + f"{rel}: plugin name {name!r} is not lowercase " + f"kebab-case, skipping" + ) + continue + if name in catalog: + first = catalog[name].get("__source", "?") + error( + f"{rel}: duplicate plugin name {name!r} (already " + f"declared in {first}), skipping" + ) + continue + spec["__source"] = str(rel) + catalog[name] = spec + + curated: list[Path] = [] + if PLUGINS_DIR.is_dir(): + for plugin_dir in sorted(PLUGINS_DIR.iterdir()): + if not plugin_dir.is_dir(): + continue + if plugin_dir.name in catalog: + continue + if (plugin_dir / ".skills-manifest.yml").is_file(): + curated.append(plugin_dir) + return catalog, curated + + +def main(argv: list[str]) -> int: + p = argparse.ArgumentParser(description="Build NVIDIA skills plugins.") + p.add_argument("--only", help="Only build the named plugin.") + p.add_argument( + "--check", + action="store_true", + help="After building, fail if the working tree changed (CI drift guard).", + ) + args = p.parse_args(argv) + + catalog, curated = discover() + if args.only: + catalog = {k: v for k, v in catalog.items() if k == args.only} + curated = [d for d in curated if d.name == args.only] + if not catalog and not curated: + die(f"no plugin named '{args.only}' found in plugins.d/ or plugins/") + + log(f"Found {len(catalog)} catalog plugin(s) and {len(curated)} curated plugin(s).") + + for name in sorted(catalog): + build_catalog_plugin(catalog[name]) + for plugin_dir in curated: + build_curated_plugin(plugin_dir) + + log("── marketplaces ──") + curated_names = {d.name for d in curated} + upsert_claude_marketplace(catalog, curated_names) + upsert_agents_marketplace(catalog, curated_names) + + if args.check: + log("── drift check ──") + result = subprocess.run( + [ + "git", + "status", + "--porcelain", + "plugins/", + ".claude-plugin/marketplace.json", + ".agents/plugins/marketplace.json", + ], + cwd=REPO_ROOT, + capture_output=True, + text=True, + ) + if result.stdout.strip(): + print(result.stdout, file=sys.stderr) + die( + "plugin tree drifted from sources; " + "run .github/scripts/build-plugins.sh and commit the result" + ) + log(" ✓ no drift") + + log("done.") + return 0 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/.github/scripts/build-plugins.sh b/.github/scripts/build-plugins.sh new file mode 100755 index 00000000..9952daed --- /dev/null +++ b/.github/scripts/build-plugins.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Wrapper around build-plugins.py that ensures PyYAML is importable. +# Forwards all arguments to the Python script. +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +if ! python3 -c "import yaml" 2>/dev/null; then + echo "PyYAML not found; installing for the current user..." >&2 + if pip3 install --user pyyaml >/dev/null 2>&1; then + : + elif pip3 install --user --break-system-packages pyyaml >/dev/null 2>&1; then + : + else + echo "error: failed to install PyYAML; install it manually (pip install pyyaml) and re-run." >&2 + exit 1 + fi +fi + +exec python3 "$SCRIPT_DIR/build-plugins.py" "$@" diff --git a/.github/workflows/sync-skills.yml b/.github/workflows/sync-skills.yml index a4d59711..545076d8 100644 --- a/.github/workflows/sync-skills.yml +++ b/.github/workflows/sync-skills.yml @@ -255,6 +255,31 @@ jobs: echo "Opened new tracking issue" fi + - name: Rebuild plugin catalog + run: | + set -euo pipefail + # plugins//skills/ in copy mode duplicates content from + # the canonical skills/ tree, so any sync that touched a + # curated source path leaves those copies stale. Re-run the + # plugin build here so the same sync PR ships a consistent + # tree (skills/ + plugins/) and validate-plugins.yml --check + # stays green. Symlink-mode plugins are a no-op for the build. + # build-plugins.py soft-fails missing/dropped curated skills + # so a rename or compliance drop does NOT block the sync PR. + .github/scripts/build-plugins.sh + + # Mark the plugin catalog as a changed component if anything + # under plugins/ or either marketplace.json moved, so the PR + # summary surfaces it and the "has_changes" gate fires even + # when the only diff is the auto-rebuild. + if ! git diff --quiet plugins/ \ + .claude-plugin/marketplace.json \ + .agents/plugins/marketplace.json; then + if ! grep -qx "- plugin catalog" /tmp/changed-components.txt 2>/dev/null; then + echo "- plugin catalog" >> /tmp/changed-components.txt + fi + fi + - name: Regenerate README tables run: .github/scripts/regenerate-readme.sh diff --git a/.github/workflows/validate-plugins.yml b/.github/workflows/validate-plugins.yml new file mode 100644 index 00000000..0e701cd6 --- /dev/null +++ b/.github/workflows/validate-plugins.yml @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 NVIDIA Corporation. All rights reserved. +# +# Validate that the generated plugin tree matches plugins.d/ + skills/. +# +# Runs `build-plugins.sh --check`, which rebuilds into the working tree +# and fails if anything drifts. The cron-driven sync workflow rebuilds +# plugins automatically; this workflow just guards against contributor +# PRs that hand-edit a generated file or forget to re-run the build. + +name: Validate Plugins + +on: + pull_request: + paths: + - "plugins.d/**" + - "skills/**" + - "plugins/**" + - ".claude-plugin/marketplace.json" + - ".agents/plugins/marketplace.json" + - ".github/scripts/build-plugins.*" + - ".github/workflows/validate-plugins.yml" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: validate-plugins-${{ github.ref }} + cancel-in-progress: true + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Install PyYAML + run: pip install pyyaml + + - name: Build plugins and fail on drift + run: .github/scripts/build-plugins.sh --check + + # TODO: add upstream CLI validation as a follow-up step. + # + # Claude side (ready to enable when we want it): + # - name: Install Claude Code CLI + # run: npm install -g @anthropic-ai/claude-code@2.1.145 + # - name: claude plugin validate + # run: | + # set -e + # for d in plugins/*/; do claude plugin validate "$d"; done + # claude plugin validate .claude-plugin/marketplace.json + # # Verified locally on 2026-05-21 against claude 2.1.145; all + # # four plugin manifests + .claude-plugin/marketplace.json pass. + # # Do NOT pass .agents/plugins/marketplace.json — that is the + # # Codex marketplace and uses a different schema. + # + # Codex side: the codex CLI has no `plugin validate` subcommand + # (only add/list/marketplace/remove). Three options if we decide we + # want CLI-level coverage: + # 1. Install-as-validator dry-run: `codex plugin marketplace add + # ./.agents/plugins/marketplace.json` then `codex plugin add + # ` for each generated plugin. Real install on the + # runner; ephemeral so side effects are fine. + # 2. Hand-roll a JSON schema check (jsonschema in Python) derived + # from upstream openai/plugins samples. + # 3. Skip — rely on the build script's schema parity and the + # drift check above. + # Deferred for now to keep this workflow lean; revisit if we hit a + # schema mismatch in the wild. diff --git a/plugins.d/README.md b/plugins.d/README.md new file mode 100644 index 00000000..885a55b5 --- /dev/null +++ b/plugins.d/README.md @@ -0,0 +1,68 @@ +# `plugins.d/` — plugin catalog source + +Each `.yml` here defines one plugin. The build script +[`.github/scripts/build-plugins.py`](../.github/scripts/build-plugins.py) +parses these files and (re)generates: + +- `plugins//.claude-plugin/plugin.json` +- `plugins//.codex-plugin/plugin.json` +- `plugins//skills//`  **symlinks** into the canonical `skills/` catalog +- `.claude-plugin/marketplace.json` (top-level Claude marketplace registry) +- `.agents/plugins/marketplace.json` (top-level Codex marketplace registry) + +Files whose names start with `_` are treated as includes and are not +themselves built into plugins. `_defaults.yml` provides shared author / +license / capability defaults; per-plugin yaml fields override the defaults +(shallow merge). + +## Source of truth + +The `skills/` directory is the single source of truth — every SKILL.md +exists exactly once there. The plugin tree under `plugins/` is reconstructed +from these YAML files on every build, so adding/removing a curated skill +only requires editing the `include_skills:` list and re-running: + +```sh +.github/scripts/build-plugins.sh +``` + +## `skill_files:` — copy vs symlink + +Each plugin selects what kind of files end up under +`plugins//skills/`: + +| Mode | What's on disk | Use when | +|---|---|---| +| `copy` (default) | real files (rsync) | publishing to Codex / Anthropic; required for `codex plugin add` (Codex drops symlinks during install) | +| `symlink` | relative symlinks → `../../../skills//` | shipping to Claude only or to `npx skills add` consumers; avoids duplication | + +The default lives in [`_defaults.yml`](./_defaults.yml); override per +plugin by setting `skill_files: symlink` (or `copy`) in +`plugins.d/.yml`. + +## Adding a plugin + +1. Create `plugins.d/.yml` with at minimum: + + ```yaml + name: # lowercase kebab-case, must match the file basename + description: ... # one-line summary + display_name: ... + short_description: ... + long_description: ... + category: Developer Tools + include_skills: + - skills/// + ``` + +2. Run `.github/scripts/build-plugins.sh`. +3. Commit the regenerated `plugins//` tree and the updated + `marketplace.json` files alongside the new yaml. + +## Curated (hand-maintained) plugins + +A directory under `plugins//` that has its own +`.skills-manifest.yml` instead of a `plugins.d/.yml` is treated as +a curated plugin: the build script only refreshes its `skills/` symlinks +and otherwise leaves `.claude-plugin/`, `.codex-plugin/`, `assets/`, and +the marketplace entries hand-edited. diff --git a/plugins.d/_defaults.yml b/plugins.d/_defaults.yml new file mode 100644 index 00000000..fc8dc51d --- /dev/null +++ b/plugins.d/_defaults.yml @@ -0,0 +1,50 @@ +# Default fields applied to every plugins.d/.yml. +# +# - Anything declared in a per-plugin yaml WINS over the defaults below. +# - Merge is shallow: nested mappings (like `author:`) are replaced wholesale, +# not field-by-field. If you set `author:` in a plugin yaml, supply both +# `name:` and `url:`. +# +# Files starting with `_` are treated as include files by build-plugins.py +# and are NOT themselves built into a plugin. + +version: "1.0.0" + +author: + name: NVIDIA + url: https://github.com/NVIDIA/skills + +homepage: https://github.com/NVIDIA/skills +repository: https://github.com/NVIDIA/skills +license: Apache-2.0 AND CC-BY-4.0 + +# interface.websiteURL is omitted by default — duplicates `homepage` for +# plugins that don't have a distinct product/marketing page. Set it per +# plugin only when there is a real landing page to link to. +# website_url: https://github.com/NVIDIA/skills + +# Privacy policy / Terms of service URLs are only required when a plugin +# actually collects user data or imposes plugin-specific terms. Leave them +# unset by default; uncomment and override per plugin when applicable. +# privacy_policy_url: https://www.nvidia.com/en-us/about-nvidia/privacy-center/ +# terms_of_service_url: https://developer.nvidia.com/legal/terms + +brand_color: "#76b900" + +capabilities: + - Interactive + - Write + +# Marketplace publishing flags default to true. To opt a plugin out of one +# or both self-hosted marketplaces, set marketplace_enabled.{claude,codex}: false +# in that plugin's yaml. + +# How `include_skills` show up on disk under plugins//skills/. +# copy - rsync each skill into the plugin tree. Real files. Required +# for Codex local-marketplace install (codex plugin add +# silently drops symlinks). Default. +# symlink - relative symlinks pointing back at the canonical skills/ +# tree. No duplicated SKILL.md. Works for Claude install and +# `npx skills add`; NOT compatible with Codex local install. +# Override per-plugin in plugins.d/.yml when needed. +skill_files: copy diff --git a/plugins.d/nvidia-skills.yml b/plugins.d/nvidia-skills.yml new file mode 100644 index 00000000..58c91c3e --- /dev/null +++ b/plugins.d/nvidia-skills.yml @@ -0,0 +1,38 @@ +name: nvidia-skills + +description: Build with NVIDIA agent skills. + +display_name: NVIDIA +short_description: Provide agentic guidance in your NVIDIA related workflows. +long_description: A curated plugin bundling verified skills to provide guidance in your NVIDIA related workflows. + +category: Developer Tools +logo: ./assets/nvidia.png +composer_icon: ./assets/nvidia.png +# screenshots: [] # optional; supply ./assets/*.png paths when we have any + +keywords: + - nvidia + - agent-skills + - gpu + +default_prompts: + - "Solve an optimization problem with cuOpt." + - "Deploy or debug an NVIDIA RAG Blueprint." + - "Search a video archive with VSS." + +# Curated subset of skills from the canonical ./skills/ catalog. +# Reproduced under plugins//skills// in the form +# selected by `skill_files:` (defined in plugins.d/_defaults.yml). +include_skills: + - skills/cuopt/cuopt-routing-api-python/ + - skills/cuopt/cuopt-user-rules/ + +# Inherits from plugins.d/_defaults.yml: +# version, author, homepage, repository, license, +# brand_color, capabilities + +# By default this plugin is added (true) in both self-hosted marketplace.json files. Uncomment to opt out. +# marketplace_enabled: +# claude: false +# codex: false diff --git a/plugins/nvidia-skills/.claude-plugin/plugin.json b/plugins/nvidia-skills/.claude-plugin/plugin.json new file mode 100644 index 00000000..657774ab --- /dev/null +++ b/plugins/nvidia-skills/.claude-plugin/plugin.json @@ -0,0 +1,21 @@ +{ + "name": "nvidia-skills", + "version": "1.0.0", + "description": "Build with NVIDIA agent skills.", + "displayName": "NVIDIA", + "author": { + "name": "NVIDIA", + "url": "https://github.com/NVIDIA/skills" + }, + "homepage": "https://github.com/NVIDIA/skills", + "repository": "https://github.com/NVIDIA/skills", + "license": "Apache-2.0 AND CC-BY-4.0", + "keywords": [ + "nvidia", + "agent-skills", + "gpu" + ], + "skills": [ + "./skills/" + ] +} diff --git a/plugins/nvidia-skills/.codex-plugin/plugin.json b/plugins/nvidia-skills/.codex-plugin/plugin.json new file mode 100644 index 00000000..16a59bde --- /dev/null +++ b/plugins/nvidia-skills/.codex-plugin/plugin.json @@ -0,0 +1,37 @@ +{ + "name": "nvidia-skills", + "version": "1.0.0", + "description": "Build with NVIDIA agent skills.", + "author": { + "name": "NVIDIA", + "url": "https://github.com/NVIDIA/skills" + }, + "homepage": "https://github.com/NVIDIA/skills", + "repository": "https://github.com/NVIDIA/skills", + "license": "Apache-2.0 AND CC-BY-4.0", + "keywords": [ + "nvidia", + "agent-skills", + "gpu" + ], + "skills": "./skills/", + "interface": { + "displayName": "NVIDIA", + "shortDescription": "Provide agentic guidance in your NVIDIA related workflows.", + "longDescription": "A curated plugin bundling verified skills to provide guidance in your NVIDIA related workflows.", + "developerName": "NVIDIA", + "category": "Developer Tools", + "capabilities": [ + "Interactive", + "Write" + ], + "logo": "./assets/nvidia.png", + "composerIcon": "./assets/nvidia.png", + "brandColor": "#76b900", + "defaultPrompt": [ + "Solve an optimization problem with cuOpt.", + "Deploy or debug an NVIDIA RAG Blueprint.", + "Search a video archive with VSS." + ] + } +} diff --git a/plugins/nvidia-skills/README.md b/plugins/nvidia-skills/README.md new file mode 100644 index 00000000..95d5bd7d --- /dev/null +++ b/plugins/nvidia-skills/README.md @@ -0,0 +1,7 @@ +# Official NVIDIA Plugin + +This plugin is **not** part of the `nvidia/skills` self-hosted marketplace. It is curated for delivery to the official OpenAI Bundled and Anthropic Official marketplaces. + +The contents here (skills, plugin manifests) are generated from `plugins.d/nvidia.yml` by `.github/scripts/build-plugins.sh`. The yaml sets `marketplace_enabled.{claude,codex}: false`, which keeps it out of `.claude-plugin/marketplace.json` and `.agents/plugins/marketplace.json` while still producing a self-contained plugin folder ready to ship upstream. + +To change which skills this plugin bundles, edit `plugins.d/nvidia.yml` and re-run the build script. Hand-maintained inside this directory: `assets/` (logo) and this README. diff --git a/plugins/nvidia-skills/assets/nvidia.png b/plugins/nvidia-skills/assets/nvidia.png new file mode 100644 index 00000000..e7165f5d Binary files /dev/null and b/plugins/nvidia-skills/assets/nvidia.png differ diff --git a/plugins/nvidia-skills/skills/cuopt-routing-api-python/SKILL.md b/plugins/nvidia-skills/skills/cuopt-routing-api-python/SKILL.md new file mode 100644 index 00000000..a8bc2393 --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-routing-api-python/SKILL.md @@ -0,0 +1,103 @@ +--- +name: cuopt-routing-api-python +version: "26.08.00" +description: Vehicle routing (VRP, TSP, PDP) with cuOpt — Python API only. Use when the user is building or solving routing in Python. +--- + + +# cuOpt Routing — Python API + +Confirm problem type (TSP, VRP, PDP) and data (locations, orders, fleet, constraints) before coding. + +This skill is **Python only**. Routing has no C API in cuOpt. + +## Minimal VRP Example + +```python +import cudf +from cuopt import routing + +cost_matrix = cudf.DataFrame([...], dtype="float32") +dm = routing.DataModel(n_locations=4, n_fleet=2, n_orders=3) +dm.add_cost_matrix(cost_matrix) +dm.set_order_locations(cudf.Series([1, 2, 3], dtype="int32")) +solution = routing.Solve(dm, routing.SolverSettings()) + +if solution.get_status() == 0: + solution.display_routes() +``` + +## Adding Constraints + +```python +# Time windows +dm.add_transit_time_matrix(transit_time_matrix) +dm.set_order_time_windows(earliest_series, latest_series) + +# Capacities +dm.add_capacity_dimension("weight", demand_series, capacity_series) +dm.set_order_service_times(service_times) +dm.set_vehicle_locations(start_locations, end_locations) +dm.set_vehicle_time_windows(earliest_start, latest_return) + +# Pickup-delivery pairs +dm.set_pickup_delivery_pairs(pickup_indices, delivery_indices) + +# Precedence +dm.add_order_precedence(node_id=2, preceding_nodes=np.array([0, 1])) +``` + +## Solution Checking + +```python +status = solution.get_status() # 0=SUCCESS, 1=FAIL, 2=TIMEOUT, 3=EMPTY +if status == 0: + route_df = solution.get_route() + total_cost = solution.get_total_objective() +else: + print(solution.get_error_message()) + print(solution.get_infeasible_orders().to_list()) +``` + +## Data Types (use explicit dtypes) + +```python +cost_matrix = cost_matrix.astype("float32") +order_locations = cudf.Series([...], dtype="int32") +demand = cudf.Series([...], dtype="int32") +``` + +## Solver Settings + +```python +ss = routing.SolverSettings() +ss.set_time_limit(30) +ss.set_verbose_mode(True) +ss.set_error_logging_mode(True) +``` + +## Common Issues + +| Problem | Fix | +|---------|-----| +| Empty solution | Widen time windows or check travel times | +| Infeasible orders | Increase fleet or capacity | +| Status != 0 with time windows | Add `add_transit_time_matrix()` | +| Wrong cost | Check cost_matrix is symmetric | +| `compute_waypoint_sequence` alters route_df | It replaces the `location` column with waypoint ids in place — pass `route_df.copy()` if you still need cost-matrix indices (e.g. when iterating per truck) | + +## Debugging + +**When status != 0:** `print(solution.get_error_message())` and `print(solution.get_infeasible_orders().to_list())` to see which orders are infeasible. + +**Data types:** Use explicit dtypes (float32, int32) for matrices and series to avoid silent errors. + +## Examples + +- [examples.md](resources/examples.md) — VRP, PDP, multi-depot +- [server_examples.md](resources/server_examples.md) — REST client (curl, Python) +- **Reference models:** This skill's `assets/` — [vrp_basic](assets/vrp_basic/), [pdp_basic](assets/pdp_basic/). See [assets/README.md](assets/README.md). + +## Escalate + +For contribution or build-from-source, see the developer skill. diff --git a/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/README.md b/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/README.md new file mode 100644 index 00000000..6b7a8091 --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/README.md @@ -0,0 +1,10 @@ +# Assets — reference routing models + +Routing reference implementations (Python). Use as reference when building new applications; do not edit in place. + +| Model | Type | Description | +|-------|------|-------------| +| [vrp_basic](vrp_basic/) | VRP | Minimal VRP: 4 locations, 1 vehicle, 3 orders | +| [pdp_basic](pdp_basic/) | PDP | Pickup-delivery pairs, capacity dimension | + +**Run:** From each subdir, `python model.py` (requires cuOpt and cudf). See [resources/examples.md](../resources/examples.md) for more patterns (time windows, multi-depot). diff --git a/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/pdp_basic/README.md b/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/pdp_basic/README.md new file mode 100644 index 00000000..64e345bb --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/pdp_basic/README.md @@ -0,0 +1,7 @@ +# Pickup-Delivery (PDP) + +2 pickup-delivery pairs (4 orders), 2 vehicles. Pickup must occur before delivery; capacity dimension. + +**Run:** `python model.py` + +**See also:** [resources/examples.md](../../resources/examples.md) for more PDP and VRP patterns. diff --git a/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/pdp_basic/model.py b/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/pdp_basic/model.py new file mode 100644 index 00000000..d85ec532 --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/pdp_basic/model.py @@ -0,0 +1,56 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +""" +PDP: 2 pickup-delivery pairs, 2 vehicles. Pickup before delivery; capacity dimension. +""" + +import cudf +from cuopt import routing + +cost_matrix = cudf.DataFrame( + [ + [0, 10, 20, 30, 40], + [10, 0, 15, 25, 35], + [20, 15, 0, 10, 20], + [30, 25, 10, 0, 15], + [40, 35, 20, 15, 0], + ], + dtype="float32", +) + +transit_time_matrix = cost_matrix.copy(deep=True) +n_fleet = 2 +n_orders = 4 + +order_locations = cudf.Series([1, 2, 3, 4], dtype="int32") +pickup_indices = cudf.Series([0, 2]) +delivery_indices = cudf.Series([1, 3]) +demand = cudf.Series([10, -10, 15, -15], dtype="int32") +vehicle_capacity = cudf.Series([50, 50], dtype="int32") + +dm = routing.DataModel( + n_locations=cost_matrix.shape[0], + n_fleet=n_fleet, + n_orders=n_orders, +) +dm.add_cost_matrix(cost_matrix) +dm.add_transit_time_matrix(transit_time_matrix) +dm.set_order_locations(order_locations) +dm.add_capacity_dimension("load", demand, vehicle_capacity) +dm.set_pickup_delivery_pairs(pickup_indices, delivery_indices) +dm.set_vehicle_locations( + cudf.Series([0, 0], dtype="int32"), + cudf.Series([0, 0], dtype="int32"), +) + +ss = routing.SolverSettings() +ss.set_time_limit(10) +solution = routing.Solve(dm, ss) + +print(f"Status: {solution.get_status()}") +if solution.get_status() == 0: + solution.display_routes() + print(f"Total cost: {solution.get_total_objective()}") +else: + print(solution.get_error_message()) diff --git a/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/vrp_basic/README.md b/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/vrp_basic/README.md new file mode 100644 index 00000000..cdb28902 --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/vrp_basic/README.md @@ -0,0 +1,7 @@ +# Minimal VRP + +4 locations (depot 0 + 3 customers), 1 vehicle, 3 orders. Cost matrix only; no time windows or capacity. + +**Run:** `python model.py` + +**See also:** [resources/examples.md](../../resources/examples.md) for VRP with time windows, capacity, and multi-depot. diff --git a/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/vrp_basic/model.py b/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/vrp_basic/model.py new file mode 100644 index 00000000..165f6afc --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-routing-api-python/assets/vrp_basic/model.py @@ -0,0 +1,31 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +""" +Minimal VRP: 4 locations, 1 vehicle, 3 orders. Cost matrix only. +""" + +import cudf +from cuopt import routing + +cost_matrix = cudf.DataFrame( + [ + [0, 10, 15, 20], + [10, 0, 12, 18], + [15, 12, 0, 10], + [20, 18, 10, 0], + ], + dtype="float32", +) + +dm = routing.DataModel(n_locations=4, n_fleet=1, n_orders=3) +dm.add_cost_matrix(cost_matrix) +dm.set_order_locations(cudf.Series([1, 2, 3], dtype="int32")) + +solution = routing.Solve(dm, routing.SolverSettings()) + +if solution.get_status() == 0: + solution.display_routes() + print(f"Total cost: {solution.get_total_objective()}") +else: + print(f"Status: {solution.get_status()}", solution.get_error_message()) diff --git a/plugins/nvidia-skills/skills/cuopt-routing-api-python/resources/examples.md b/plugins/nvidia-skills/skills/cuopt-routing-api-python/resources/examples.md new file mode 100644 index 00000000..ee402bb3 --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-routing-api-python/resources/examples.md @@ -0,0 +1,249 @@ +# Routing: Python API Examples + +## VRP with Time Windows & Capacities + +```python +""" +Vehicle Routing Problem with: +- 1 depot (location 0) +- 5 customer locations (1-5) +- 2 vehicles with capacity 100 each +- Time windows for each location +- Demand at each customer +""" +import cudf +from cuopt import routing + +# Cost/distance matrix (6x6: depot + 5 customers) +cost_matrix = cudf.DataFrame([ + [0, 10, 15, 20, 25, 30], # From depot + [10, 0, 12, 18, 22, 28], # From customer 1 + [15, 12, 0, 10, 15, 20], # From customer 2 + [20, 18, 10, 0, 8, 15], # From customer 3 + [25, 22, 15, 8, 0, 10], # From customer 4 + [30, 28, 20, 15, 10, 0], # From customer 5 +], dtype="float32") + +# Also use as transit time matrix (same values for simplicity) +transit_time_matrix = cost_matrix.copy(deep=True) + +# Order data (customers 1-5) +order_locations = cudf.Series([1, 2, 3, 4, 5], dtype="int32") # Location indices for orders + +# Demand at each customer (single capacity dimension) +demand = cudf.Series([20, 30, 25, 15, 35], dtype="int32") + +# Vehicle capacities (must match demand dimensions) +vehicle_capacity = cudf.Series([100, 100], dtype="int32") + +# Time windows for orders [earliest, latest] +order_earliest = cudf.Series([0, 10, 20, 0, 30], dtype="int32") +order_latest = cudf.Series([50, 60, 70, 80, 90], dtype="int32") + +# Service time at each customer +service_times = cudf.Series([5, 5, 5, 5, 5], dtype="int32") + +# Fleet configuration +n_fleet = 2 + +# Vehicle start/end locations (both start and return to depot) +vehicle_start = cudf.Series([0, 0], dtype="int32") +vehicle_end = cudf.Series([0, 0], dtype="int32") + +# Vehicle time windows (operating hours) +vehicle_earliest = cudf.Series([0, 0], dtype="int32") +vehicle_latest = cudf.Series([200, 200], dtype="int32") + +# Build the data model +dm = routing.DataModel( + n_locations=cost_matrix.shape[0], + n_fleet=n_fleet, + n_orders=len(order_locations) +) + +# Add matrices +dm.add_cost_matrix(cost_matrix) +dm.add_transit_time_matrix(transit_time_matrix) + +# Add order data +dm.set_order_locations(order_locations) +dm.set_order_time_windows(order_earliest, order_latest) +dm.set_order_service_times(service_times) + +# Add capacity dimension (name, demand_per_order, capacity_per_vehicle) +dm.add_capacity_dimension("weight", demand, vehicle_capacity) + +# Add fleet data +dm.set_vehicle_locations(vehicle_start, vehicle_end) +dm.set_vehicle_time_windows(vehicle_earliest, vehicle_latest) + +# Configure solver +ss = routing.SolverSettings() +ss.set_time_limit(10) # seconds + +# Solve +solution = routing.Solve(dm, ss) + +# Check solution status +print(f"Status: {solution.get_status()}") + +# Display routes +if solution.get_status() == 0: # Success + print("\n--- Solution Found ---") + solution.display_routes() + + # Get detailed route data + route_df = solution.get_route() + print("\nDetailed route data:") + print(route_df) + + # Get objective value (total cost) + print(f"\nTotal cost: {solution.get_total_objective()}") +else: + print("No feasible solution found (status != 0).") +``` + +## Pickup and Delivery Problem (PDP) + +```python +""" +Pickup and Delivery Problem: +- Items must be picked up from one location and delivered to another +- Same vehicle must do both pickup and delivery +- Pickup must occur before delivery +""" +import cudf +from cuopt import routing + +# Cost matrix (depot + 4 locations) +cost_matrix = cudf.DataFrame([ + [0, 10, 20, 30, 40], + [10, 0, 15, 25, 35], + [20, 15, 0, 10, 20], + [30, 25, 10, 0, 15], + [40, 35, 20, 15, 0], +], dtype="float32") + +transit_time_matrix = cost_matrix.copy(deep=True) + +n_fleet = 2 +n_orders = 4 # 2 pickup-delivery pairs = 4 orders + +# Orders: pickup at loc 1 -> deliver at loc 2, pickup at loc 3 -> deliver at loc 4 +order_locations = cudf.Series([1, 2, 3, 4], dtype="int32") + +# Pickup and delivery pairs (indices into order array) +# Order 0 (pickup) pairs with Order 1 (delivery) +# Order 2 (pickup) pairs with Order 3 (delivery) +pickup_indices = cudf.Series([0, 2]) +delivery_indices = cudf.Series([1, 3]) + +# Demand: positive for pickup, negative for delivery (must sum to 0 per pair) +demand = cudf.Series([10, -10, 15, -15], dtype="int32") +vehicle_capacity = cudf.Series([50, 50], dtype="int32") + +# Build model +dm = routing.DataModel( + n_locations=cost_matrix.shape[0], + n_fleet=n_fleet, + n_orders=n_orders +) + +dm.add_cost_matrix(cost_matrix) +dm.add_transit_time_matrix(transit_time_matrix) +dm.set_order_locations(order_locations) + +# Add capacity dimension +dm.add_capacity_dimension("load", demand, vehicle_capacity) + +# Set pickup and delivery constraints +dm.set_pickup_delivery_pairs(pickup_indices, delivery_indices) + +# Fleet setup +dm.set_vehicle_locations( + cudf.Series([0, 0]), # Start at depot + cudf.Series([0, 0]) # Return to depot +) + +# Solve +ss = routing.SolverSettings() +ss.set_time_limit(10) +solution = routing.Solve(dm, ss) + +print(f"Status: {solution.get_status()}") +if solution.get_status() == 0: + solution.display_routes() +``` + +## Minimal VRP (Quick Start) + +```python +import cudf +from cuopt import routing + +# Minimal 4-location problem +cost_matrix = cudf.DataFrame([ + [0, 10, 15, 20], + [10, 0, 12, 18], + [15, 12, 0, 10], + [20, 18, 10, 0], +], dtype="float32") + +dm = routing.DataModel(n_locations=4, n_fleet=1, n_orders=3) +dm.add_cost_matrix(cost_matrix) +dm.set_order_locations(cudf.Series([1, 2, 3], dtype="int32")) + +solution = routing.Solve(dm, routing.SolverSettings()) + +if solution.get_status() == 0: + solution.display_routes() +``` + +## Multi-Depot VRP + +```python +import cudf +from cuopt import routing + +# 6 locations: 2 depots (0, 1) + 4 customers (2, 3, 4, 5) +cost_matrix = cudf.DataFrame([ + [0, 5, 10, 15, 20, 25], + [5, 0, 12, 8, 18, 22], + [10, 12, 0, 6, 14, 16], + [15, 8, 6, 0, 10, 12], + [20, 18, 14, 10, 0, 8], + [25, 22, 16, 12, 8, 0], +], dtype="float32") + +n_fleet = 2 + +dm = routing.DataModel(n_locations=6, n_fleet=n_fleet, n_orders=4) +dm.add_cost_matrix(cost_matrix) +dm.set_order_locations(cudf.Series([2, 3, 4, 5], dtype="int32")) + +# Vehicle 0 starts/ends at depot 0, Vehicle 1 at depot 1 +dm.set_vehicle_locations( + cudf.Series([0, 1]), # start locations + cudf.Series([0, 1]) # end locations +) + +solution = routing.Solve(dm, routing.SolverSettings()) +if solution.get_status() == 0: + solution.display_routes() +``` + +--- + +## Additional References (tested in CI) + +For more complete examples, read these files: + +| Example | File | Description | +|---------|------|-------------| +| Basic Routing | `docs/cuopt/source/cuopt-server/examples/routing/examples/basic_routing_example.py` | Server-based routing | +| Initial Solution | `docs/cuopt/source/cuopt-server/examples/routing/examples/initial_solution_example.py` | Warm starting | +| Smoke Test | `docs/cuopt/source/cuopt-python/routing/examples/smoke_test_example.sh` | Quick validation | + +These examples are tested by CI and represent canonical usage. + +**Note:** The Python routing API documentation is in `python/cuopt/cuopt/routing/vehicle_routing.py` (docstrings). diff --git a/plugins/nvidia-skills/skills/cuopt-routing-api-python/resources/server_examples.md b/plugins/nvidia-skills/skills/cuopt-routing-api-python/resources/server_examples.md new file mode 100644 index 00000000..06d03dbe --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-routing-api-python/resources/server_examples.md @@ -0,0 +1,204 @@ +# Routing: REST Server Examples + +## Start the Server + +```bash +# Start server +python -m cuopt_server.cuopt_service --ip 0.0.0.0 --port 8000 & + +# Wait and verify +sleep 5 +curl -s http://localhost:8000/cuopt/health +``` + +## Basic VRP (curl) + +```bash +REQID=$(curl -s -X POST "http://localhost:8000/cuopt/request" \ + -H "Content-Type: application/json" \ + -H "CLIENT-VERSION: custom" \ + -d '{ + "cost_matrix_data": { + "data": {"0": [[0,10,15,20],[10,0,12,18],[15,12,0,10],[20,18,10,0]]} + }, + "travel_time_matrix_data": { + "data": {"0": [[0,10,15,20],[10,0,12,18],[15,12,0,10],[20,18,10,0]]} + }, + "task_data": { + "task_locations": [1, 2, 3], + "demand": [[10, 15, 20]], + "task_time_windows": [[0, 100], [10, 80], [20, 90]], + "service_times": [5, 5, 5] + }, + "fleet_data": { + "vehicle_locations": [[0, 0], [0, 0]], + "capacities": [[50, 50]], + "vehicle_time_windows": [[0, 200], [0, 200]] + }, + "solver_config": { + "time_limit": 5 + } + }' | jq -r '.reqId') + +echo "Request ID: $REQID" + +# Poll for solution +sleep 2 +curl -s "http://localhost:8000/cuopt/solution/$REQID" \ + -H "Content-Type: application/json" \ + -H "CLIENT-VERSION: custom" | jq . +``` + +## VRP with Time Windows (Python requests) + +```python +import requests +import time + +SERVER = "http://localhost:8000" +HEADERS = {"Content-Type": "application/json", "CLIENT-VERSION": "custom"} + +payload = { + "cost_matrix_data": { + "data": { + "0": [ + [0, 10, 15, 20, 25], + [10, 0, 12, 18, 22], + [15, 12, 0, 10, 15], + [20, 18, 10, 0, 8], + [25, 22, 15, 8, 0] + ] + } + }, + "travel_time_matrix_data": { + "data": { + "0": [ + [0, 10, 15, 20, 25], + [10, 0, 12, 18, 22], + [15, 12, 0, 10, 15], + [20, 18, 10, 0, 8], + [25, 22, 15, 8, 0] + ] + } + }, + "task_data": { + "task_locations": [1, 2, 3, 4], + "demand": [[20, 30, 25, 15]], + "task_time_windows": [[0, 50], [10, 60], [20, 70], [0, 80]], + "service_times": [5, 5, 5, 5] + }, + "fleet_data": { + "vehicle_locations": [[0, 0], [0, 0]], + "capacities": [[100, 100]], + "vehicle_time_windows": [[0, 200], [0, 200]] + }, + "solver_config": { + "time_limit": 10 + } +} + +# Submit request +response = requests.post(f"{SERVER}/cuopt/request", json=payload, headers=HEADERS) +response.raise_for_status() +req_id = response.json()["reqId"] +print(f"Request submitted: {req_id}") + +# Poll for solution +for attempt in range(30): + response = requests.get(f"{SERVER}/cuopt/solution/{req_id}", headers=HEADERS) + result = response.json() + + if "response" in result: + solver_response = result["response"].get("solver_response", {}) + print(f"\nSolution found!") + print(f"Status: {solver_response.get('status', 'N/A')}") + print(f"Cost: {solver_response.get('solution_cost', 'N/A')}") + + if "vehicle_data" in solver_response: + for vid, vdata in solver_response["vehicle_data"].items(): + route = vdata.get("route", []) + print(f"Vehicle {vid}: {' -> '.join(map(str, route))}") + break + else: + print(f"Waiting... (attempt {attempt + 1})") + time.sleep(1) +``` + +## Pickup and Delivery (curl) + +```bash +REQID=$(curl -s -X POST "http://localhost:8000/cuopt/request" \ + -H "Content-Type: application/json" \ + -H "CLIENT-VERSION: custom" \ + -d '{ + "cost_matrix_data": { + "data": {"0": [[0,10,20,30,40],[10,0,15,25,35],[20,15,0,10,20],[30,25,10,0,15],[40,35,20,15,0]]} + }, + "travel_time_matrix_data": { + "data": {"0": [[0,10,20,30,40],[10,0,15,25,35],[20,15,0,10,20],[30,25,10,0,15],[40,35,20,15,0]]} + }, + "task_data": { + "task_locations": [1, 2, 3, 4], + "demand": [[10, -10, 15, -15]], + "pickup_and_delivery_pairs": [[0, 1], [2, 3]] + }, + "fleet_data": { + "vehicle_locations": [[0, 0]], + "capacities": [[50]] + }, + "solver_config": { + "time_limit": 10 + } + }' | jq -r '.reqId') + +echo "Request ID: $REQID" + +# Poll for solution +sleep 2 +curl -s "http://localhost:8000/cuopt/solution/$REQID" \ + -H "Content-Type: application/json" \ + -H "CLIENT-VERSION: custom" | jq . +``` + +## Terminology Reference + +| Python API | REST Server API | +|------------|-----------------| +| `order_locations` | `task_locations` | +| `set_order_time_windows()` | `task_time_windows` | +| `set_order_service_times()` | `service_times` | +| `add_transit_time_matrix()` | `travel_time_matrix_data` | +| `set_pickup_delivery_pairs()` | `pickup_and_delivery_pairs` | + +## Common Payload Mistakes + +```json +// ❌ WRONG field name +"transit_time_matrix_data": {...} + +// ✅ CORRECT +"travel_time_matrix_data": {...} +``` + +```json +// ❌ WRONG capacity format (per vehicle) +"capacities": [[50], [50]] + +// ✅ CORRECT (per dimension across vehicles) +"capacities": [[50, 50]] +``` + +--- + +## Additional References (tested in CI) + +For more complete examples, read these files: + +| Example | File | Description | +|---------|------|-------------| +| Basic Routing (Python) | `docs/cuopt/source/cuopt-server/examples/routing/examples/basic_routing_example.py` | VRP via REST | +| Basic Routing (curl) | `docs/cuopt/source/cuopt-server/examples/routing/examples/basic_routing_example.sh` | Shell script | +| Initial Solution | `docs/cuopt/source/cuopt-server/examples/routing/examples/initial_solution_example.py` | Warm starting | +| Initial Solution (curl) | `docs/cuopt/source/cuopt-server/examples/routing/examples/initial_solution_example.sh` | Warm start shell | + +These examples are tested by CI (`ci/test_doc_examples.sh`) and represent canonical usage. diff --git a/plugins/nvidia-skills/skills/cuopt-routing-api-python/skill-card.md b/plugins/nvidia-skills/skills/cuopt-routing-api-python/skill-card.md new file mode 100644 index 00000000..69ece75f --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-routing-api-python/skill-card.md @@ -0,0 +1,38 @@ +## Description:
+Vehicle routing (VRP, TSP, PDP) with cuOpt — Python API only. Use when the user is building or solving routing in Python.
+ +This skill is ready for commercial/non-commercial use.
+ +## Owner: NVIDIA
+ +### License/Terms of Use:
+Apache 2.0
+## Use Case:
+Developers and engineers building or solving vehicle routing problems (VRP, TSP, PDP) using the NVIDIA cuOpt Python API for GPU-accelerated optimization.
+ +### Deployment Geography for Use:
+Global
+ +## Known Risks and Mitigations:
+Risk: Review before execution as proposals could introduce incorrect or misleading guidance into skills.
+Mitigation: Review and scan skill before deployment.
+ +## Reference(s):
+- [cuOpt User Guide](https://docs.nvidia.com/cuopt/user-guide/latest/introduction.html)
+- [cuOpt Examples Repository](https://github.com/NVIDIA/cuopt-examples)
+ + +## Skill Output:
+**Output Type(s):** [Code, API Calls, Configuration instructions]
+**Output Format:** [Markdown with inline Python code blocks]
+**Output Parameters:** [1D]
+**Other Properties Related to Output:** [None]
+ +## Skill Version(s):
+26.06.00 (source: frontmatter)
+ +## Ethical Considerations:
+NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal team to ensure this skill meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
+ +(For Release on NVIDIA Platforms Only)
+Please report quality, risk, security vulnerabilities or NVIDIA AI Concerns [here](https://app.intigriti.com/programs/nvidia/nvidiavdp/detail).
diff --git a/plugins/nvidia-skills/skills/cuopt-routing-api-python/skill.oms.sig b/plugins/nvidia-skills/skills/cuopt-routing-api-python/skill.oms.sig new file mode 100644 index 00000000..ef91a123 --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-routing-api-python/skill.oms.sig @@ -0,0 +1 @@ +{"mediaType":"application/vnd.dev.sigstore.bundle.v0.3+json","verificationMaterial":{"x509CertificateChain":{"certificates":[{"rawBytes":"MIICgzCCAgmgAwIBAgIUKIyS7SxNteQIiWzK1dWj85E6520wCgYIKoZIzj0EAwMwVTELMAkGA1UEBhMCVVMxGzAZBgNVBAoMEk5WSURJQSBDb3Jwb3JhdGlvbjEpMCcGA1UEAwwgTlZJRElBIEFnZW50IENhcGFiaWxpdGllcyBJQ0EgMDEwHhcNMjYwNDAxMDAwMDAwWhcNMjgwNDIyMTUzMzA5WjBUMQswCQYDVQQGEwJVUzEbMBkGA1UECgwSTlZJRElBIENvcnBvcmF0aW9uMSgwJgYDVQQDDB9OVklESUEgQWdlbnQgU2tpbGxzIFNpZ25pbmcgMDAxMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEYoRM9bQl/dGlwSRNi6bTpIJUXH8Nv9GciP6LSflJYYMLCc296kpyuTSsk5ddbAWiDcFX3C/ydX3jwc+qCLYP6uHy9XphyLjOQ27Yb2J6rBLVtRBS1mgGco/Gr7fL6ODco4GaMIGXMB0GA1UdDgQWBBRQ/5ZW3nJ6lmo9SVk7I15o7UGmpTAfBgNVHSMEGDAWgBRPGpILxMBBleJSsBGjrMKsby1CgjAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQEAwIHgDA3BggrBgEFBQcBAQQrMCkwJwYIKwYBBQUHMAGGG2h0dHA6Ly9vY3NwLm5kaXMubnZpZGlhLmNvbTAKBggqhkjOPQQDAwNoADBlAjAUygu/GiOCIXrgGr4SmLgeEVDcEitfFUv7ALbvLVGVyMysB3mxmO/uInZfXzWcJZsCMQDxuoxj4ZmO30jhkPIcCxGFCOvnUsnfU3TfGcouYm4M6iRpbKvtVnHPiy4bi6pcKf0="},{"rawBytes":"MIICiDCCAg6gAwIBAgIUZs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iwKICAgICAgICAiLmdpdGF0dHJpYnV0ZXMiLAogICAgICAgICIuZ2l0aHViIgogICAgICBdLAogICAgICAibWV0aG9kIjogImZpbGVzIiwKICAgICAgImFsbG93X3N5bWxpbmtzIjogZmFsc2UKICAgIH0KICB9Cn0=","payloadType":"application/vnd.in-toto+json","signatures":[{"sig":"MGUCMQCcGZqaSXabbjPR8wp86n7/8am2Wf1/VojZaXO9mP2ZiizEDj3f2BC38yJq4Ft1Iu8CMAORDnqPrWpHhermkTL/X7I8cJtd3F8k8G9fsxxrS+Ucn6JKiEFMMHU68esX8gZSrg==","keyid":""}]}} \ No newline at end of file diff --git a/plugins/nvidia-skills/skills/cuopt-user-rules/SKILL.md b/plugins/nvidia-skills/skills/cuopt-user-rules/SKILL.md new file mode 100644 index 00000000..47ce33a4 --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-user-rules/SKILL.md @@ -0,0 +1,222 @@ +--- +name: cuopt-user-rules +version: "26.08.00" +description: Base rules for end users calling NVIDIA cuOpt (routing/LP/MILP/QP/install/server). Not for cuOpt internals — use cuopt-developer for those. +--- + + +# cuOpt User Rules + +**Read this when helping someone *use* cuOpt** (calling the SDK, installing, deploying the server). For modifying cuOpt itself, switch to `cuopt-developer`. + +--- + +## Ask Before Assuming + +**Always clarify ambiguous requirements before implementing:** + +- What **language/interface**? +- What problem type? +- What constraints matter? +- What output format? + +**Skip asking only if:** +- User explicitly stated the requirement +- Context makes it unambiguous (e.g., user shows Python code) + +--- + +## Handle Incomplete Questions + +**If a question seems partial or incomplete, ask follow-up questions:** + +- "Could you tell me more about [missing detail]?" +- "What specifically would you like to achieve with this?" +- "Are there any constraints or requirements I should know about?" + +**Common missing information to probe for:** +- Problem size (number of vehicles, locations, variables, constraints) +- Specific constraints (time windows, capacities, precedence) +- Performance requirements (time limits, solution quality) +- Integration context (existing codebase, deployment environment) + +**Don't guess — ask.** A brief clarifying question saves time vs. solving the wrong problem. + +--- + +## Clarify Data Requirements + +**Before generating examples, ask about data:** + +1. **Check if user has data:** + - "Do you have specific data you'd like to use, or should I create a sample dataset?" + - "Can you share the format of your input data?" + +2. **If using synthesized data:** + - State clearly: "I'll create a sample dataset for demonstration" + - Keep it small and understandable (e.g., 5-10 locations, 2-3 vehicles) + - Make values realistic and meaningful + +3. **Always document what you used:** + ``` + "For this example I'm using: + - [X] locations/variables/constraints + - [Key assumptions: e.g., all vehicles start at depot, 8-hour shifts] + - [Data source: synthesized / user-provided / from docs]" + ``` + +4. **State assumptions explicitly:** + - "I'm assuming [X] — let me know if this differs from your scenario" + - List any default values or simplifications made + +--- + +## MUST Verify Understanding + +**Before writing substantial code, you MUST confirm your understanding:** + +``` +"Let me confirm I understand: +- Problem: [restate in your words] +- Constraints: [list them] +- Objective: [minimize/maximize what] +- Interface: [Python/REST/C/CLI] +Is this correct?" +``` + +--- + +## Follow Requirements Exactly + +- Use the **exact** variable names, formats, and structures the user specifies +- Don't add features the user didn't ask for +- Don't change the problem formulation unless asked +- If user provides partial code, extend it—don't rewrite from scratch + +--- + +## Check Results + +After providing a solution, guide the user to verify: + +- **Status check**: Is it `Optimal` / `FeasibleFound` / `SUCCESS`? +- **Constraint satisfaction**: Are all constraints met? +- **Objective value**: Is it reasonable for the problem? + +**Always end with a Result summary** that includes at least: +- Solver status (e.g. Optimal, FeasibleFound, SUCCESS). +- **Objective value with highlight** — easy to spot (bold or code block). Example: **Objective value (min total cost):** <value> or `Objective value: `. +- Briefly what the objective represents (e.g. total cost, total profit). + +Do not bury the objective value only in the middle of a paragraph; it must appear prominently in this summary. Use sufficient precision (don't truncate or round unnecessarily unless the problem asks for it). + +**Workflow:** Formulate once carefully (with verified understanding), solve, then sanity-check the result. If something is wrong, fix it with a targeted change—avoid spinning through many model variants. Decide, implement, verify, then move on. + +Provide diagnostic code snippets when helpful. + +### Post-correction check (mandatory) +If the result required a correction, retry, or workaround to reach this point, you MUST evaluate the skill-evolution workflow (`skills/skill-evolution/SKILL.md`) before moving on. Do not skip this step. + +--- + +## Check Environment First + +**Before writing code or suggesting installation, verify the user's setup:** + +1. **Ask how they access cuOpt:** + - "Do you have cuOpt installed? If so, which interface?" + - "What environment are you using? (local GPU, cloud, Docker, server, etc.)" + +2. **Different packages by language/interface:** + + | Language / Interface | Package | Check | + |----------------------|---------|-------| + | **Python** | `cuopt` (pip/conda) — also pulls in `libcuopt` | `import cuopt` | + | **C** | `libcuopt` (pip/conda) — already present if `cuopt` is installed | `find libcuopt.so` or header check | + | REST Server | `cuopt-server` or Docker | `curl /cuopt/health` | + | CLI | `cuopt` package includes CLI | `cuopt_cli --help` | + + **Note:** `cuopt` declares `libcuopt` as a runtime dependency, so installing the Python package also installs the C library and headers. Installing `libcuopt` on its own does **not** install the Python API. + +3. **If not installed, ask how they want to access:** + - "Would you like help installing cuOpt, or do you have access another way?" + - Options: pip, conda, Docker, cloud instance, existing remote server + +4. **Never assume installation is needed** — the user may: + - Already have it installed + - Be connecting to a remote server + - Prefer a specific installation method + - Only need the C library (not Python) + +5. **Ask before running any verification commands:** + ```python + # Python API check - ask first + import cuopt + print(cuopt.__version__) + ``` + ```bash + # C API check - ask first + find ${CONDA_PREFIX} -name "libcuopt.so" + ``` + ```bash + # Server check - ask first + curl http://localhost:8000/cuopt/health + ``` + +--- + +## Ask Before Running + +**Do not execute commands or code without explicit permission:** + +| Action | Rule | +|--------|------| +| Shell commands | Show command, explain what it does, ask "Should I run this?" | +| Package installs | **Never** run installs yourself — give the exact command, user runs it (see below). | +| Examples/scripts | Show the code first, ask "Would you like me to run this?" | +| File writes | Explain what will change, ask before writing | + +**Exceptions (okay without asking):** +- Read-only commands the user explicitly requested +- Commands the user just provided and asked you to run + +--- + +## No Privileged Operations + +**Never do these without explicit user request AND confirmation:** + +- Use `sudo` or run as root +- Modify system files or configurations +- Add package repositories or keys +- Change firewall, network, or driver settings +- Write files outside the workspace + +--- + +## Never Install Packages Automatically + +> **🔒 MANDATORY — You MUST NOT install, upgrade, or modify packages.** Provide the exact command; the user runs it. No exceptions. + +| Forbidden | What to do instead | +|-----------|--------------------| +| `pip install ...`, `conda install ...`, `apt install ...`, any package manager | Give the exact command and ask the user to run it. Say why the package is needed. | + +**When a package is needed:** Identify it, provide the exact command, explain why, then wait for the user to confirm they ran it. Even if the user says "just install it", give the command and require them to execute it themselves. + +--- + +## Resources + +### Documentation +- [cuOpt User Guide](https://docs.nvidia.com/cuopt/user-guide/latest/introduction.html) +- [API Reference](https://docs.nvidia.com/cuopt/user-guide/latest/api.html) + +### Examples +- [cuopt-examples repo](https://github.com/NVIDIA/cuopt-examples) +- [Google Colab notebooks](https://colab.research.google.com/github/nvidia/cuopt-examples/) + +### Support +- [File a Bug](https://github.com/NVIDIA/cuopt/issues/new?template=bug_report.md) +- [Ask a Question](https://github.com/NVIDIA/cuopt/issues/new?template=submit-question.md) +- [All Issues](https://github.com/NVIDIA/cuopt/issues) diff --git a/plugins/nvidia-skills/skills/cuopt-user-rules/skill-card.md b/plugins/nvidia-skills/skills/cuopt-user-rules/skill-card.md new file mode 100644 index 00000000..1a3212da --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-user-rules/skill-card.md @@ -0,0 +1,39 @@ +## Description:
+Base rules for end users calling NVIDIA cuOpt (routing/LP/MILP/QP/install/server). Not for cuOpt internals — use cuopt-developer for those.
+ +This skill is ready for commercial/non-commercial use.
+ +## Owner: NVIDIA
+ +### License/Terms of Use:
+Apache 2.0
+## Use Case:
+Developers and engineers who interact with cuOpt for optimization tasks use this skill to receive consistent, safe, and methodical guidance on installation, API usage, problem formulation, and result verification across all cuOpt interfaces.
+ +### Deployment Geography for Use:
+Global
+ +## Known Risks and Mitigations:
+Risk: Review before execution as proposals could introduce incorrect or misleading guidance into skills.
+Mitigation: Review and scan skill before deployment.
+ +## Reference(s):
+- [cuOpt User Guide](https://docs.nvidia.com/cuopt/user-guide/latest/introduction.html)
+- [cuOpt API Reference](https://docs.nvidia.com/cuopt/user-guide/latest/api.html)
+- [cuOpt Examples Repository](https://github.com/NVIDIA/cuopt-examples)
+ + +## Skill Output:
+**Output Type(s):** [Configuration instructions, Code, Shell commands]
+**Output Format:** [Markdown with inline code blocks]
+**Output Parameters:** [1D]
+**Other Properties Related to Output:** [None]
+ +## Skill Version(s):
+26.06.00 (source: frontmatter)
+ +## Ethical Considerations:
+NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal team to ensure this skill meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
+ +(For Release on NVIDIA Platforms Only)
+Please report quality, risk, security vulnerabilities or NVIDIA AI Concerns [here](https://app.intigriti.com/programs/nvidia/nvidiavdp/detail).
diff --git a/plugins/nvidia-skills/skills/cuopt-user-rules/skill.oms.sig b/plugins/nvidia-skills/skills/cuopt-user-rules/skill.oms.sig new file mode 100644 index 00000000..e8886de5 --- /dev/null +++ b/plugins/nvidia-skills/skills/cuopt-user-rules/skill.oms.sig @@ -0,0 +1 @@ +{"mediaType":"application/vnd.dev.sigstore.bundle.v0.3+json","verificationMaterial":{"x509CertificateChain":{"certificates":[{"rawBytes":"MIICgzCCAgmgAwIBAgIUKIyS7SxNteQIiWzK1dWj85E6520wCgYIKoZIzj0EAwMwVTELMAkGA1UEBhMCVVMxGzAZBgNVBAoMEk5WSURJQSBDb3Jwb3JhdGlvbjEpMCcGA1UEAwwgTlZJRElBIEFnZW50IENhcGFiaWxpdGllcyBJQ0EgMDEwHhcNMjYwNDAxMDAwMDAwWhcNMjgwNDIyMTUzMzA5WjBUMQswCQYDVQQGEwJVUzEbMBkGA1UECgwSTlZJRElBIENvcnBvcmF0aW9uMSgwJgYDVQQDDB9OVklESUEgQWdlbnQgU2tpbGxzIFNpZ25pbmcgMDAxMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEYoRM9bQl/dGlwSRNi6bTpIJUXH8Nv9GciP6LSflJYYMLCc296kpyuTSsk5ddbAWiDcFX3C/ydX3jwc+qCLYP6uHy9XphyLjOQ27Yb2J6rBLVt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ogICAgXQogIH0KfQ==","payloadType":"application/vnd.in-toto+json","signatures":[{"sig":"MGQCMDIjBmRHpcspsQ7/mEhz0qJSitSds+MN5Judmm28hW2/Dv35RN/+CwhoJ1iIRcCEpgIwGpgw2wwIBWcdWKaJ79Jy9JM1pzBXC0ajaGZJ/FKzP2gat3NDljl6ZFnzOxQnEieV","keyid":""}]}} \ No newline at end of file