Development
This guide covers setting up a development environment and contributing to obx.
Prerequisites
Section titled “Prerequisites”- Go 1.21+: Required for building
- mise (recommended): For tool management
- Git: For version control
Getting Started
Section titled “Getting Started”Clone the Repository
Section titled “Clone the Repository”git clone https://github.com/zach-snell/obx.gitcd obxInstall Dependencies
Section titled “Install Dependencies”mise installThis installs Go and development tools automatically.
# Install Go 1.21+# Then install dev tools:go install github.com/golangci/golangci-lint/cmd/golangci-lint@latestgo install golang.org/x/vuln/cmd/govulncheck@latestmise run build# orgo build -o bin/obx ./cmd/obxRun Tests
Section titled “Run Tests”mise run test# orgo test -race -cover ./...Project Structure
Section titled “Project Structure”obx/├── cmd/│ └── server/│ └── main.go # Entry point├── internal/│ ├── server/│ │ └── server.go # MCP server setup, tool registration│ └── vault/│ ├── vault.go # Vault struct, core helpers│ ├── notes.go # Note CRUD operations│ ├── search.go # Search tools│ ├── frontmatter.go # Frontmatter operations│ ├── tasks.go # Task management│ ├── periodic.go # Periodic notes│ ├── templates.go # Template operations│ ├── graph.go # Link analysis│ ├── canvas.go # Canvas operations│ ├── bulk.go # Bulk operations│ └── *_test.go # Tests├── docs/ # Documentation site├── .mise.toml # mise configuration└── README.mdDevelopment Tasks
Section titled “Development Tasks”Available mise tasks:
| Task | Description |
|---|---|
mise run build | Build the binary |
mise run dev | Run with test vault |
mise run test | Run tests with race detection |
mise run lint | Run golangci-lint |
mise run vuln | Check for vulnerabilities |
mise run check | Run lint + test + vuln |
mise run fuzz | Run all fuzz tests |
mise run docs:dev | Run docs dev server |
mise run docs:build | Build docs for production |
Adding a New Tool
Section titled “Adding a New Tool”1. Implement the Handler
Section titled “1. Implement the Handler”Create or update a file in internal/vault/:
package vault
import ( "context" "github.com/mark3labs/mcp-go/mcp")
func (v *Vault) MyNewToolHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { // Get parameters param := request.Params.Arguments["param"].(string)
// Do the work result, err := v.doSomething(param) if err != nil { return mcp.NewToolResultError(err.Error()), nil }
// Return result return mcp.NewToolResultText(result), nil}2. Register the Tool
Section titled “2. Register the Tool”Add to internal/server/server.go:
// my-new-tools.AddTool( mcp.NewTool("my-new-tool", mcp.WithDescription("Description of what this tool does"), mcp.WithString("param", mcp.Required(), mcp.Description("Parameter description"), ), mcp.WithNumber("optional_param", mcp.Description("Optional parameter"), ), ), v.MyNewToolHandler,)3. Write Tests
Section titled “3. Write Tests”package vault
import ( "testing")
func TestMyNewTool(t *testing.T) { v := setupTestVault(t)
// Test normal case result, err := v.doSomething("input") if err != nil { t.Fatalf("unexpected error: %v", err) }
if result != expected { t.Errorf("got %v, want %v", result, expected) }}4. Update Documentation
Section titled “4. Update Documentation”Add documentation in docs/src/content/docs/tools/.
Testing
Section titled “Testing”Unit Tests
Section titled “Unit Tests”go test ./internal/vault/... -vWith Coverage
Section titled “With Coverage”go test -cover -coverprofile=coverage.out ./...go tool cover -html=coverage.outFuzz Testing
Section titled “Fuzz Testing”# Run all fuzz tests (10s each)mise run fuzz
# Run specific fuzz test longerFUZZ_NAME=ParseTask FUZZ_TIME=60s mise run fuzz:oneIntegration Testing
Section titled “Integration Testing”Test against a real vault:
# Create test vaultmkdir -p test-vault/daily test-vault/templatesecho "# Test" > test-vault/test.md
# Run servermise run devCode Style
Section titled “Code Style”Formatting
Section titled “Formatting”gofmt -w .Linting
Section titled “Linting”mise run lintLinting checks:
- Code style
- Error handling
- Unused code
- Security issues
Pre-commit Checks
Section titled “Pre-commit Checks”Run before committing:
mise run checkDocumentation
Section titled “Documentation”Local Development
Section titled “Local Development”cd docspnpm installpnpm devBuilding
Section titled “Building”mise run docs:buildAdding Pages
Section titled “Adding Pages”- Create
.mdxfile in appropriate directory - Update
astro.config.mjssidebar if needed - Use Starlight components for rich content
Release Process
Section titled “Release Process”Version Bump
Section titled “Version Bump”- Update version in
internal/server/server.go - Update CHANGELOG.md
- Commit:
git commit -m "Release vX.Y.Z" - Tag:
git tag vX.Y.Z - Push:
git push origin main --tags
GitHub Actions handles:
- Running tests on PR
- Building binaries on release
- Publishing to GitHub Releases
- Deploying documentation
Contributing
Section titled “Contributing”Pull Request Process
Section titled “Pull Request Process”- Fork the repository
- Create a feature branch
- Make changes with tests
- Run
mise run check - Submit PR with clear description
Commit Messages
Section titled “Commit Messages”Follow conventional commits:
feat: Add new tool for Xfix: Handle edge case in searchdocs: Update installation guidetest: Add fuzz tests for parser
Code Review
Section titled “Code Review”PRs are reviewed for:
- Correctness
- Test coverage
- Documentation
- Performance
- Security
Getting Help
Section titled “Getting Help”- Issues: GitHub Issues
- Discussions: GitHub Discussions