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