Thanks for your interest in contributing to Cortex. This document covers how to build, test, and submit changes.
- Rust 1.75+ (install via rustup)
- A C compiler (for tree-sitter grammar compilation)
- Git
git clone https://github.com/1337Xcode/cortex.git
cd cortex
cargo build --releaseThe build compiles all tree-sitter grammars from source via build.rs. No network downloads happen at build time. First build takes 3-5 minutes. Incremental builds take 20-40 seconds.
For development iteration, use cargo check for fast type checking without full compilation.
# Run all tests
cargo test
# Run unit tests only
cargo test --lib
# Run integration tests only
cargo test --test '*'
# Run tests for a specific module
cargo test store::
cargo test indexer::
cargo test mcp::Integration tests use fixture repositories in tests/fixtures/. Some tests require the binary to be built first:
cargo build --release
cargo test --test integrationsrc/
├── main.rs Entry point, CLI wiring
├── config.rs Configuration loading
├── error.rs Top-level error types
├── mcp/ MCP server (JSON-RPC 2.0 over stdio)
├── indexer/ tree-sitter parsing and graph extraction
├── watcher/ File system event watching
├── store/ SQLite database (the only module that touches DB)
├── security/ Taint analysis, OWASP, SBOM
├── memory/ Cross-session observation management
├── bundle/ JSON export/import for team sharing
├── agents/ IDE/agent auto-configuration
└── cli/ Subcommand definitions
- Run
cargo fmtbefore committing - Run
cargo clippyand fix all warnings - Follow the dependency rules in
.agent/instructions.md: onlystore/may open database connections
- Fork the repository
- Create a feature branch:
git checkout -b my-feature - Make your changes with tests
- Run the full test suite:
cargo test - Run formatting and lints:
cargo fmt && cargo clippy - Commit with a clear message describing what and why
- Push to your fork and open a pull request
- Keep PRs focused on a single change
- Include tests for new functionality
- Update documentation if behavior changes
- Reference any related issues in the PR description
To add a new tree-sitter language:
- Add the grammar crate to
Cargo.toml - Add the grammar compilation to
build.rs - Create
src/indexer/languages/{language}.rswith extraction logic - Add file extension mapping in
src/indexer/parser.rs - Add fixture tests in
tests/unit/parser/ - Update the language table in
docs/architecture.mdandREADME.md
Before cutting a release, run the release readiness checks:
node scripts/verify-release.jsThis verifies:
- Archive naming consistency across the release workflow, install.js, and install.sh
- Documentation link integrity (all relative links resolve to existing files)
- Version string consistency across Cargo.toml, npm/package.json, and CHANGELOG.md
All checks must pass before tagging a release.
- Use GitHub Issues for bug reports and feature requests
- Include Cortex version (
cortex --version), OS, and reproduction steps - For crashes, include the full error output
See SECURITY.md for reporting security vulnerabilities.