Commit 3b2cf74
feat(tools): add cargo-stow for Cargo.toml validation and enforcement (#2961)
## Summary
Introduces `cargo stow`, a workspace linting tool that validates and
fixes Cargo.toml files to enforce project conventions.
### Features
- **Validation Rules:**
- Flat crate structure (no nested crates under `crates/`)
- Crate naming conventions (`baml_<word>` or `baml_<prefix>_<word>`)
- Test crate pairing (e.g., `baml_ide_tests` requires `baml_ide`)
- Workspace dependency format (`{ workspace = true }`)
- Dependency restriction rules (e.g., `anyhow` only in CLI/test crates)
- Dependency sorting (internal deps first, then external)
- **Auto-fix capability:** Run `cargo stow --fix` to automatically fix
sortable/formattable issues
- **Runtime configuration:** Configure via `stow.toml` or
`[workspace.metadata.stow]` in Cargo.toml - no recompilation needed to
change rules
### Integration
- Added `cargo-stow` CI job that runs on every PR
- Integrated into pre-commit hooks via `setup-hooks.sh`
### Usage
```bash
# Check for validation errors
cargo stow --check
# Automatically fix issues
cargo stow --fix
# Verbose output
cargo stow --check --verbose
```
## Test plan
- [x] `cargo stow --check` passes on the current workspace
- [x] Pre-commit hook runs stow check
- [x] CI workflow includes cargo-stow job
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>1 parent 221c79e commit 3b2cf74
35 files changed
Lines changed: 5256 additions & 3368 deletions
File tree
- .github/workflows
- baml_language
- .claude
- architecture
- crates
- baml_base
- baml_builtins_macros
- baml_cli
- baml_compiler_diagnostics
- baml_compiler_emit
- baml_compiler_hir
- baml_compiler_lexer
- baml_compiler_parser
- baml_compiler_syntax
- baml_compiler_tir
- baml_compiler_vir
- baml_db
- baml_ide_tests
- baml_ide
- baml_lsp_types
- baml_lsp
- baml_playground_wasm
- baml_project
- baml_tests
- baml_tools_onionskin
- baml_tools_stow
- src
- baml_vm_types
- baml_vm
- baml_workspace
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
208 | | - | |
| 207 | + | |
| 208 | + | |
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 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 | + | |
203 | 228 | | |
204 | 229 | | |
205 | 230 | | |
| |||
300 | 325 | | |
301 | 326 | | |
302 | 327 | | |
| 328 | + | |
303 | 329 | | |
304 | 330 | | |
305 | 331 | | |
| |||
309 | 335 | | |
310 | 336 | | |
311 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
312 | 343 | | |
313 | 344 | | |
314 | 345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
0 commit comments