-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTaskfile.yml
More file actions
256 lines (223 loc) · 8.59 KB
/
Taskfile.yml
File metadata and controls
256 lines (223 loc) · 8.59 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
version: '3'
dotenv: ['.env']
vars:
OPENAPI_V2: '{{.CLOUD_REPO_PATH}}/backend/spec/api/v2/openapi.json'
OPENAPI_V3: '{{.CLOUD_REPO_PATH}}/backend/spec/api/v3/openapi.json'
TS_SDK: browser-use-node
PY_SDK: browser-use-python
tasks:
# ── OpenAPI Spec ──────────────────────────────────────────────
spec:pull:
desc: Pull fresh OpenAPI specs from running local backend
cmds:
- curl -sf {{.BACKEND_URL}}/api/v2/openapi.json | python3 -m json.tool > {{.OPENAPI_V2}}
- curl -sf {{.BACKEND_URL}}/api/v3/openapi.json | python3 -m json.tool > {{.OPENAPI_V3}}
- echo "Updated OpenAPI specs from {{.BACKEND_URL}}"
spec:diff:
desc: Show what changed in the OpenAPI specs
dir: '{{.CLOUD_REPO_PATH}}'
cmds:
- git diff --stat backend/spec/api/v2/openapi.json backend/spec/api/v3/openapi.json
- git diff backend/spec/api/v2/openapi.json backend/spec/api/v3/openapi.json
# ── Type Generation (deterministic, no AI) ────────────────────
gen:types:
desc: Generate v2 + v3 types for both TS and Python
cmds:
- task: gen:types:ts
- task: gen:types:py
gen:types:ts:
desc: Generate TypeScript types from OpenAPI (v2 + v3)
dir: '{{.TS_SDK}}'
cmds:
- npx openapi-typescript {{.OPENAPI_V2}} -o src/generated/v2/types.ts
- npx openapi-typescript {{.OPENAPI_V3}} -o src/generated/v3/types.ts
- echo "TypeScript types generated (v2 + v3)"
gen:types:py:
desc: Generate Python models from OpenAPI (v2 + v3)
cmds:
- |
datamodel-codegen \
--input {{.OPENAPI_V2}} \
--input-file-type openapi \
--output {{.PY_SDK}}/src/browser_use_sdk/generated/v2/models.py \
--output-model-type pydantic_v2.BaseModel \
--snake-case-field \
--field-constraints \
--use-union-operator \
--disable-timestamp
- |
datamodel-codegen \
--input {{.OPENAPI_V3}} \
--input-file-type openapi \
--output {{.PY_SDK}}/src/browser_use_sdk/generated/v3/models.py \
--output-model-type pydantic_v2.BaseModel \
--snake-case-field \
--field-constraints \
--use-union-operator \
--disable-timestamp
- echo "Python models generated (v2 + v3)"
# ── Build ─────────────────────────────────────────────────────
build:ts:
desc: Build TypeScript SDK (CJS + ESM)
dir: '{{.TS_SDK}}'
cmds:
- pnpm install --frozen-lockfile
- pnpm build
build:py:
desc: Build Python SDK
dir: '{{.PY_SDK}}'
cmds:
- uv build
build:
desc: Build both SDKs
cmds:
- task: build:ts
- task: build:py
# ── Type Check ────────────────────────────────────────────────
check:ts:
desc: Type-check TypeScript SDK
dir: '{{.TS_SDK}}'
cmds:
- pnpm tsc --noEmit
check:py:
desc: Type-check Python SDK
dir: '{{.PY_SDK}}'
cmds:
- uv run pyright src/
check:
desc: Type-check both SDKs
cmds:
- task: check:ts
- task: check:py
# ── Test ──────────────────────────────────────────────────────
test:ts:
desc: Run TypeScript tests
dir: '{{.TS_SDK}}'
cmds:
- pnpm test
test:py:
desc: Run Python vibe tests (no backend or API needed)
dir: '{{.PY_SDK}}'
cmds:
- uv run python -m pytest tests/ -m "not live and not prod"
test:
desc: Run all tests (vibe tests, no backend required)
cmds:
- task: test:ts
- task: test:py
test:live:ts:
desc: Run TypeScript live integration tests (requires running backend)
dir: '{{.TS_SDK}}'
cmds:
- npx tsx tests/live.test.ts
test:live:py:
desc: Run Python live integration tests (requires running backend)
dir: '{{.PY_SDK}}'
cmds:
- uv run python -m pytest tests/ -m live -v -s
test:live:
desc: Run all live integration tests (requires running backend)
cmds:
- task: test:live:ts
- task: test:live:py
test:prod:ts:
desc: Run TypeScript prod smoke tests (hits real API)
dir: '{{.TS_SDK}}'
cmds:
- npx tsx tests/prod.test.ts
test:prod:py:
desc: Run Python prod smoke tests (hits real API)
dir: '{{.PY_SDK}}'
cmds:
- uv run python -m pytest tests/ -m prod -v -s
test:prod:
desc: Run all prod smoke tests (hits real API, uses .env.prod)
cmds:
- task: test:prod:ts
- task: test:prod:py
# ── Version Management ────────────────────────────────────────
version:
desc: Show current versions
cmds:
- echo "TS {{.TS_SDK}}:" $(node -p "require('./{{.TS_SDK}}/package.json').version")
- echo "PY {{.PY_SDK}}:" $(cd {{.PY_SDK}} && uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
version:bump:
desc: "Bump version (usage: task version:bump -- patch|minor|major)"
cmds:
- cmd: cd {{.TS_SDK}} && npm version {{.CLI_ARGS | default "patch"}} --no-git-tag-version
- cmd: |
NEW_VERSION=$(node -p "require('./{{.TS_SDK}}/package.json').version")
cd {{.PY_SDK}} && sed -i '' "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" pyproject.toml
echo "Python version bumped to ${NEW_VERSION}"
- cmd: |
NEW_VERSION=$(node -p "require('./{{.TS_SDK}}/package.json').version")
sed -i '' "s/| TypeScript | npm | [0-9]*\.[0-9]*\.[0-9]* |/| TypeScript | npm | ${NEW_VERSION} |/" README.md
sed -i '' "s/| Python | PyPI | [0-9]*\.[0-9]*\.[0-9]* |/| Python | PyPI | ${NEW_VERSION} |/" README.md
echo "README.md versions updated to ${NEW_VERSION}"
- task: version
# ── Publish ───────────────────────────────────────────────────
publish:ts:
desc: Publish TypeScript SDK to npm
dir: '{{.TS_SDK}}'
deps: [build:ts]
cmds:
- npm publish --access public
publish:py:
desc: Publish Python SDK to PyPI
dir: '{{.PY_SDK}}'
cmds:
- rm -rf dist/
- task: build:py
- uv publish --token {{.PYPI_TOKEN}}
publish:
desc: Publish both SDKs
cmds:
- task: publish:ts
- task: publish:py
# ── Snapshots ─────────────────────────────────────────────────
snapshot:save:
desc: Save current OpenAPI specs as snapshots (run after successful generation)
cmds:
- cp {{.OPENAPI_V2}} snapshots/v2.json
- cp {{.OPENAPI_V3}} snapshots/v3.json
- task: docs:sync
- echo "Snapshots saved and docs synced"
snapshot:diff:
desc: Show what changed between snapshots and current specs
cmds:
- echo "=== v2 changes ==="
- diff snapshots/v2.json {{.OPENAPI_V2}} || true
- echo ""
- echo "=== v3 changes ==="
- diff snapshots/v3.json {{.OPENAPI_V3}} || true
# ── Docs ─────────────────────────────────────────────────────
docs:sync:
desc: Copy OpenAPI specs into docs for Mintlify
cmds:
- cp snapshots/v2.json docs/openapi/v2.json
- cp snapshots/v3.json docs/openapi/v3.json
docs:dev:
desc: Start Mintlify docs dev server
deps: [docs:sync]
dir: docs
cmds:
- mint dev
docs:install:
desc: Install Mintlify CLI globally
cmds:
- npm install -g mintlify
# ── Full Pipeline ─────────────────────────────────────────────
update:
desc: "Full mechanical pipeline: spec -> types -> check -> docs"
cmds:
- task: spec:pull
- task: gen:types
- task: check
- task: docs:sync
- echo ""
- echo "Types regenerated and type-checked."
- echo "Next steps:"
- echo " 1. /sdk build -- regenerate SDK client code"
- echo " 2. /sdk test -- vibe test against localhost"
- echo " 3. /sdk docs -- update docs + drift check"
- echo " 4. git diff -- review everything"