Files
docker-agent/Taskfile.yml
T
David Gageot 2d157247ba feat(modelsdev): embed models.dev catalog snapshot as binary fallback
Adds a build-time snapshot of the models.dev catalog baked into the
binary via go:embed, used as last-resort fallback when the cache and
live fetch are both unavailable. A generator (pkg/modelsdev/internal/gen)
refreshes the snapshot; task update-models and a weekly GitHub Actions
workflow keep it current.

The fallback snapshot is not memoized on transient fetch failure, so the
Store retries the fetch once the network recovers. Context windows for
Fable and Opus 4.6-4.8 now come from the embedded snapshot (always
available, even offline); the Anthropic client falls back to the flat
200k floor only when no catalogue entry exists. A warning is logged when
the embedded snapshot fails to parse so a bad build artifact is
discoverable.

The snapshot freshness check is opt-in: TestSnapshotDateParses always
runs (time-independent) while TestSnapshotDateIsFresh is skipped unless
CHECK_MODELS_SNAPSHOT_FRESHNESS is set. A 'task check-models-fresh'
target provides the CI backstop.

Assisted-By: Claude
2026-06-27 16:00:08 +02:00

133 lines
3.5 KiB
YAML

# https://taskfile.dev
version: "3"
vars:
GIT_TAG:
sh: echo "${GIT_TAG:-$(git describe --tags --exact-match 2>/dev/null || echo dev)}"
GIT_COMMIT:
sh: echo "${GIT_COMMIT:-$(git rev-parse HEAD 2>/dev/null || echo dev)}"
env:
GIT_TAG: "{{.GIT_TAG}}"
GIT_COMMIT: "{{.GIT_COMMIT}}"
tasks:
default:
desc: Run lint, test, and build
aliases: [dev]
deps: [lint, test, build]
build:
desc: Build the application binary
aliases: [b]
sources:
- "**/*.go"
- "**/*.template"
- "**/*.txt"
- "**/*.yml"
- "**/*.yaml"
- go.mod
- go.sum
generates:
- bin/docker-agent
cmds:
- ./scripts/build.sh
clean:
desc: Remove the generated binary
cmds:
- rm -rf ./bin
update-models:
desc: Refresh the embedded models.dev catalog snapshot
cmds:
- go generate ./pkg/modelsdev/...
check-models-fresh:
desc: Fail if the embedded models.dev snapshot is stale (run update-models to refresh)
cmds:
- CHECK_MODELS_SNAPSHOT_FRESHNESS=1 go test -run TestSnapshotDateIsFresh ./pkg/modelsdev/
deploy-local:
desc: Deploy the cli-plugin
aliases: [install]
deps: [build]
cmds:
- mkdir -p "${HOME}/.docker/cli-plugins"
- /bin/ln -sf "$(pwd)/bin/docker-agent" "${HOME}/.docker/cli-plugins/docker-agent"
lint:
desc: Run the linters
sources:
- "**/*.go"
- .golangci.yml
- go.mod
- go.sum
cmds:
- GOLANGCI_LINT_CACHE={{.TASKFILE_DIR}}/.cache/lint golangci-lint run
- go run ./lint .
- go mod tidy --diff >/dev/null || (echo 'go.mod/go.sum files are not tidy' && exit 1)
format:
desc: Format code
sources:
- "**/*.go"
- .golangci.yml
cmds:
- golangci-lint fmt
test:
desc: Run tests
dotenv: [.env.test]
cmds:
- go test ./...
test-binary:
desc: Run tests on build binary
deps: [deploy-local]
dotenv: [.env.test]
cmds:
- go test -tags=binary_required ./e2e/binary/...
build-local:
desc: Build binaries for local host platform
cmds:
- docker build --target=local --build-arg GIT_TAG --build-arg GIT_COMMIT --platform local --output=./dist .
- |
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
mv ./dist/docker-agent ./dist/docker-agent.exe
fi
cross:
desc: Build binaries for multiple platforms
cmds:
- docker buildx build --target=cross --build-arg GIT_TAG --build-arg GIT_COMMIT --platform linux/amd64,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64,windows/arm64 --output=./dist .
build-image:
desc: Build Docker image
cmds:
- docker build -t docker/docker-agent --build-arg GIT_TAG --build-arg GIT_COMMIT .
push-image:
desc: Build and Push Docker image
cmds:
- docker buildx build --push --platform linux/amd64,linux/arm64 -t docker/docker-agent --build-arg GIT_TAG --build-arg GIT_COMMIT .
docs-serve:
desc: Preview the Jekyll documentation site locally
dir: docs
cmds:
- docker build -t docker-agent-docs .
- docker run --rm -v $(cd .. && pwd)/docs:/srv/jekyll -e JEKYLL_ENV=development -p 4000:4000 docker-agent-docs jekyll serve --host 0.0.0.0 --config _config.yml,_config.dev.yml --livereload
docs-check-links:
desc: Build the documentation site and check for broken links
dir: docs
cmds:
- ../scripts/docs-check-links.sh
record-demo:
desc: Record demo gif
cmds:
- vhs ./docs/recordings/demo.tape