Thank you for your interest in contributing to Engram. This document covers everything you need to know to participate effectively — whether you're fixing a bug, proposing a feature, improving documentation, or writing a test.
- Code of Conduct
- Ways to Contribute
- Before You Start
- Development Setup
- Project Structure
- Branch & Commit Conventions
- Testing Requirements
- Pull Request Process
- Proposing Features or Architectural Changes
- Reporting Bugs
- Documentation
- Release Process
- Maintainer Notes
This project adheres to the Contributor Covenant Code of Conduct. By participating you agree to uphold it. Report unacceptable behavior to the repository maintainers via a private GitHub message or by email.
| Type | How |
|---|---|
| Bug report | Open a GitHub Issue |
| Feature proposal | Open a GitHub Discussion or Issue |
| Code fix / improvement | Fork → branch → PR (see below) |
| Documentation | Same PR flow; docs live in README.md, docs/, and code-level JSDoc |
| Test coverage | PRs adding tests for uncovered code are always welcome |
| Security issue | See SECURITY.md — do not open a public issue |
- Search existing Issues and Discussions before opening a new one. Your question or proposal may already have a thread.
- For non-trivial changes (new features, refactors touching multiple modules, changes to the MCP API surface), open an Issue or Discussion first to align on direction before writing code.
- For bug fixes or small improvements, feel free to go straight to a PR.
- Node.js v18 or higher
- npm v9 or higher
- A C++ toolchain for
better-sqlite3native compilation:- Windows: Visual C++ Build Tools (
npm install -g windows-build-tools) or "Desktop development with C++" via the Visual Studio Installer - macOS: Xcode Command Line Tools (
xcode-select --install) - Linux:
build-essentialandpython3
- Windows: Visual C++ Build Tools (
# 1. Fork the repo on GitHub, then clone your fork
git clone https://github.com/<your-username>/Engram.git
cd Engram
# 2. Install dependencies
npm install
# 3. Build TypeScript → dist/
npm run build
# 4. Run all tests
npm test# Rebuild on every TypeScript change
npm run dev # tsc --watch
# Run tests once
npm test # vitest run
# Run tests in watch mode
npm run test:watch # vitest
# Run with coverage
npm run test:coverage
# Launch the MCP Inspector against a local build
npm run inspectAfter building, you can point your IDE at the local build by using an absolute
path in your MCP config instead of npx:
{
"servers": {
"engram": {
"type": "stdio",
"command": "node",
"args": [
"/absolute/path/to/Engram/dist/index.js",
"--project-root",
"${workspaceFolder}"
]
}
}
}src/
index.ts Entry point — starts MCP server
database.ts SQLite connection, WAL config, migration runner
migrations.ts All DB schema migrations (append-only)
types.ts Shared TypeScript types
response.ts Response builder helpers — ALL responses go through here
constants.ts Shared constants (limits, defaults)
repositories/ One file per DB entity (sessions, decisions, tasks, …)
services/ Business logic services (git, events, compaction, …)
tools/ MCP tool implementations (dispatcher-memory, dispatcher-admin, …)
modes/ Universal mode server (single-tool BM25 routing)
installer/ IDE detection and config injection logic
tests/
repositories/ Unit tests for all repos
tools/ Smoke tests for dispatchers
services/ Service-level tests
unit/ Isolated utility tests
packages/
engram-thin-client/ Defer-loading proxy (Anthropic API only)
engram-universal-thin-client/ Single-tool universal proxy (all agents)
docs/ Supplemental documentation
These are non-negotiable. Any PR violating them will not be merged:
- All MCP tool responses must go through
src/response.ts(success(),error()). Never return raw objects from tools. - All Zod array params that accept optional string arrays must use
coerceStringArray(). Notz.array(z.string()).optional(). - All logging must use
console.error(neverconsole.log). MCP uses stdout for protocol messages; anything on stdout breaks the transport. - Migrations are append-only. Never modify an existing migration. Always add a new one.
- No breaking changes to the 4-dispatcher API surface without a major version bump.
Use the following naming scheme:
| Type | Pattern | Example |
|---|---|---|
| Feature | feature/<short-description> |
feature/context-pressure-ui |
| Bug fix | fix/<issue-or-description> |
fix/backup-enoent |
| Hotfix | hotfix/<description> |
hotfix/enum-validation |
| Docs | docs/<description> |
docs/contributing-guide |
| Tests | test/<description> |
test/repo-batch-coverage |
| Chore | chore/<description> |
chore/update-deps |
Branch from main. PRs target main.
Engram uses Conventional Commits. Every commit message must follow this format:
<type>(<scope>): <short imperative summary>
[optional body — wrap at 72 chars]
[optional footer(s): Closes #123, BREAKING CHANGE: …]
Types:
| Type | When to use |
|---|---|
feat |
A new feature or behaviour |
fix |
A bug fix |
refactor |
Code restructuring without behaviour change |
test |
Adding or updating tests |
docs |
Documentation only |
chore |
Tooling, deps, config (no production code change) |
perf |
Performance improvement |
ci |
CI/CD pipeline changes |
Scopes (optional but encouraged):
sessions, memory, admin, find, repos, migrations, installer,
universal, thin-client, tests, docs
Examples:
feat(memory): add route_task action for specialization-based routing
fix(sessions): resolve session_start sentinel in what_changed query
docs(contributing): add branch naming and commit conventions
test(repos): add batch file-notes atomicity test
chore: bump better-sqlite3 to 12.6.2
All PRs must pass the full test suite. New functionality must include tests.
npm test # must exit 0 before opening a PR- New actions or tool handlers: Add a smoke test in
tests/tools/. - Repository changes: Add or extend tests in
tests/repositories/. - Migration changes: Verify the migration runs cleanly on both a fresh DB and an existing DB with prior data.
- Bug fixes: Add a regression test that fails before the fix and passes after.
tests/helpers/test-db.ts provides createTestDb() — an in-memory SQLite
instance with all migrations applied. Use it instead of mocking the database.
There is no enforced coverage gate today, but new code should be covered. PRs that dramatically reduce coverage will receive review feedback requesting tests.
- Open a PR against
mainwith a clear title following the Conventional Commits format. - Fill in the PR template (title, what changed, why, how it was tested, any breaking changes).
- Ensure
npm testpasses and the build compiles cleanly withnpm run build. - Keep PRs focused. One logical change per PR. Split large changes into a stack of smaller PRs if possible.
- Respond to review feedback within a reasonable time. PRs with no activity for 30 days may be closed.
- A maintainer will merge once approved. Squash merging is used to keep the main branch history clean.
Before requesting review, confirm:
-
npm run buildsucceeds with no TypeScript errors -
npm testpasses (all tests green) - New behaviour has corresponding tests
- Response helpers from
src/response.tsare used (not raw objects) - No
console.logintroduced (useconsole.error) - Migrations are append-only if schema changed
- Commit messages follow Conventional Commits format
-
RELEASE_NOTES.mdupdated if this is a user-visible change
For anything beyond a bug fix or small improvement:
- Open a GitHub Discussion or Issue describing the problem you want to solve and your proposed solution.
- Wait for feedback from maintainers before writing code. This avoids wasted effort on approaches that won't be accepted.
- Once aligned, implement in a feature branch and open a draft PR early so maintainers can track progress.
Understanding the project's boundaries helps you write proposals that will land:
- No cloud sync or remote database. The memory stays local by design.
- No telemetry or analytics. No data leaves the machine.
- No additional authentication surface. Engram is a local tool.
- No breaking changes to the 4-dispatcher API surface without a major version bump.
- No new top-level tools beyond the 4 dispatchers (or the single universal
tool). New operations go inside an existing dispatcher as a new
action.
Use the Bug Report issue template.
A good bug report includes:
- Engram version (
npx -y engram-mcp-server --checkornpm list engram-mcp-server) - Node.js version (
node --version) - Operating system (Windows / macOS / Linux, with version)
- IDE and AI tool (e.g. VS Code Copilot, Cursor, Claude Desktop)
- Minimal repro steps — exactly what you called, in what order
- Expected behaviour vs actual behaviour
- Relevant error messages or logs (redact any sensitive file paths if needed)
For security issues, see SECURITY.md.
Documentation lives in multiple places:
| Location | Content |
|---|---|
README.md |
Primary user-facing documentation — install, features, reference |
docs/ |
In-depth guides (scheduled events, migration notes, etc.) |
RELEASE_NOTES.md |
User-facing changelog — update for every user-visible change |
| Source-level JSDoc | Inline documentation for complex functions |
Documentation PRs are welcome and valued equally with code PRs.
This section is for maintainers.
- Finalize all changes on
main. - Update
RELEASE_NOTES.mdwith a complete list of changes. - Bump the version in
package.json(follows Semantic Versioning):patch— bug fixes onlyminor— new functionality, backwards-compatiblemajor— breaking changes to the public API
- Run
npm run buildandnpm test— both must pass. - Run
npm pack --dry-runand verify the file list looks correct. - Commit:
chore: vX.Y.Z release — <summary> - Tag:
git tag vX.Y.Z && git push origin vX.Y.Z - Publish:
npm publish
- The
scripts/inject-release-notes.jsscript embeds the latest release notes intopackage.jsonat pack time. It runs automatically via theprepacknpm hook. - The
src/installer/module handles IDE detection and config injection. Always test installer changes against all supported IDEs listed inREADME.md(or mock them via the test suite). - GitHub Actions CI runs
npm teston every push and PR. See.github/workflows/ci.yml.
We appreciate every contribution — code, words, or a well-written bug report. Thank you for helping make Engram better.