✨ Add dioxus and project-uv plugins
Introduce two new plugins: dioxus and project-uv with metadata READMEs and SKILL documentation and example skill files Update marketplace.json to advertise both plugins
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
---
|
||||
name: project-uv
|
||||
description: Use whenever you are about to run, install, or modify Python code in a project whose root contains a `pyproject.toml` — especially before invoking `python`, `pip`, `uv run`, or any test/lint command. Detects how uv is wired up here (project vs script mode, lockfile, declared scripts, src/ layout, tool table) and tells you the right invocation pattern *for this repo* before you guess. Trigger words: "run this script", "install this dependency", "test", "sync", any mention of `uv`, `pip`, `python -m`, or running a `.py` file.
|
||||
---
|
||||
|
||||
# project-uv
|
||||
|
||||
The point of this skill is to **stop guessing how to run Python in this project**. `uv` supports several distinct workflows (project-managed, script-with-inline-deps, ad-hoc venv) and the right invocation differs accordingly. Probe first, then run.
|
||||
|
||||
## Activation
|
||||
|
||||
This skill applies when the current project root contains a `pyproject.toml`. If there is no `pyproject.toml`, this skill is not relevant — fall back to whatever Python tooling the user already established.
|
||||
|
||||
## Step 0: Probe the project
|
||||
|
||||
**MANDATORY FIRST STEP** when this skill is invoked for the first time in a conversation. Run the probe script:
|
||||
|
||||
```bash
|
||||
uv run --no-project python ${CLAUDE_PLUGIN_ROOT}/skills/project-uv/scripts/probe.py
|
||||
```
|
||||
|
||||
(Or copy `scripts/probe.py` and run it directly with any available Python — it has no dependencies.)
|
||||
|
||||
The probe prints a short structured report describing:
|
||||
|
||||
- whether `uv` is installed and its version
|
||||
- the project mode: managed project (`[project]` table) vs PEP 723 script mode vs neither
|
||||
- whether a `uv.lock` exists and is up to date
|
||||
- whether `[tool.uv]` is configured, with notable keys
|
||||
- declared scripts: `[project.scripts]` console entrypoints
|
||||
- src layout: presence of `src/`, top-level packages
|
||||
- presence of sibling tooling: `Justfile`, `Makefile`, `mise.toml`, `.python-version`
|
||||
|
||||
Treat the probe output as ground truth for the rest of the conversation. Don't re-probe unless files relevant to the probe have changed.
|
||||
|
||||
## Invocation rules of thumb
|
||||
|
||||
Once you know the project mode, apply these defaults:
|
||||
|
||||
**Managed project (`[project]` table present, optionally with `uv.lock`):**
|
||||
- Sync first if `uv.lock` is out of date or `.venv` is missing: `uv sync`
|
||||
- Run anything inside the env via `uv run`, e.g. `uv run pytest`, `uv run python -m mypkg.cli`
|
||||
- Add deps with `uv add <pkg>`, not `pip install`
|
||||
- Declared console scripts are runnable as `uv run <name>`
|
||||
|
||||
**PEP 723 inline-deps script:**
|
||||
- Run with `uv run path/to/script.py` — uv will install inline deps in an ephemeral env
|
||||
- Do not `uv add` to a non-project file; edit the `# /// script` block instead
|
||||
|
||||
**Neither (raw `pyproject.toml` with no `[project]` and no inline deps):**
|
||||
- The user probably has another build backend or only metadata. Ask before assuming.
|
||||
|
||||
## Composing with other tooling
|
||||
|
||||
If the probe shows a `Justfile` / `Makefile`, **prefer the recipe over the raw uv command** whenever a recipe exists for the task — that's the user's preferred entry point. Only fall through to raw `uv run` when no recipe covers it.
|
||||
|
||||
If the probe shows `mise.toml` and the agent has access to `mise`, defer to mise for tool versions (Python version in particular).
|
||||
|
||||
## What this skill does NOT do
|
||||
|
||||
- It does not install `uv` for the user. If uv is missing, report that and stop.
|
||||
- It does not modify `pyproject.toml`. Adding/removing deps is a separate, user-driven decision — surface the recommended command, let the user accept.
|
||||
- It does not pick a Python version. That's `.python-version` / `mise.toml` / `[tool.uv]` territory.
|
||||
|
||||
## Future granularity (pilot note)
|
||||
|
||||
This skill is intentionally narrow. Companion skills like `run-uv-with-just` are planned: they would activate only when both `pyproject.toml` and `Justfile` are present, and would teach the agent the just-recipe vocabulary in this specific repo. The granularity is meant to compose, not duplicate.
|
||||
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Probe a Python project to detect how uv is wired up.
|
||||
|
||||
Run from the project root (or pass --root). Output is a short structured
|
||||
report intended for an LLM agent to read before suggesting uv commands.
|
||||
|
||||
No third-party dependencies; stdlib only so it can run with `uv run --no-project`
|
||||
or any system Python.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
import tomllib # Python 3.11+
|
||||
except ModuleNotFoundError: # pragma: no cover
|
||||
import tomli as tomllib # type: ignore[no-redef]
|
||||
|
||||
|
||||
def detect_uv() -> tuple[bool, str | None]:
|
||||
uv = shutil.which("uv")
|
||||
if not uv:
|
||||
return False, None
|
||||
try:
|
||||
out = subprocess.run(
|
||||
[uv, "--version"], capture_output=True, text=True, timeout=5, check=False
|
||||
)
|
||||
return True, out.stdout.strip() or out.stderr.strip() or None
|
||||
except Exception:
|
||||
return True, None
|
||||
|
||||
|
||||
def load_pyproject(root: Path) -> dict | None:
|
||||
pp = root / "pyproject.toml"
|
||||
if not pp.exists():
|
||||
return None
|
||||
try:
|
||||
return tomllib.loads(pp.read_text(encoding="utf-8"))
|
||||
except Exception as e:
|
||||
print(f"WARN: failed to parse pyproject.toml: {e}", file=sys.stderr)
|
||||
return None
|
||||
|
||||
|
||||
def detect_pep723_scripts(root: Path) -> list[str]:
|
||||
hits: list[str] = []
|
||||
for py in root.glob("*.py"):
|
||||
try:
|
||||
head = py.read_text(encoding="utf-8", errors="replace")[:2000]
|
||||
except Exception:
|
||||
continue
|
||||
if "# /// script" in head:
|
||||
hits.append(py.name)
|
||||
return hits
|
||||
|
||||
|
||||
def main() -> int:
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--root", default=".", help="project root (default: cwd)")
|
||||
args = ap.parse_args()
|
||||
root = Path(args.root).resolve()
|
||||
|
||||
print(f"# project-uv probe")
|
||||
print(f"root: {root}")
|
||||
print()
|
||||
|
||||
uv_present, uv_version = detect_uv()
|
||||
print(f"uv installed: {uv_present}")
|
||||
if uv_version:
|
||||
print(f"uv version: {uv_version}")
|
||||
print()
|
||||
|
||||
pyproject = load_pyproject(root)
|
||||
has_pyproject = pyproject is not None
|
||||
print(f"pyproject.toml present: {has_pyproject}")
|
||||
|
||||
if not has_pyproject:
|
||||
scripts = detect_pep723_scripts(root)
|
||||
print(f"PEP 723 inline-dep scripts at root: {scripts or 'none'}")
|
||||
print("mode: no-pyproject (skill does not apply unless inline-dep scripts found)")
|
||||
return 0
|
||||
|
||||
assert pyproject is not None
|
||||
has_project = "project" in pyproject
|
||||
tool_uv = pyproject.get("tool", {}).get("uv")
|
||||
scripts_table = pyproject.get("project", {}).get("scripts", {}) if has_project else {}
|
||||
|
||||
print(f"[project] table: {has_project}")
|
||||
print(f"[tool.uv] table: {tool_uv is not None}")
|
||||
if tool_uv:
|
||||
notable = sorted(tool_uv.keys())
|
||||
print(f"[tool.uv] keys: {notable}")
|
||||
print()
|
||||
|
||||
lock = root / "uv.lock"
|
||||
venv = root / ".venv"
|
||||
print(f"uv.lock present: {lock.exists()}")
|
||||
print(f".venv present: {venv.exists()}")
|
||||
print()
|
||||
|
||||
if scripts_table:
|
||||
print("declared console scripts ([project.scripts]):")
|
||||
for name, target in scripts_table.items():
|
||||
print(f" {name} -> {target}")
|
||||
else:
|
||||
print("declared console scripts: none")
|
||||
print()
|
||||
|
||||
src = root / "src"
|
||||
print(f"src/ layout: {src.is_dir()}")
|
||||
if src.is_dir():
|
||||
pkgs = [p.name for p in src.iterdir() if p.is_dir() and (p / "__init__.py").exists()]
|
||||
print(f"src/ packages: {pkgs or 'none'}")
|
||||
else:
|
||||
top_pkgs = [
|
||||
p.name for p in root.iterdir()
|
||||
if p.is_dir() and (p / "__init__.py").exists() and not p.name.startswith(".")
|
||||
]
|
||||
print(f"top-level packages: {top_pkgs or 'none'}")
|
||||
print()
|
||||
|
||||
siblings = {
|
||||
"Justfile": (root / "Justfile").exists() or (root / "justfile").exists() or (root / ".justfile").exists(),
|
||||
"Makefile": (root / "Makefile").exists(),
|
||||
"mise.toml": (root / "mise.toml").exists() or (root / ".mise.toml").exists(),
|
||||
".python-version": (root / ".python-version").exists(),
|
||||
".env": (root / ".env").exists(),
|
||||
}
|
||||
print("sibling tooling:")
|
||||
for name, present in siblings.items():
|
||||
print(f" {name}: {present}")
|
||||
print()
|
||||
|
||||
if has_project and lock.exists():
|
||||
mode = "managed-project-locked"
|
||||
elif has_project:
|
||||
mode = "managed-project-unlocked"
|
||||
elif tool_uv is not None:
|
||||
mode = "uv-tool-only"
|
||||
else:
|
||||
mode = "metadata-only-or-other-backend"
|
||||
print(f"mode: {mode}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user