Contributing
We welcome contributions to bz! This guide explains how to get started.
Ways to Contribute
- Report bugs - Open an issue describing the problem
- Suggest features - Open an issue with your idea
- Improve documentation - Fix typos, add examples, clarify explanations
- Submit code - Fix bugs or implement features
Development Setup
-
Fork and clone
Terminal window git clone https://github.com/YOUR-USERNAME/bz.gitcd bz -
Install dependencies
Terminal window go mod download -
Build
Terminal window go build -o bz . -
Run tests
Terminal window go test ./... -
Set up dev workflow
The project uses
justas a task runner andlefthookfor Git hooks. Install both, then run:Terminal window lefthook installSee the
justfilefor available recipes (e.g.,just test,just lint).
Code Structure
bz/├── cmd/ # CLI commands (Cobra)│ ├── mod/ # mod subcommands (search, sync, etc.)│ ├── registry/ # registry subcommands│ └── root.go # Root command├── internal/ # Internal packages│ ├── bzconfig/ # bz configuration loading│ ├── cli/ # CLI helpers│ ├── cmdutil/ # Command utilities│ ├── config/ # Configuration types│ │ └── modules/ # Module configuration│ ├── depgraph/ # Dependency graph│ ├── envutil/ # Environment utilities│ ├── modsync/ # Module sync service│ ├── module/ # Module types│ ├── modulearg/ # Module argument parsing│ ├── osv/ # OSV vulnerability data│ ├── publisher/ # Publisher implementations│ ├── registry/ # Registry implementations│ ├── starlark/ # Starlark interpreter│ │ ├── builtins/ # Built-in Starlark functions│ │ ├── convertutil/ # Starlark conversion utilities│ │ └── value/ # Starlark value types│ ├── testutil/ # Test utilities│ ├── tui/ # Terminal UI components│ └── version/ # Version information├── docs/ # Documentation (Starlight)├── justfile # Task runner recipes (just)├── lefthook.yml # Git hooks configuration└── main.go # Entry pointMaking Changes
-
Create a branch
Terminal window git checkout -b feature/my-feature# orgit checkout -b fix/my-bugfix -
Make your changes
- Follow existing code style
- Add tests for new functionality
- Update documentation if needed
-
Run tests
Terminal window go test ./... -
Run linter
Terminal window go tool -modfile=tools.go.mod golangci-lint run --config=tools/lint/golangci.toml -
Commit
Terminal window git add .git commit -m "feat: add my feature"Use Conventional Commits:
feat:- New featurefix:- Bug fixdocs:- Documentationrefactor:- Code refactoringtest:- Testschore:- Maintenance
-
Push and create PR
Terminal window git push origin feature/my-featureThen open a Pull Request on GitHub.
Pull Request Guidelines
- Keep PRs focused - one feature or fix per PR
- Include tests for new functionality
- Update documentation if behavior changes
- Ensure all tests pass
- Respond to review feedback
Testing
Unit Tests
# Run all testsgo test ./...
# Run tests with coveragego test -cover ./...
# Run specific package testsgo test ./internal/registry/...Integration Tests
# Build and test CLIgo build -o bz ../bz mod search rules_go./bz mod info rules_goDocumentation
Documentation lives in docs/ and uses Starlight.
Local Development
cd docsbun installbun run devVisit http://localhost:4321/bz/ to preview.
Note: We use bun as the package manager for the docs. Do not use npm or yarn.
Writing Docs
- Use MDX format (
.mdxfiles) - Keep explanations clear and concise
- Include code examples
- Test that code examples work
Questions?
- Open a Discussion for questions
- Open an Issue for bugs or features
Thank you for contributing!