Developing Berry¶
This guide covers setting up a local development environment for the Berry project.
Prerequisites¶
Setup¶
# Clone the repository
git clone https://github.com/geoffjay/berry-rs.git
cd berry
# Build all packages
cargo build
# Run tests
cargo test --all
Running the Services¶
Berry uses LanceDB by default (embedded, no setup needed). You only need to run the Berry server.
If you want to use ChromaDB instead, start it first:
Start Berry Server¶
In development mode (with debug logging):
Or build and run the release binary:
CLI Development¶
Configuration¶
Create ~/.config/berry/config.jsonc:
{
"store": "lance",
"server": {
"url": "http://localhost:4114",
"timeout": 5000
},
"defaults": {
"type": "information",
"createdBy": "user"
},
"lance": {
"table": "berry_memories"
}
}
Running the CLI¶
During development:
cargo run -p berry-cli -- --help
cargo run -p berry-cli -- remember "test memory"
cargo run -p berry-cli -- search "test"
Or build and use directly:
Testing Commands¶
# Store a memory
cargo run -p berry-cli -- remember "The API uses JWT tokens"
# Search memories
cargo run -p berry-cli -- search "authentication"
# Recall by ID
cargo run -p berry-cli -- recall mem_1234567890_abcdef
# Delete a memory
cargo run -p berry-cli -- forget mem_1234567890_abcdef
Building¶
Debug Build¶
Binaries are placed in target/debug/:
- target/debug/berry
- target/debug/berry-server
- target/debug/berry-mcp
Release Build¶
Binaries are placed in target/release/.
Running Tests¶
# Run all tests
cargo test --all
# Run tests for a specific crate
cargo test -p berry
# Run tests with output
cargo test --all -- --nocapture
Code Formatting¶
Linting¶
Adding New Features¶
Adding a New Memory Field¶
- Update the
Memorystruct incrates/berry/src/types/memory.rs - Update
CreateMemoryRequestincrates/berry/src/types/requests.rs - Update the ChromaDB metadata conversion in
crates/berry/src/store/chroma.rs - Add CLI flags in
crates/cli/src/main.rs - Update server routes as needed
Adding a New CLI Command¶
- Create a new module in
crates/cli/src/commands/ - Export the module in
crates/cli/src/commands/mod.rs - Add the subcommand to the
Commandsenum incrates/cli/src/main.rs - Handle the command in the main match statement
Adding a New API Endpoint¶
- Create a handler in
crates/server/src/routes/ - Export the handler in
crates/server/src/routes/mod.rs - Add the route in
crates/server/src/main.rs
Debugging¶
Enable Debug Logging¶
Available log levels: error, warn, info, debug, trace
JSON Log Format¶
Testing ChromaDB Connection¶
Testing Server Health¶
Contributing¶
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
cargo test --all - Run clippy:
cargo clippy --all-targets - Format code:
cargo fmt --all - Submit a pull request
Troubleshooting¶
Cargo build fails with "edition 2024"¶
Ensure you have Rust 1.75+ installed:
ChromaDB connection refused (if using ChromaDB)¶
Ensure ChromaDB is running:
Start it if needed:
Tests fail with network errors¶
Some integration tests may require external services (ChromaDB, Ollama) to be running. Tests that require external services should be marked appropriately.