-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmise.dev.toml
More file actions
378 lines (340 loc) · 11.3 KB
/
mise.dev.toml
File metadata and controls
378 lines (340 loc) · 11.3 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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# SPDX-FileCopyrightText: 2025 Knitli Inc.
# SPDX-FileContributor: Adam Poulemanos <adam@knit.li>
#
# SPDX-License-Identifier: MIT OR Apache-2.0
#:tombi schema.strict = false
[prepare.uv]
[settings.python]
[tools]
hk = "latest"
pkl = "latest"
usage = "latest"
uv = "latest"
# Quality & validation tools
"aqua:tombi-toml/tombi" = "latest"
"ubi:astral-sh/ty" = "latest"
ruff = "latest" # Python linting/formatting
"pipx:ipython" = "latest"
[tools."pipx:reuse"]
version = "latest"
python = "3.13"
[env]
_.python.venv = { path = ".venv" }
[hooks]
[hooks.enter]
env.MISE_EXPERIMENTAL = "1"
script = '''
'''
[tasks]
[tasks.enter]
silent = "stdout"
tools.uv = "latest"
run = '''
# profile is set to 'dev' in a cloud CI environment for cloud agents. 'enter' tends to break there.
if [ "$profile" = "dev" ] && [ "$CI" = "true" ]; then
# don't run
exit 0
fi
case "$python_path" in
*.venv/bin/python*)
# Already in venv, do nothing
;;
*)
# Not in venv or python not found, source it
. .venv/bin/activate 2>/dev/null || true
;;
esac
'''
run_windows = '''
@echo off
set "pythonPath=%python_path%"
if "%profile%"=="dev" if "%CI%"=="true" (
rem don't run
exit /b 0
)
if not "%pythonPath%"=="%pythonPath:.venv\Scripts\python=%" (
rem Already in venv, do nothing
) else (
rem Not in venv or python not found, source it
if exist .venv\Scripts\activate.bat (
call .venv\Scripts\activate.bat 2>NUL
)
)
'''
[tasks.enter.env]
ACTIVE_SHELL = '''{{ exec(command='basename "$SHELL" 2>/dev/null || echo zsh') }}'''
python_path = '''{{ exec(command='command -v python 2>/dev/null || echo ""') }}'''
MISE_EXPERIMENTAL = "1"
[tasks.cloud-setup]
run = [
# This setup only runs in cloud environments, and for cloud agents or complex tasks.
# For cloud agents, the shell is *always* bash and may or may not be interactive.
"echo \"[codeweaver] Setting up cloud development environment...\"",
"ln -sf AGENTS.md CLAUDE.md",
'''if ! command -v mise &>/dev/null; then
echo "[codeweaver] We couldn't find mise in your PATH. We'll try to install it for you."
if [ -d "$HOME/.local/share/mise" ] || [ -d "$HOME/.mise" ] || [ -f "$HOME/.local/bin/mise" ]; then
export PATH="$HOME/.local/bin:$HOME/.mise/bin:$HOME/.local/share/mise/bin:$PATH"
else
chmod +x scripts/dev-env/install-mise.sh 2>&1 || true
./scripts/dev-env/install-mise.sh 2>&1 || true
fi
fi''',
"echo \"[codeweaver] Using mise...\"",
'''if command -v mise &>/dev/null && ! grep -q "mise activate" "$HOME/.bashrc"; then
echo "eval \"$(mise activate bash)\" 2>&1 || true" >> "$HOME/.bashrc"
fi''',
'''if command -v mise &>/dev/null && ! grep -q "mise activate" "$HOME/.bash_profile"; then
echo "eval \"$(mise activate bash --shims)\" 2>&1 || true" >> "$HOME/.bash_profile"
fi''',
'''mise trust --all 2>&1''',
'''mise -vv install 2>&1''',
'''mise use hk@latest''',
'''hk install --mise 2>&1 || { echo "[WARNING] hk install failed during cloud-setup" >&2; }''',
'''echo "[codeweaver] Ensuring Python version "$MISE_PYTHON_VERSION" is installed..."''',
"uv venv --allow-existing --seed --keyring-provider subprocess --python $MISE_PYTHON_VERSION .venv 2>&1",
". .venv/bin/activate 2>&1 || true",
"uv sync --extra full --group dev --group test 2>&1",
"git config include.path .gitconfig 2>&1 || true",
'''bash -c "
ignore_files=('src/codeweaver/_version.py' 'coverage.xml' 'test-results.xml')
for file in \"\${ignore_files[@]}\"; do
if ! grep -qx \"\$file\" .git/info/exclude; then
echo \"\$file\" >> .git/info/exclude 2>&1
fi
done
"''',
"echo \"[codeweaver] Cloud development environment setup complete!\"",
]
[tasks.cloud-setup.env]
MISE_PYTHON_VERSION = "{{ get_env(name='MISE_PYTHON_VERSION', default='3.13') }}"
MISE_EXPERIMENTAL = "1"
MISE_ENV = "dev"
MISE_YES = "1"
[tasks.update-dependencies]
tools.uv = "latest"
depends = ["source"]
run = '''#!/usr/bin/env zsh
echo "${CW_PREFIX} Updating dependencies..."
uv sync --extra full --group dev --group docs --group build --group test -U'''
run_windows = '''
echo [codeweaver] Updating dependencies...
uv sync --extra full --group dev --group docs --group build --group test -U
'''
[tasks.update]
silent = "stdout"
alias = "update-tools"
shell = "zsh -c"
env.MISE_EXPERIMENTAL = "1"
env.MISE_YES = "1"
run = [
"echo \"${CW_PREFIX} Updating tools...\"",
"mise upgrade",
"mise self-update",
"mise prune",
"mise reshim",
"echo \"${CW_PREFIX} ✅ Tools updated! 🧰\"",
]
run_windows = [
"echo [codeweaver] Updating tools...",
"mise upgrade",
"mise self-update",
"mise prune",
"mise reshim",
"echo [codeweaver] Tools updated!",
]
[tasks.test-watch]
tools.uv = "latest"
run = '''
echo "${CW_PREFIX} Running tests in watch mode..."
uv run pytest tests/ -f --tb=short
'''
run_windows = '''
echo [codeweaver] Running tests in watch mode...
uv run pytest tests/ -f --tb=short
'''
[tasks.build]
# Building and packaging
run = '''
echo "${CW_PREFIX} Building package..."
uv build 2>&1 &&
echo "${CW_PREFIX} ✅ Package built successfully!"
'''
run_windows = '''
echo [codeweaver] Building package...
uv build
if %ERRORLEVEL% equ 0 (
echo [codeweaver] Package built successfully!
)
'''
# Documentation
[tasks.docs-dev]
tools.uv = "latest"
env.MISE_EXPERIMENTAL = "1"
run = '''
echo "${CW_PREFIX} Starting CodeWeaver documentation server..."
mise //:docs-site/dev || true
'''
run_windows = '''
echo [codeweaver] Starting CodeWeaver documentation server...
mise //:docs-site/dev || exit /b 0
'''
[tasks.changelog]
description = "Generate a filtered, PR-focused changelog (output to stdout)"
tools.git-cliff = "latest"
run = '''
echo "${CW_PREFIX} Generating changelog..."
git-cliff
'''
[tasks.changelog-unreleased]
description = "Generate changelog for unreleased changes (output to stdout)"
tools.git-cliff = "latest"
run = '''
echo "${CW_PREFIX} Generating unreleased changelog..."
git-cliff --unreleased
'''
[tasks.changelog-update]
description = "Update CHANGELOG.md with unreleased changes"
tools.git-cliff = "latest"
run = '''
echo "${CW_PREFIX} Updating CHANGELOG.md with unreleased changes..."
git-cliff --unreleased --prepend --output CHANGELOG.md &&
echo "${CW_PREFIX} ✅ CHANGELOG.md updated!"
'''
[tasks.changelog-tag]
description = "Generate changelog for a specific tag"
usage = '''
arg "<tag>" help="Git tag to generate changelog for (e.g., v0.1.0)"
'''
tools.git-cliff = "latest"
run = '''
echo "${CW_PREFIX} Generating changelog for tag ${usage_tag:?}..."
git-cliff --tag "${usage_tag:?}" --prepend --output CHANGELOG.md &&
echo "${CW_PREFIX} ✅ CHANGELOG.md generated for ${usage_tag:?}!"
'''
[tasks.prepare-version]
description = "Prepare build artifacts for a new version release"
usage = '''
arg "[version]" help="Version to prepare (e.g., 1.2.0). If not provided, will prompt."
flag "--no-commit" help="Don't commit the changes, just generate artifacts"
flag "--no-tag" help="Don't create a git tag"
flag "--push" help="Push changes and tags to remote after committing"
'''
run = '''
#!/usr/bin/env bash
set -e
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${CW_PREFIX} Preparing version release..."
# Get version
VERSION="${usage_version:-}"
if [ -z "$VERSION" ]; then
read -p "Enter version number (e.g., 1.2.0): " VERSION
fi
# Validate version format (supports pre-release: 1.2.0-alpha.1, 1.2.0-beta.2, etc.)
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._-]+)?$ ]]; then
echo -e "${RED}Error: Invalid version format. Use semantic versioning (e.g., 1.2.0 or 1.2.0-alpha.1)${NC}"
exit 1
fi
echo -e "${CW_PREFIX} Preparing version ${GREEN}v${VERSION}${NC}..."
# Step 1: Run build preparation
echo -e "${CW_PREFIX} Step 1/7: Running build preparation..."
uv run python scripts/build/prepare-build.py || {
echo -e "${RED}Build preparation failed!${NC}"
exit 1
}
# Step 2: Check for generated artifacts
echo -e "${CW_PREFIX} Step 2/7: Verifying generated artifacts..."
if [ ! -f "src/codeweaver/semantic/data/node_types_cache.json" ]; then
echo -e "${YELLOW}Warning: node_types_cache.json not found${NC}"
fi
# Step 3: Update CHANGELOG
echo -e "${CW_PREFIX} Step 3/7: Updating CHANGELOG.md..."
git cliff --unreleased --bump --prepend CHANGELOG.md || {
echo -e "${YELLOW}Warning: Failed to update CHANGELOG${NC}"
}
# Step 4: Ensure Reuse coverage
echo -e "${CW_PREFIX} Step 4/7: Ensuring Reuse coverage..."
reuse lint || {
echo -e "${RED}Reuse lint failed!${NC}"
exit 1
}
# Step 5: Generate SBOM
echo -e "${CW_PREFIX} Step 5/7: Generating SBOM for version ${VERSION}..."
reuse spdx --add-license-concluded --creator-person "automated[bot]" --creator-organization "Knitli Inc." -o sbom.spdx || {
echo -e "${RED}SBOM generation failed!${NC}"
exit 1
}
# Step 6: Commit if not disabled
if [ -z "${usage_no_commit:-}" ]; then
echo -e "${CW_PREFIX} Step 6/7: Committing build artifacts..."
git add src/codeweaver/semantic/data/node_types_cache.json 2>/dev/null || true
git add CHANGELOG.md 2>/dev/null || true
git add schema/ 2>/dev/null || true
if ! git diff --cached --quiet; then
git commit -m "chore: prepare build artifacts for v${VERSION}
- Update node_types cache
- Generate schema for v${VERSION}
- Update CHANGELOG.md" || {
echo -e "${RED}Commit failed!${NC}"
exit 1
}
echo -e "${GREEN}✓ Build artifacts committed${NC}"
else
echo -e "${YELLOW}No changes to commit${NC}"
fi
else
echo -e "${YELLOW}Skipping commit (--no-commit flag)${NC}"
fi
# Step 7: Tag if not disabled
if [ -z "${usage_no_tag:-}" ] && [ -z "${usage_no_commit:-}" ]; then
echo -e "${CW_PREFIX} Step 7/7: Creating git tag v${VERSION}..."
git tag -a "v${VERSION}" -m "Release v${VERSION}" || {
echo -e "${RED}Tagging failed!${NC}"
exit 1
}
echo -e "${GREEN}✓ Created tag v${VERSION}${NC}"
else
echo -e "${YELLOW}Skipping tag creation${NC}"
fi
# Push if requested
if [ -n "${usage_push:-}" ]; then
echo -e "${CW_PREFIX} Pushing to remote..."
git push && git push --tags || {
echo -e "${RED}Push failed!${NC}"
exit 1
}
echo -e "${GREEN}✓ Pushed to remote${NC}"
fi
echo ""
echo -e "${GREEN}════════════════════════════════════════════════${NC}"
echo -e "${GREEN}✓ Version ${VERSION} prepared successfully!${NC}"
echo -e "${GREEN}════════════════════════════════════════════════${NC}"
echo ""
echo -e "${BLUE}Next steps:${NC}"
if [ -z "${usage_push:-}" ]; then
echo -e " 1. Review the changes: ${YELLOW}git show${NC}"
echo -e " 2. Push to remote: ${YELLOW}git push && git push --tags${NC}"
fi
echo -e " 3. Create GitHub release from tag v${VERSION}"
echo ""
'''
run_windows = '''
echo [codeweaver] Version preparation on Windows not yet supported. Use WSL or Linux.
exit 1
'''
[tasks.prepare-version.tools]
"cargo:tree-sitter-cli" = "latest"
"pipx:reuse" = "latest"
git-cliff = "latest"
usage = "latest"
uv = "latest"
[tasks.prepare-version.env]
GITHUB_REPO = "knitli/codeweaver"
GITHUB_TOKEN = "{{ get_env(name='MISE_GITHUB_TOKEN', default='') }}"
MISE_ENV = "dev"
GIT_CLIFF_REPOSITORY = "{{ get_env(name='CODEWEAVER_PROJECT_PATH', default=config_root) }}"