mirror of
https://github.com/docker/docker-agent.git
synced 2026-11-04 10:02:15 +00:00
Emit a strict Zod schema per builtin tool from the parameters each toolset actually advertises, per-toolset tool-name lists with a ToolName union, and the Toolset config as a union discriminated on type, with per-type fields derived from Toolset.validate. Generation fails on JSON Schema constructs the Zod emitter doesn't support instead of widening them, and coverage tests tie the output to the registered toolset types and ToolName constants.
245 lines
9.0 KiB
YAML
245 lines
9.0 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"
|
|
- pkg/model/provider/catalog/providers.json
|
|
- "**/*.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/...
|
|
|
|
models-delta:
|
|
desc: Show the models.dev catalog delta (HEAD vs the working-tree snapshot by default)
|
|
silent: true
|
|
cmds:
|
|
- bash ./scripts/models-delta.sh {{.CLI_ARGS}}
|
|
|
|
test-models-delta:
|
|
desc: Run the golden-fixture regression test for the models-delta jq scripts
|
|
cmds:
|
|
- bash ./scripts/models-delta-test.sh
|
|
|
|
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/
|
|
|
|
check-models-live:
|
|
desc: Validate example model references against the live models.dev API (hits the network; not part of `task test` since drift here is external and must not block PRs — see issue #4134)
|
|
cmds:
|
|
- CHECK_MODELS_DEV_LIVE=1 go test -count=1 -run TestExamplesAgainstLiveModelsDev ./pkg/config/
|
|
|
|
check-plan-cross:
|
|
desc: Cross-compile the plan storage and host plans packages for every file-lock build-tag variant (plus the plan-consuming CLI and TUI packages on windows)
|
|
cmds:
|
|
- GOOS=linux GOARCH=amd64 go build ./pkg/tools/builtin/plan/ ./pkg/plans/
|
|
- GOOS=windows GOARCH=amd64 go build ./pkg/tools/builtin/plan/ ./pkg/plans/ ./cmd/root/ ./pkg/tui/
|
|
- GOOS=js GOARCH=wasm go build ./pkg/tools/builtin/plan/ ./pkg/plans/
|
|
- GOOS=wasip1 GOARCH=wasm go build ./pkg/tools/builtin/plan/ ./pkg/plans/
|
|
- GOOS=plan9 GOARCH=amd64 go build ./pkg/tools/builtin/plan/ ./pkg/plans/
|
|
|
|
generate-ts:
|
|
desc: Generate the TypeScript SDK types and JSON Schemas from the Go API types
|
|
cmds:
|
|
- go run ./sdk/typescript/gen
|
|
|
|
check-ts:
|
|
desc: Fail if the generated TypeScript SDK is stale or does not type-check (requires Node)
|
|
deps: [install-ts]
|
|
vars:
|
|
GENERATED: sdk/typescript/src/generated sdk/typescript/schemas
|
|
cmds:
|
|
- task: generate-ts
|
|
- |
|
|
untracked="$(git ls-files --others --exclude-standard -- {{.GENERATED}})"
|
|
if ! git --no-pager diff --exit-code -- {{.GENERATED}} || [ -n "$untracked" ]; then
|
|
[ -z "$untracked" ] || printf 'untracked: %s\n' $untracked
|
|
echo 'The generated TypeScript SDK is stale: run `task generate-ts` and commit the result.'
|
|
exit 1
|
|
fi
|
|
- npm --prefix sdk/typescript run typecheck
|
|
- npm --prefix sdk/typescript test
|
|
|
|
install-ts:
|
|
internal: true
|
|
dir: sdk/typescript
|
|
sources:
|
|
- package.json
|
|
- package-lock.json
|
|
generates:
|
|
- node_modules/.package-lock.json
|
|
cmds:
|
|
- npm ci --ignore-scripts --no-audit --no-fund
|
|
|
|
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 --allow-parallel-runners
|
|
- 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-ci:
|
|
desc: Run tests with CI timing reports
|
|
dotenv: [.env.test]
|
|
cmds:
|
|
- set -o pipefail; go test -json ./... | go run ./scripts/gotestreport -out "${RUNNER_TEMP:-/tmp}/go-test.json"
|
|
|
|
test-race:
|
|
desc: Run tests with the race detector and shuffled order (slow; CI runs it on main only)
|
|
dotenv: [.env.test]
|
|
cmds:
|
|
- go test -race -shuffle=on ./...
|
|
|
|
test-wasm-providers:
|
|
desc: Test explicit provider registration in the WASM demo (requires Node)
|
|
cmds:
|
|
- task: test-wasm-js
|
|
- go test ./e2e -run '^TestWasmProviderDependencies$'
|
|
|
|
# The GOOS=js half of test-wasm-providers; the e2e check above already runs
|
|
# under `task test`, so CI calls this to avoid recompiling the e2e package.
|
|
test-wasm-js:
|
|
desc: Run portable runtime, tool and provider tests under GOOS=js (requires Node)
|
|
cmds:
|
|
- GOOS=js GOARCH=wasm go test -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" ./cmd/wasm
|
|
- GOOS=js GOARCH=wasm go test -tags docker_agent_wasm_rag -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" ./cmd/wasm
|
|
- GOOS=js GOARCH=wasm go test -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" pkg/model/provider/factory_js_openai_vendor_test.go
|
|
- GOOS=js GOARCH=wasm go test -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" -run '^TestLimitLargeToolResults|^TestEnvironmentInfo' ./pkg/hooks/builtins
|
|
- GOOS=js GOARCH=wasm go test -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" ./pkg/embeddedchat ./pkg/fuzzy/... ./pkg/tools/builtin/calculator ./pkg/tools/builtin/datetime ./pkg/tools/builtin/deferred ./pkg/tools/builtin/think ./pkg/tools/builtin/random ./pkg/tools/builtin/todo ./pkg/tools/builtin/memory ./pkg/memory/database/inmemory ./pkg/tools/codemode ./pkg/tools/toon ./pkg/rag ./pkg/rag/strategy
|
|
- GOOS=js GOARCH=wasm go test -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" -run 'MemoryStorage|Conformance' ./pkg/tools/builtin/plan
|
|
- GOOS=js GOARCH=wasm go test -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" -run 'Egress|TestWithOAuthTokenStore' ./pkg/httpclient ./pkg/tools/mcp
|
|
- GOOS=js GOARCH=wasm go test -tags docker_agent_wasm_cloud -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" ./cmd/wasm ./pkg/model/provider/bedrock ./pkg/model/provider/gemini ./pkg/model/provider/anthropic/vertex ./pkg/model/provider/vertexai
|
|
|
|
test-wasm-bridge:
|
|
desc: Build WASM variants and test their JavaScript API under Node
|
|
cmds:
|
|
- GOOS=js GOARCH=wasm go build -tags docker_agent_wasm_rag -o cmd/wasm/web/docker-agent.wasm ./cmd/wasm
|
|
- node cmd/wasm/smoke_test.js
|
|
- node --test cmd/wasm/node/rag_test.js
|
|
- GOOS=js GOARCH=wasm go build -o cmd/wasm/web/docker-agent.wasm ./cmd/wasm
|
|
- node --test cmd/wasm/web/events_test.js
|
|
- node cmd/wasm/smoke_test.js
|
|
- node --test cmd/wasm/node/bridge_test.js cmd/wasm/node/rag_off_test.js
|
|
|
|
test-wasm-browser:
|
|
desc: Test real browser fetch, tools and RAG (requires Chrome and openssl)
|
|
cmds:
|
|
- node cmd/wasm/browser/smoke_test.js --build {{.CLI_ARGS}}
|
|
|
|
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 .
|
|
|
|
template:
|
|
desc: Build the sandbox template image with the locally-built binary
|
|
cmds:
|
|
- docker buildx build --load --target=template --build-arg GIT_TAG --build-arg GIT_COMMIT -t docker/docker-agent-sbx-templates .
|
|
|
|
docs-serve:
|
|
desc: Preview the documentation site locally with Hugo
|
|
dir: docs
|
|
cmds:
|
|
- docker build -t docker-agent-docs .
|
|
- docker run --rm -v $(cd .. && pwd)/docs:/src -p 1313:1313 docker-agent-docs
|
|
|
|
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
|