diff --git a/.claude/skills/ck-build-analysis b/.claude/skills/ck-build-analysis index 82c4f40f12..a52dd1e3bd 100755 --- a/.claude/skills/ck-build-analysis +++ b/.claude/skills/ck-build-analysis @@ -166,29 +166,23 @@ echo "Generating analysis report..." docker cp "${SCRIPT_DIR}/analyze_build_trace.py" "${CONTAINER_NAME}:/tmp/analyze_build_trace.py" docker cp "${SCRIPT_DIR}/templates" "${CONTAINER_NAME}:/tmp/ck_build_analysis_templates" -# Check if uv is available and use it for PEP 723 dependency management -# Check both PATH and common install locations -if docker exec "${CONTAINER_NAME}" bash -c "command -v uv >/dev/null 2>&1 || test -x \$HOME/.local/bin/uv"; then - echo "Using uv run for automatic dependency management..." - # Ensure uv is in PATH (handles ~/.local/bin installation) - docker exec "${CONTAINER_NAME}" bash -c "export PATH=\"\$HOME/.local/bin:\$PATH\" && uv run --no-project /tmp/analyze_build_trace.py \ - ${TRACE_FILE} \ - /workspace/${OUTPUT_FILE} \ - ${TARGET} \ - ${GRANULARITY} \ - ${BUILD_TIME} \ - /tmp/ck_build_analysis_templates" -else - echo "uv not found, using python3 (requires python3-jinja2 pre-installed)..." - docker exec "${CONTAINER_NAME}" python3 /tmp/analyze_build_trace.py \ - "${TRACE_FILE}" \ - "/workspace/${OUTPUT_FILE}" \ - "${TARGET}" \ - "${GRANULARITY}" \ - "${BUILD_TIME}" \ - "/tmp/ck_build_analysis_templates" +# Check if uv is available, install if needed, and use for PEP 723 dependency management +if ! docker exec "${CONTAINER_NAME}" bash -c "command -v uv >/dev/null 2>&1 || test -x \$HOME/.local/bin/uv"; then + echo "uv not found, installing..." + docker exec "${CONTAINER_NAME}" bash -c "curl -LsSf https://astral.sh/uv/install.sh | sh" >/dev/null 2>&1 + echo "uv installed successfully" fi +echo "Using uv run for automatic dependency management..." +# Ensure uv is in PATH (handles ~/.local/bin installation) +docker exec "${CONTAINER_NAME}" bash -c "export PATH=\"\$HOME/.local/bin:\$PATH\" && uv run --no-project /tmp/analyze_build_trace.py \ + ${TRACE_FILE} \ + /workspace/${OUTPUT_FILE} \ + ${TARGET} \ + ${GRANULARITY} \ + ${BUILD_TIME} \ + /tmp/ck_build_analysis_templates" + # Copy report back to host docker cp "${CONTAINER_NAME}:/workspace/${OUTPUT_FILE}" "${PROJECT_ROOT}/${OUTPUT_FILE}" diff --git a/.claude/skills/ck-build-analysis.md b/.claude/skills/ck-build-analysis.md index 792c90a01a..83ff89144d 100644 --- a/.claude/skills/ck-build-analysis.md +++ b/.claude/skills/ck-build-analysis.md @@ -126,29 +126,18 @@ The analysis script (`analyze_build_trace.py`) is PEP 723 compliant with inline # /// ``` -**The skill automatically uses `uv run` if available**, which provides: +**The skill automatically installs and uses `uv`**, which provides: - ✅ Zero-configuration dependency management - ✅ Automatic installation of jinja2 from PEP 723 metadata - ✅ Isolated dependency environment (no system pollution) - ✅ Fast caching for subsequent runs -### Installation Options +**No manual setup required!** The first time you run the skill, it will: +1. Detect if `uv` is installed in the container +2. If not, automatically install it (takes ~5 seconds) +3. Use `uv run` to execute the analysis with auto-managed dependencies -**Option 1: Install uv (Recommended)** -```bash -# Install uv in the Docker container (one-time setup) -docker exec ck_ bash -c "curl -LsSf https://astral.sh/uv/install.sh | sh" -``` - -After installing `uv`, the skill will automatically use it for dependency management. - -**Option 2: Use system python3 + jinja2** -```bash -# If uv is not available, install jinja2 manually -docker exec ck_ apt-get install -y python3-jinja2 -``` - -The skill automatically detects which method is available and uses the appropriate one. +On subsequent runs, `uv` will already be available and dependencies will be cached. ### Components @@ -161,12 +150,9 @@ The skill automatically detects which method is available and uses the appropria The Python script can also be run independently: ```bash -# With uv (recommended - auto-installs dependencies) +# With uv (recommended - auto-installs dependencies from PEP 723 metadata) uv run .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/ -# With pipx (alternative - auto-installs dependencies) +# With pipx (alternative - also auto-installs dependencies) pipx run .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/ - -# With python3 (requires jinja2 pre-installed) -python3 .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/ ```