项目文件夹

文件
Seth Hobson 2d3f6a8527 chore: move toolchain to uv-native (no pip, no requirements.txt) (#543)
* chore: move toolchain to uv-native (no pip, no requirements.txt)

The repo previously mixed uv (for plugin-eval) with pip + requirements.txt
(for yt-design-extractor) and raw `python3` invocations in the Makefile and
CI workflows. This makes the toolchain uniformly uv-managed.

## yt-design-extractor

Moved `tools/yt-design-extractor.py` into `tools/yt-design-extractor/` with its
own `pyproject.toml` + `uv.lock`. EasyOCR (and its ~2 GB torch dependency)
becomes an optional extra (`uv sync --extra easyocr`). Deleted
`tools/requirements.txt`.

## Makefile

All targets now route through uv:
- `make install` / `make install-easyocr` / `make deps` / `make check` / `make run*`:
  `cd tools/yt-design-extractor && uv run/uv sync`
- `make generate` / `make validate` / `make garden` / `make clean-generated`:
  `uv run --project plugins/plugin-eval python tools/...` (reuses plugin-eval's
  venv — it already has pyyaml and `extra-paths = ["../.."]` for tools/adapters)
- `make test` / `make smoke-test`: `uv run --project plugins/plugin-eval pytest`

## CI

- `.github/workflows/validate.yml`:
  - `multi-harness-generate` swapped from `actions/setup-python@v5` to
    `astral-sh/setup-uv@v5` + `uv sync` of plugin-eval before `make generate-all`
  - Workflow-level `permissions: contents: read` + `persist-credentials: false`
    on every checkout (carrying the security hardening forward consistently)
- `.github/workflows/code-quality.yml`:
  - `json-lint` job swapped from `setup-python` to `setup-uv`
  - YAML validator now uses `uv run --with pyyaml python` (no pre-step install)
  - JSON/TOML validators use `uv run python` (stdlib `json.tool`, `tomllib`)
  - Dropped the standalone `pip install pyyaml --quiet` line

## Inline hints

- `plugins/plugin-eval/src/plugin_eval/layers/judge.py`: error message
  recommends `uv sync --extra llm` instead of `pip install plugin-eval[llm]`
- `tools/yt-design-extractor/yt-design-extractor.py`: usage docstring and
  install hints now reference `make install` / `make install-easyocr` / `uv run`

The pip refs inside plugin-authored commands (deps-audit.md, doc-generate.md,
error-trace.md) describe scanning **user** Python projects — those legitimately
use pip and are out of scope.

Local gates green: make test (385 pass), make garden (0 errors), make validate
clean, ruff + format + ty all pass, markdownlint clean.

* chore: address PR #543 review feedback

- checkmake (Makefile): consolidate the multi-line `.PHONY:` declaration
  onto a single line. The previous backslash-continued form was readable
  but checkmake couldn't parse it, falsely flagging `validate` and
  `clean-generated` as missing from .PHONY. They were already declared —
  just invisible to the linter.

Other CodeRabbit feedback declined:

- pyproject.toml dep version constraints (CodeRabbit self-tagged "Low value"):
  uv.lock pins exact versions for reproducibility; upper bounds on yt-dlp,
  Pillow, etc. would invite stale-pin churn without changing the locked
  installation. Tracking upstream aggressively is the right default for a
  utility tool.

- SHA-pinning for GitHub Actions (CodeRabbit "Major" but defensible):
  Workflow has no write scope (permissions: contents: read on both files),
  no secrets are exposed, and the actions involved are first-party Anthropic
  (astral-sh, actions/*, DavidAnson). Same policy decision as PR #542 —
  blanket SHA pinning is a bigger commitment than this PR's scope warrants.

* chore: pin all GitHub Actions to commit SHAs

Addresses CodeRabbit's Major finding (zizmor `unpinned-uses`). Reverses the
earlier policy decision now that the workflow scope has grown — pins both
workflows consistently in one pass:

- actions/checkout         v4  → 34e114876b0b11c390a56381ad16ebd13914f8d5
- actions/setup-node       v4  → 49933ea5288caeca8642d1e84afbd3f7d6820020
- actions/upload-artifact  v4  → ea165f8d65b6e75b540449e92b4886f43607fa02
- astral-sh/setup-uv       v5  → e58605a9b6da7c637471fab8847a5e5a6b8df081
- DavidAnson/markdownlint-cli2-action v18 → eb5ca3ab411449c66620fe7f1b3c9e10547144b0
- oven-sh/setup-bun        v2  → 0c5077e51419868618aeaa5fe8019c62421857d6

Each pin keeps the version tag in a trailing comment for human readability
and dependabot/renovate compatibility.

Both workflows YAML-validated locally; functionality unchanged.
2026-05-22 12:20:56 -04:00

163 行
5.2 KiB
YAML

name: Code Quality
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
# Read-only lint workflow — no writes back to the repo, no deployments.
permissions:
contents: read
jobs:
python-lint:
name: Python (ruff + ty)
runs-on: ubuntu-latest
defaults:
run:
working-directory: plugins/plugin-eval
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@e58605a9b6da7c637471fab8847a5e5a6b8df081 # v5
with:
enable-cache: true
- name: Set up Python
run: uv python install
- name: Sync plugin-eval dev dependencies
run: uv sync --all-extras
- name: ruff check (lint)
# Scope: adapter framework + plugin-eval. yt-design-extractor.py is legacy
# and out of scope for the multi-harness work; not gated.
run: |
uv run ruff check \
../../tools/adapters/ \
../../tools/generate.py \
../../tools/validate_generated.py \
../../tools/doc_gardener.py \
../../tools/tests/ \
src/plugin_eval/
- name: ruff format --check
run: |
uv run ruff format --check \
../../tools/adapters/ \
../../tools/generate.py \
../../tools/validate_generated.py \
../../tools/doc_gardener.py \
../../tools/tests/ \
src/plugin_eval/
- name: ty type-check
run: |
uv run ty check \
../../tools/adapters/ \
../../tools/generate.py \
../../tools/validate_generated.py \
../../tools/doc_gardener.py \
../../tools/tests/ \
src/plugin_eval/
markdown-lint:
name: Markdown (markdownlint-cli2)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
- name: markdownlint
# Lints top-level guides (README, AGENTS, ARCHITECTURE, CLAUDE, per-harness
# setup, CONTRIBUTING) and our authored docs/. Per-plugin READMEs are owned
# by their plugin authors and not lint-gated here — they should be authored
# to spec, but lint enforcement happens at the plugin-author layer, not at
# the framework PR layer.
# Config in .markdownlint.json keeps the ruleset narrow and pragmatic.
uses: DavidAnson/markdownlint-cli2-action@eb5ca3ab411449c66620fe7f1b3c9e10547144b0 # v18
with:
globs: |
*.md
docs/*.md
config: .markdownlint.json
json-lint:
name: JSON / TOML / YAML syntax
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@e58605a9b6da7c637471fab8847a5e5a6b8df081 # v5
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.12
- name: Validate every JSON file
run: |
set -e
shopt -s globstar nullglob
failed=0
for f in **/*.json; do
# Skip generated trees and node_modules
case "$f" in
.codex/*|.cursor/*|.cursor-plugin/*|.opencode/*|node_modules/*|skills/*|agents/*|commands/*) continue ;;
esac
if ! uv run python -m json.tool "$f" > /dev/null 2>&1; then
echo "::error file=$f::invalid JSON"
failed=1
fi
done
exit $failed
- name: Validate every TOML file
run: |
set -e
shopt -s globstar nullglob
failed=0
for f in **/*.toml; do
case "$f" in
.codex/*|.cursor/*|.cursor-plugin/*|.opencode/*|node_modules/*|commands/*) continue ;;
esac
if ! uv run python -c "import tomllib, sys; tomllib.loads(open(sys.argv[1]).read())" "$f" 2>/dev/null; then
echo "::error file=$f::invalid TOML"
failed=1
fi
done
exit $failed
- name: Validate every YAML file
run: |
set -e
shopt -s globstar nullglob
failed=0
for f in **/*.yml **/*.yaml; do
case "$f" in
.codex/*|.cursor/*|.cursor-plugin/*|.opencode/*|node_modules/*) continue ;;
esac
# Use safe_load_all to handle multi-document YAML (e.g. Kubernetes manifests
# with `---` document separators — valid YAML, but safe_load only reads the
# first doc and would mis-flag the file as invalid).
if ! uv run --with pyyaml python -c "import yaml, sys; list(yaml.safe_load_all(open(sys.argv[1]).read()))" "$f" 2>/dev/null; then
echo "::error file=$f::invalid YAML"
failed=1
fi
done
exit $failed