a1afbce84c
U2 of the Claude Desktop .mcpb bundle plan. - internal/engine/embed.go embeds the vendored Python tree at build time via //go:embed all:vendored. The engine package owns the embed because Go's directive cannot reach outside its own package directory; sync and gitignore paths are updated to match (internal/engine/vendored/ in place of mcp/vendored/). - internal/engine/extract.go materializes the embed into <cache>/last30days-pp-mcp/<version>/ with a .version sentinel that short-circuits re-extraction. Atomic rename from a .tmp sibling means a partial extraction can never be mistaken for complete. Concurrent first-call extractions serialize behind a per-cache-dir sync.Once. - EnsureUserCache honors a LAST30DAYS_CACHE_DIR env override for locked-down filesystems; the override is named in extract errors. - internal/engine/extract_test.go covers happy path, sentinel skip, version bump, 10-goroutine race, empty-version rejection, unwritable cache parent, and the env override (7 tests, all passing). - A tracked vendored/.gitkeep anchors the embed path so the directive matches even before scripts/sync-engine.sh runs.
27 lines
978 B
Go
27 lines
978 B
Go
// Package engine wraps the vendored Python last30days engine. The engine
|
|
// is embedded at build time via //go:embed and extracted into a per-user
|
|
// cache directory on first use, then invoked through python3 in a
|
|
// subprocess. Consumers should call EnsureUserCache to materialize the
|
|
// engine and Run to execute it.
|
|
package engine
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
)
|
|
|
|
// EngineSourceDir is the embed root inside the binary. scripts/sync-engine.sh
|
|
// mirrors skills/last30days/scripts/ into this directory before each build.
|
|
// The all: prefix preserves files starting with "." or "_" so the .gitkeep
|
|
// anchor file survives - without it the embed would error before sync runs.
|
|
//
|
|
//go:embed all:vendored
|
|
var vendored embed.FS
|
|
|
|
// EngineFS returns the embedded engine as a filesystem rooted at the
|
|
// vendored/ directory contents (so callers see "last30days.py" at the
|
|
// root, not "vendored/last30days.py").
|
|
func EngineFS() (fs.FS, error) {
|
|
return fs.Sub(vendored, "vendored")
|
|
}
|