diff --git a/.claude/skills/ck-build-analysis b/.claude/skills/ck-build-analysis index db06cd4fc9..ef3df6f53b 100755 --- a/.claude/skills/ck-build-analysis +++ b/.claude/skills/ck-build-analysis @@ -179,14 +179,28 @@ 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" -# Run analysis -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 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" +fi # 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 b6375a6ba5..2d80146998 100644 --- a/.claude/skills/ck-build-analysis.md +++ b/.claude/skills/ck-build-analysis.md @@ -113,7 +113,7 @@ The report includes: ## Implementation Details -### PEP 723 Compliance +### PEP 723 Compliance with Automatic Dependency Management The analysis script (`analyze_build_trace.py`) is PEP 723 compliant with inline dependency metadata: @@ -126,26 +126,47 @@ The analysis script (`analyze_build_trace.py`) is PEP 723 compliant with inline # /// ``` -This allows tools like `pipx run` or `uv run` to automatically manage dependencies: +**The skill automatically uses `uv run` if available**, 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 + +**Option 1: Install uv (Recommended)** ```bash -# Run standalone with pipx (auto-installs dependencies) -pipx run .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/ - -# Or with uv -uv run .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/ +# 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. + ### Components - **ck-build-analysis** - Main bash script that orchestrates Docker, CMake, and analysis - **analyze_build_trace.py** - PEP 723 compliant Python script for trace analysis - **templates/build_analysis_report.md.jinja** - Jinja2 template for report generation -### Requirements +### Standalone Usage -In Docker container: -- `python3-jinja2` (installed via `apt-get install python3-jinja2`) +The Python script can also be run independently: -For standalone use: -- Python 3.8+ with `jinja2>=3.0.0` (auto-managed if using `pipx` or `uv`) +```bash +# With uv (recommended - auto-installs dependencies) +uv run .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/ + +# With pipx (alternative - 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/ +```