| 1 | #!/usr/bin/env bash |
| 2 | # Mirrors skills/last30days/scripts/{last30days.py,store.py,lib/} into |
| 3 | # mcp/internal/engine/vendored/ |
| 4 | # so the Go binary's embed.FS captures the engine at build time. |
| 5 | # |
| 6 | # Source of truth: skills/last30days/scripts/. Never edit mcp/internal/engine/vendored/ directly. |
| 7 | # Run before `go build` locally and in CI before `printing-press bundle`. |
| 8 | |
| 9 | set -euo pipefail |
| 10 | |
| 11 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 12 | MCP_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" |
| 13 | REPO_ROOT="$(cd "${MCP_DIR}/.." && pwd)" |
| 14 | ENGINE_SRC="${REPO_ROOT}/skills/last30days/scripts" |
| 15 | # Embed path must live inside the consuming package (Go //go:embed cannot |
| 16 | # reach outside its own directory tree), so vendored/ sits under engine/. |
| 17 | VENDORED="${MCP_DIR}/internal/engine/vendored" |
| 18 | |
| 19 | if [ ! -f "${ENGINE_SRC}/last30days.py" ]; then |
| 20 | echo "sync-engine: ${ENGINE_SRC}/last30days.py not found" >&2 |
| 21 | exit 1 |
| 22 | fi |
| 23 | |
| 24 | mkdir -p "${VENDORED}" |
| 25 | # Clear stale content while keeping the .gitkeep that anchors the embed path. |
| 26 | find "${VENDORED}" -mindepth 1 -not -name ".gitkeep" -delete |
| 27 | |
| 28 | # Copy the entry script, the top-level modules it imports at runtime, and the |
| 29 | # lib/ tree (modules + lib/vendor/). sync_contract_test.go fails if the engine |
| 30 | # imports a top-level module missing from this list. |
| 31 | for module in last30days.py store.py; do |
| 32 | cp "${ENGINE_SRC}/${module}" "${VENDORED}/${module}" |
| 33 | done |
| 34 | cp -R "${ENGINE_SRC}/lib" "${VENDORED}/lib" |
| 35 | |
| 36 | # Strip caches so the embed.FS stays deterministic. |
| 37 | find "${VENDORED}" -type d -name "__pycache__" -prune -exec rm -rf {} + |
| 38 | find "${VENDORED}" -type f -name "*.pyc" -delete |
| 39 | |
| 40 | echo "sync-engine: vendored engine at ${VENDORED}" |
| 41 |