Repository navigation
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
193 lines (172 loc) · 6.14 KB
/
Copy pathTaskfile.yaml
File metadata and controls
193 lines (172 loc) · 6.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
version: "3"
vars:
BINARY: captain
BIN_DIR: .bin
APP_NAME: captain
REGISTRY: '{{.REGISTRY | default "docker.lab"}}'
IMAGE: "{{.REGISTRY}}/{{.APP_NAME}}"
tasks:
default:
cmds:
- task --list
build:
desc: Build the captain binary
vars:
VERSION:
sh: git describe --tags --always
COMMIT:
sh: git rev-parse --short HEAD
DATE:
sh: date -u '+%Y-%m-%dT%H:%M:%SZ'
DIRTY:
sh: |
if test -n "$(git status --porcelain)"
then
echo true
else
echo false
fi
LDFLAGS: -s -w -X main.version={{.VERSION}} -X main.commit={{.COMMIT}} -X main.date={{.DATE}} -X main.dirty={{.DIRTY}}
OUTPUT: '{{.OUTPUT | default (printf "%s/%s" .BIN_DIR .BINARY)}}'
cmds:
- mkdir -p {{dir .OUTPUT}}
# CGO_ENABLED=0 unconditionally: every dependency is pure Go (sqlite comes
# from modernc.org/sqlite), so a cross-compile for image:lab produces the
# same binary the host build does, with no linux cgo toolchain needed.
- 'CGO_ENABLED=0 {{if .GOOS}}GOOS={{.GOOS}} GOARCH={{.GOARCH}} {{end}}go build -ldflags "{{.LDFLAGS}}" -o {{.OUTPUT}} ./cmd/captain'
www:build:
desc: Build the embedded Captain web UI
dir: pkg/cli/webapp
cmds:
- CI=true pnpm install --frozen-lockfile
- pnpm run build
- touch dist/.gitkeep
www:dev:
desc: Start Captain with the Vite dev proxy and open the browser
dir: pkg/cli/webapp
cmds:
- CI=true pnpm install --frozen-lockfile
- cd ../../.. && go run ./cmd/captain serve --dev --open
docs:build:
desc: Build the Captain Astro documentation site
dir: docs
cmds:
- CI=true pnpm install --frozen-lockfile
- pnpm run build
docs:dev:
desc: Start the Captain Astro documentation site
dir: docs
cmds:
- CI=true pnpm install --frozen-lockfile
- pnpm run dev
image:base:
desc: "Build the agent sandbox base image locally as captain:latest — the FROM of Dockerfile.flanksource and the base image:lab layers onto. Slow (apt, Go, Playwright); rerun only when the Dockerfile's pinned tool versions change."
vars:
GOARCH: '{{.GOARCH | default "amd64"}}'
cmds:
# deps pulls release assets from GitHub; GITHUB_TOKEN in the environment
# lifts the anonymous rate limit the Dockerfile's secret mount expects.
- >-
docker buildx build --platform linux/{{.GOARCH}} --load pkg/container/base
-f pkg/container/base/Dockerfile
{{if .GITHUB_TOKEN}}--secret id=GITHUB_TOKEN,env=GITHUB_TOKEN{{end}}
-t {{.APP_NAME}}:latest
image:lab:
desc: "Build and push the sandbox image with the working tree's captain binary to the lab registry. Requires image:base once. Defaults REGISTRY=docker.lab; override with REGISTRY=docker.example.com."
# The binary embeds pkg/cli/webapp/dist (serve.go), so the UI is rebuilt
# first or the image ships a stale one.
deps: [www:build]
vars:
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo dev
GOARCH: '{{.GOARCH | default "amd64"}}'
# Supplies everything but captain itself. Built by image:base — nothing is
# published to a registry, because .github/workflows/publish-image.yml is
# manual-only and has never been run.
BASE_IMAGE: '{{.BASE_IMAGE | default "captain:latest"}}'
LAB_DIR: "{{.BIN_DIR}}/lab"
cmds:
- task: build
vars:
GOOS: linux
GOARCH: "{{.GOARCH}}"
OUTPUT: "{{.LAB_DIR}}/captain-linux-{{.GOARCH}}"
# Context is the lab bin dir, not the repo root: the overlay needs one
# binary, and a root context would upload every node_modules tree.
- >-
docker buildx build --platform linux/{{.GOARCH}} --push {{.LAB_DIR}}
-f pkg/container/base/Dockerfile.lab
--build-arg BASE_IMAGE={{.BASE_IMAGE}}
-t {{.IMAGE}}:{{.VERSION}} -t {{.IMAGE}}:latest
lint:
desc: Run linters
cmds:
- golangci-lint run ./...
test:
desc: Run tests
cmds:
- go test ./...
test:verbose:
desc: Run tests with verbose output
cmds:
- go test -v ./...
test:e2e:mcp:
desc: Run the black-box MCP-to-CLI end-to-end test
cmds:
- go test -tags=e2e -count=1 -v -timeout=8m ./tests/e2e/mcp2cli
schemas:generate:
desc: Generate and check the native adapter resource schemas the schemas branch publishes
cmds:
- ./hack/adapterresources/fetch-sources.sh
- go run ./hack/adapterresources resources -out .tmp/adapter-schemas
- CAPTAIN_ADAPTER_RESOURCES=$PWD/.tmp/adapter-schemas go test -tags adapterresources -count=1 ./pkg/adapters
test:fixtures:
desc: Run gavel fixture tests
deps: [build]
cmds:
- PATH="$PWD/.bin:$PATH" gavel fixtures pkg/cli/testdata/history_test.md
- PATH="$PWD/.bin:$PATH" gavel fixtures pkg/cli/testdata/permissions_matrix_test.md
- gavel fixtures 'pkg/cli/testdata/prompt-questions/*.fixture.yaml'
install:
desc: Build and install captain to the default Go bin
vars:
VERSION:
sh: git describe --tags --always
COMMIT:
sh: git rev-parse --short HEAD
DATE:
sh: date -u '+%Y-%m-%dT%H:%M:%SZ'
DIRTY:
sh: |
if test -n "$(git status --porcelain)"
then
echo true
else
echo false
fi
LDFLAGS: -s -w -X main.version={{.VERSION}} -X main.commit={{.COMMIT}} -X main.date={{.DATE}} -X main.dirty={{.DIRTY}}
cmds:
- go install -ldflags "{{.LDFLAGS}}" ./cmd/captain
fmt:
desc: Format Go code
cmds:
- gofmt -w .
tidy:
desc: Tidy go modules
cmds:
- go mod tidy
models:update:
desc: Regenerate the embedded LLM model registry from models.dev + local patches
cmds:
- go run ./pkg/ai/internal/gen-model-registry --patches pkg/ai/internal/gen-model-registry/patches.json --output pkg/api/registry/models.json
clean:
desc: Remove build artifacts
cmds:
- rm -rf {{.BIN_DIR}}
all:
desc: Run fmt, lint, test, and build
cmds:
- task: fmt
- task: lint
- task: test
- task: build