| 1 | // Package engine wraps the vendored Python last30days engine. The engine |
| 2 | // is embedded at build time via //go:embed and extracted into a per-user |
| 3 | // cache directory on first use, then invoked through python3 in a |
| 4 | // subprocess. Consumers should call EnsureUserCache to materialize the |
| 5 | // engine and Run to execute it. |
| 6 | package engine |
| 7 | |
| 8 | import ( |
| 9 | "embed" |
| 10 | "io/fs" |
| 11 | ) |
| 12 | |
| 13 | // EngineSourceDir is the embed root inside the binary. scripts/sync-engine.sh |
| 14 | // mirrors skills/last30days/scripts/ into this directory before each build. |
| 15 | // The all: prefix preserves files starting with "." or "_" so the .gitkeep |
| 16 | // anchor file survives - without it the embed would error before sync runs. |
| 17 | // |
| 18 | //go:embed all:vendored |
| 19 | var vendored embed.FS |
| 20 | |
| 21 | // EngineFS returns the embedded engine as a filesystem rooted at the |
| 22 | // vendored/ directory contents (so callers see "last30days.py" at the |
| 23 | // root, not "vendored/last30days.py"). |
| 24 | func EngineFS() (fs.FS, error) { |
| 25 | return fs.Sub(vendored, "vendored") |
| 26 | } |
| 27 |