Developer Reference

Documentation

Operational setup for treedb-repo-mcp, @snissn/pi-treedb, commit-pinned overlays, code-linked agent memory, and the Go TreeDB storage engine.

1. Install & Binary Verification

Prebuilt static CGO_ENABLED=0 binaries are published for darwin/arm64, darwin/amd64, linux/arm64, and linux/amd64. The POSIX installer verifies SHA256SUMS via sha256sum, shasum, or openssl before placing the binary in ~/.local/bin:

curl -fsSL https://treedb.dev/install.sh | sh

# Pin a specific release or custom install path:
TREEDB_MCP_VERSION=v0.2.0 TREEDB_MCP_INSTALL_DIR=/usr/local/bin \
  sh -c "$(curl -fsSL https://treedb.dev/install.sh)"

2. Multi-Repo Control Plane (repos.toml)

Run one multiplexed daemon across all local repositories with unified health, watcher telemetry, and safe fast-forward git polling (--git-poll 60s skips dirty, detached, or diverged worktrees automatically):

treedb-repo-mcp repo add ~/dev/project-a
treedb-repo-mcp repo add ~/dev/project-b --no-github
treedb-repo-mcp repos status
treedb-repo-mcp sync --config ~/.config/treedb-mcp/repos.toml
treedb-repo-mcp daemon --config ~/.config/treedb-mcp/repos.toml --http 127.0.0.1:7337

3. Commit-Pinned Fail-Closed Queries (ref)

Pass ref (commit SHA, branch, or tag) to search, search_code, phrase_search, find_symbol, get_file_context, or CLI query --ref:

  • Zero-cost fast path: When the clean indexed base commit equals ref, queries execute directly against TreeDB with zero overlay overhead.
  • Exact delta overlay: When ref is ahead or on another branch/tag, treedb-repo-mcp computes git diff-tree, masks modified/deleted base paths, and overlays exact git cat-file blobs in memory.
  • Fail-closed safety: Invalid refs, dirty bases, or diffs exceeding 500 files / 32 MiB return an explicit error rather than silently returning drifted code.

4. Code-Linked Agent Memory (agent_memories)

Store architectural facts, decisions, and gotchas directly inside TreeDB with memory_retain, memory_recall, and memory_invalidate:

  • Automatic code-drift detection: Memories linked via linked_paths and linked_commit_sha are checked against ref on recall and surface stale_code_warning: true + changed_paths whenever those files move.
  • Secret-scanning gate: Rejects AWS keys, GitHub tokens, JWTs, PEM private keys, and high-entropy credentials across body, title, namespace, and tags before persistence.

5. Pi Extension (@snissn/pi-treedb) & OpenTelemetry

Install the native Pi package from npm to get workspace-scoped auto-HEAD pinning, prompt-cache-safe first-turn memory recall, [STALE CODE] prefix badges, /treedb-stats, and pi-otel spans:

pi install npm:@snissn/pi-treedb

6. Go Storage Engine & Module Path

treedb.dev already serves vanity go-import metadata pointing to github.com/snissn/treedb in preparation for the standalone root-module cutover (snissn/gomap#5972). While active pre-cutover work finishes in snissn/gomap, import github.com/snissn/gomap/TreeDB:

opts := treedb.OptionsFor(treedb.ProfileCommandWALDurable, "./data")
db, err := treedb.Open(opts)
if err != nil {
	log.Fatal(err)
}
defer db.Close()

Production durability profiles: ProfileCommandWALDurable (recommended server default), ProfileCommandWALRelaxed (high-throughput ingest), and ProfileNoWALFast (explicit sync boundary).