Thank you for your interest in contributing to Trinity! This document provides guidelines for contributing to the project.
- Fork the repository
- Create a branch:
git checkout -b feat/issue-{N} - Make your changes
- Run tests:
zig build test - Format code:
zig fmt src/ - Commit:
git commit -m "feat(scope): description (#N)" - Push and create PR
- Zig 0.15.x — Required for building the project
- Git — For version control
- GitHub CLI — Optional, for issue management
# Clone your fork
git clone https://github.com/YOUR_USERNAME/trinity.git
cd trinity
# Build TRI CLI
zig build tri
# Run all tests
zig build test
# Build specific components
zig build vibee # VIBEE compiler
zig build firebird # Firebird LLM
zig build tri-api # Agentic loop# Run all tests
zig build test
# Run specific test
zig test src/vsa/vsa.zig
# Run with verbose output
zig build test -- -fno-test-exec-time- Use
zig fmtbefore committing - Configure your editor to run
zig fmton save - CI will check formatting automatically
- Functions:
camelCasefor public,snake_casefor private - Types:
PascalCasefor structs, enums, unions - Constants:
UPPER_SNAKE_CASE - Files:
snake_case.zig
// ✅ Good: Return errors
pub fn doSomething(allocator: Allocator) !void {
const result = try mightFail();
// ...
}
// ❌ Bad: Panic on errors
pub fn doSomething(allocator: Allocator) void {
const result = mightFail() catch unreachable; // Don't do this
}- Use explicit allocators
- Document allocator requirements
- Clean up allocations in error paths
- Prefer
deferfor cleanup
Trinity uses a state machine for development:
IDLE → ACTIVE → DIRTY → TESTED → COMMITTED → SHIPPED
Commands:
tri dev start --issue <N> # Start session for issue
tri dev test # Run tests
tri dev commit "msg" # Commit with issue ID
tri dev ship # Mark as delivered
tri dev reset # Reset changesAll significant changes should be tracked via GitHub issues:
- Create or claim an issue
- Create branch:
feat/issue-{N}orfix/issue-{N} - Implement following the spec (if
.trispec exists) - Reference issue in commit:
feat(scope): description (#N) - Create PR with
Closes #N
Follow Conventional Commits:
<type>(<scope>): <description> (#<issue>)
[optional body]
[optional footer]
Types:
feat— New featurefix— Bug fixrefactor— Code refactoringdocs— Documentation changestest— Adding or updating testschore— Maintenance tasks
Examples:
feat(vsa): add hypervector similarity search (#123)
fix(cli): handle empty input in tri command (#456)
docs(readme): update installation instructions (#789)
test "description of what is being tested" {
// Arrange
const allocator = std.testing.allocator;
// Act
const result = try functionUnderTest(allocator);
defer allocator.free(result);
// Assert
try std.testing.expectEqual(expected, result);
}- Aim for high test coverage on core modules
- Test error paths explicitly
- Include edge cases and boundary conditions
- Document non-obvious test behavior
- Keep README.md in sync with code changes
- Update command registry when adding commands
- Document new APIs in appropriate
.mdfiles - Run
docs-checkworkflow to validate
/// Brief description of what this does.
///
/// More detailed explanation if needed.
/// Can span multiple lines.
pub fn publicFunction() void {
// Implementation comments explain WHY, not WHAT
// (Code itself shows WHAT)
}- Code Review: Self-review your changes
- Tests: Ensure all tests pass
- Format: Run
zig fmt src/ - Docs: Update relevant documentation
- Commits: Squash fix-up commits, write clear messages
## Summary
Brief description of changes.
## Related Issue
Closes #N
## Changes
- Change 1
- Change 2
## Testing
- [ ] Tests pass locally
- [ ] Added new tests for new functionality
- [ ] Manual testing completed
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated- Documentation: docs/DOCUMENTATION_INDEX.md
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Search existing issues and discussions
- Check documentation index
- Create an issue with the
questionlabel
By contributing, you agree that your contributions will be licensed under the MIT License.