Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
328 lines (270 loc) · 11.8 KB
/
Copy pathTaskfile.yml
File metadata and controls
328 lines (270 loc) · 11.8 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
version: "3"
tasks:
setup:
desc: "Set up the development environment"
cmds:
- go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.14.0 || true
- task: governance:hooks:install
- go mod download
default:
desc: Show available tasks
cmds:
- task --list
update:
desc: "Update Go modules and the docs lockfile"
cmds:
- go get -u all
- go mod tidy
- uv lock --upgrade
upgrade:
desc: "Upgrade all dependencies to latest then update"
cmds:
- task: update
set-version:
desc: "Set version across all packages (usage: task set-version -- 1.2.3)"
requires:
vars: [CLI_ARGS]
vars:
VERSION: "{{.CLI_ARGS}}"
cmds:
- |
set -euo pipefail
echo "Setting version to {{.VERSION}} across all packages..."
# Go CLI version
sed -i '' 's/Version = ".*"/Version = "{{.VERSION}}"/' cmd/commands/root.go
sed -i '' 's/var version = ".*"/var version = "{{.VERSION}}"/' cmd/ai-rulez/main.go
# npm release wrapper
sed -i '' 's/"version": ".*"/"version": "{{.VERSION}}"/' release/npm/package.json
# pyproject.toml
sed -i '' 's/^version = ".*"/version = "{{.VERSION}}"/' pyproject.toml
# PyPI wrapper __version__
sed -i '' 's/__version__ = ".*"/__version__ = "{{.VERSION}}"/' release/pypi/__init__.py
sed -i '' 's/__version__ = ".*"/__version__ = "{{.VERSION}}"/' release/pypi/ai_rulez/__init__.py
# Pre-commit hook rev (internal/hooks/setup.go)
sed -i '' 's/officialPreCommitRev = "v[^"]*"/officialPreCommitRev = "v{{.VERSION}}"/' internal/hooks/setup.go
# Pre-commit bootstrap script default version (scripts/pre-commit/run-ai-rulez.sh)
sed -i '' 's/AI_RULEZ_VERSION="\${AI_RULEZ_VERSION:-v[^"]*}"/AI_RULEZ_VERSION="\${AI_RULEZ_VERSION:-v{{.VERSION}}}"/' scripts/pre-commit/run-ai-rulez.sh
# README pre-commit example + poly hook source revision
sed -i '' 's/rev: v[0-9][0-9.]*/rev: v{{.VERSION}}/' README.md
sed -i '' 's/revision = "v[0-9][0-9.]*"/revision = "v{{.VERSION}}"/g' README.md
# Poly hook catalog + docs: pinned ai-rulez versions (npx/uvx) and revisions
for f in poly-hooks.toml docs/poly-hooks.md; do
sed -i '' 's/ai-rulez@[0-9][0-9.]*/ai-rulez@{{.VERSION}}/g' "$f"
sed -i '' 's/ai-rulez==[0-9][0-9.]*/ai-rulez=={{.VERSION}}/g' "$f"
done
sed -i '' 's/revision = "v[0-9][0-9.]*"/revision = "v{{.VERSION}}"/g' docs/poly-hooks.md
echo "Done. Updated version to {{.VERSION}} in:"
echo " - cmd/commands/root.go"
echo " - cmd/ai-rulez/main.go"
echo " - release/npm/package.json"
echo " - pyproject.toml"
echo " - release/pypi/__init__.py"
echo " - release/pypi/ai_rulez/__init__.py"
echo " - internal/hooks/setup.go"
echo " - scripts/pre-commit/run-ai-rulez.sh"
echo " - README.md"
echo " - poly-hooks.toml"
echo " - docs/poly-hooks.md"
setup:llm:
desc: "Download, sha256-verify and cache the static liter-llm library; prints the CGO_LDFLAGS export (needs the network once)"
cmds:
- bash scripts/setup-liter-llm.sh
build:
desc: "Build the CLI binary as a release does: liter-llm linked statically (plain `go build` links the shared library the module ships, which only runs on this machine)"
cmds:
- bash -c 'if [ -z "${CGO_LDFLAGS:-}" ]; then eval "$(bash scripts/setup-liter-llm.sh)"; fi; go build -ldflags="-s -w" -o bin/ai-rulez ./cmd/ai-rulez'
test:release:
desc: "Run the model-layer tests against the static liter-llm library, the way CI does"
cmds:
- bash -c 'if [ -z "${CGO_LDFLAGS:-}" ]; then eval "$(bash scripts/setup-liter-llm.sh)"; fi; go test ./internal/llm/... ./internal/pricing/... ./internal/tokens/... ./cmd/...'
release:dry-run:
desc: "Build this platform's release archive locally and check what the wrappers expect (see docs/maintainers/release.md)"
cmds:
- bash scripts/release-dry-run.sh
test:
desc: "Run unit and integration tests"
vars:
TEST_TIMEOUT: '{{default "30m" .TEST_TIMEOUT}}'
COMMAND_TEST_LOG_DIR: '{{default "" .COMMAND_TEST_LOG_DIR}}'
cmds:
- '{{if eq OS "windows"}}go run ./scripts/testshard -shards 4 -log-dir "{{.COMMAND_TEST_LOG_DIR}}"{{else}}go test{{end}} -timeout {{.TEST_TIMEOUT}} ./cmd/... ./internal/... ./pkg/... ./scripts/... ./bench/... ./schema/... ./tests/fixtures/... ./tests/integration/... ./tests/testutil/... ./tests/archlint/...'
schema:local:generate:
desc: "Derive the local overlay schema from the main schema"
env:
UPDATE_LOCAL_SCHEMA: "1"
cmds:
- go test ./schema -run TestLocalSchemaInSync -count=1
test:gemini-settings:
desc: "Verify Gemini extension settings schema and native projection"
cmds:
- go test ./internal/config ./internal/generator/plugin ./schema -count=1
test:golden:update:
desc: "Rewrite golden files (UPDATE_GOLDEN=1) in every package that has them, then the tokens golden; review the diff"
env:
UPDATE_GOLDEN: "1"
cmds:
- go test -count=1 ./cmd/commands/ ./internal/lint/ ./internal/evals/evalimport/ ./internal/importer/ ./internal/mcp/ ./internal/okfbridge/ ./internal/generator/... ./internal/publish/... ./internal/migrate/ ./internal/agentplugins/ ./internal/telemetry/ ./internal/ard/ ./internal/policy/ ./tests/golden/ ./tests/archlint/
- go test -count=1 ./internal/generator -run Golden_TokenReportJSON -update-tokens-golden
test:verbose:
desc: "Run all tests with verbose output"
cmds:
- go test -v ./...
test:race:
desc: "Run tests with race detector"
cmds:
- go test -race ./...
test:e2e:
desc: "Run all e2e tests"
cmds:
- go test -timeout 30m ./tests/e2e/...
test:e2e:cli:
desc: "Run e2e CLI tests"
cmds:
- go test ./tests/e2e/cli/...
test:e2e:mcp:
desc: "Run e2e MCP tests"
cmds:
- go test ./tests/e2e/mcp/...
test:e2e:integration:
desc: "Run e2e integration tests"
cmds:
- go test ./tests/e2e/integration/...
test:otelcol:
desc: "Send telemetry to a pinned real OpenTelemetry Collector (needs docker)"
env:
AI_RULEZ_E2E_OTELCOL: "1"
cmds:
- go test ./internal/telemetry -run 'TestCollector' -count=1 -v
test:platform:
desc: "Run cross-platform specific tests"
cmds:
- go test -timeout 30m ./tests/platform/...
test:bats:
desc: "Run the Bats suites for shell scripts (usage: task test:bats -- [bats args or suite path])"
cmds:
# run.sh sets BATS_LIB_PATH=tests/lib (bats_load_library searches nothing else) and builds
# ai-rulez once for the suites that render scripts through the binary.
- scripts/bats/run.sh {{.CLI_ARGS}}
test:lib:sync:
desc: "Refresh tests/lib/xberg-bats from xberg-io/actions (task test:lib:sync -- --ref v1 re-pins)"
cmds:
- scripts/bats/sync-xberg-bats.sh {{.CLI_ARGS}}
test:lib:check:
desc: "Fail when tests/lib/xberg-bats has drifted from the pinned xberg-io/actions commit"
cmds:
- scripts/bats/sync-xberg-bats.sh --check
lint:bats:
desc: "Format-check and lint the Bats suites (poly has no engine for .bats)"
cmds:
- scripts/bats/lint.sh
bench:judge:
desc: "Run the judge benchmark on Amazon Bedrock: the synthetic corpus of bench/judge through the model pipeline, then precision/recall per code, the trap false-positive rate, grounding and cost. Spends money (hard cap 5 USD by default); pass flags after --, for example: task bench:judge -- --max-cost 3 --only mal-s03-a,trap-t01. Uses AWS_PROFILE=default and AWS_REGION=eu-north-1 unless --aws-profile / --aws-region say otherwise"
cmds:
- go run ./bench/judge/cmd/judgebench {{.CLI_ARGS}}
bench:judge:offline:
desc: "Run the offline half of the judge benchmark: the verifier and the convention attachment on the corpus, no model"
cmds:
- go test ./bench/judge/... -count=1
test:benchmark:
desc: "Run Go benchmarks (small and medium synthetic projects)"
cmds:
- go test -bench=. -run='^$' -timeout 30m ./...
test:benchmark:large:
desc: "Run Go benchmarks including the 2000-file synthetic project (one iteration each)"
env:
AI_RULEZ_BENCH_LARGE: "1"
cmds:
- go test -bench=. -benchtime=1x -run='^$' -timeout 60m ./...
test:benchmark:regression:
desc: "Run the curated benchmark subset and fail on a >25% time/op regression against scripts/bench-baseline.txt"
cmds:
- scripts/bench.sh
test:benchmark:baseline:
desc: "Re-record scripts/bench-baseline.txt on this machine"
cmds:
- scripts/bench.sh --update
test:all:
desc: "Run all test suites"
cmds:
- task: test
- task: test:platform
- task: test:e2e
lint:
desc: "Run poly formatting and lint checks"
cmds:
- poly fmt --check .
- poly lint .
check:
desc: "Run go vet and golangci-lint"
cmds:
- go vet ./...
- golangci-lint run --timeout=5m
format:
desc: "Format Go code"
cmds:
- go fmt ./...
generate:
desc: "Generate ai-rulez configuration files"
cmds:
- go run ./cmd/ai-rulez generate
validate:
desc: "Validate ai-rulez configuration"
cmds:
- go run ./cmd/ai-rulez validate
docs:cli:
desc: "Regenerate docs/cli-reference.md and the command index of docs/cli.md from the Cobra command tree"
cmds:
- go run ./scripts/clidocs
docs:cli:check:
desc: "Fail when docs/cli-reference.md or the command index of docs/cli.md differ from the command tree"
cmds:
- go run ./scripts/clidocs --check
docs:llms:
desc: "Regenerate docs/llms.txt and docs/llms-full.txt from zensical.toml and docs/"
cmds:
- go run ./scripts/docsllms
docs:llms:check:
desc: "Fail when docs/llms.txt or docs/llms-full.txt differ from the docs sources"
cmds:
- go run ./scripts/docsllms --check
harness:verify:
desc: "List harness trap and limit rows with source and verified_on; fail when older than max_table_age_days (default 90). HARNESS_MAX_AGE_DAYS overrides; HARNESS_VERIFY_FETCH=1 also re-fetches each quote (network)"
cmds:
- HARNESS_VERIFY=1 go test ./internal/lint -run TestHarnessVerify -count=1 -v
demo:record:
desc: "Re-record the README terminal demos with vhs (all, or name them: task demo:record -- validate); uses the ai-rulez on PATH"
cmds:
- bash scripts/demo/run.sh record {{.CLI_ARGS}}
demo:check:
desc: "Parse every demo tape and check each committed GIF exists and is at most 1 MiB"
cmds:
- bash scripts/demo/run.sh check
clean:
desc: "Clean build artifacts"
cmds:
- rm -rf bin/
- go clean -cache -testcache
governance:hooks:install:
desc: Provision machine preferences and install reviewed AI governance hooks
cmds:
- |
python3 - <<'PYTHON'
import pathlib
import shutil
import subprocess
import tomllib
if shutil.which("ai-rulez") is None:
raise SystemExit("Install the reviewed ai-rulez CLI before installing hooks")
preferences = pathlib.Path("poly.local.toml")
text = preferences.read_text() if preferences.exists() else ""
data = tomllib.loads(text)
if "hook_preferences" not in data:
preferences.write_text(text.rstrip() + '\n\n[hook_preferences]\nchannels = ["system"]\n')
elif "system" not in data["hook_preferences"].get("channels", []):
raise SystemExit("Add system to hook_preferences.channels in poly.local.toml")
subprocess.run(["poly", "hooks", "install"], check=True)
PYTHON
governance:check:
desc: Check materialized local governance outputs against shared sources
cmds:
- ai-rulez generate --check --no-local --strict-config