cartographer

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: Apache-2.0

README

 ██████╗ █████╗ ██████╗ ████████╗ ██████╗  ██████╗ ██████╗  █████╗ ██████╗ ██╗  ██╗███████╗██████╗
██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██╔═══██╗██╔════╝ ██╔══██╗██╔══██╗██╔══██╗██║  ██║██╔════╝██╔══██╗
██║     ███████║██████╔╝   ██║   ██║   ██║██║  ███╗██████╔╝███████║██████╔╝███████║█████╗  ██████╔╝
██║     ██╔══██║██╔══██╗   ██║   ██║   ██║██║   ██║██╔══██╗██╔══██║██╔═══╝ ██╔══██║██╔══╝  ██╔══██╗
╚██████╗██║  ██║██║  ██║   ██║   ╚██████╔╝╚██████╔╝██║  ██║██║  ██║██║     ██║  ██║███████╗██║  ██║
 ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝   ╚═╝    ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝

MCP governance server in Go for the Agentic Wiki — knowledge that composes, not that you query.

CI Release Go Report Card License Go MCP

[!WARNING] Beta software. Cartographer is pre-1.0: the MCP tool surface, CLI and configuration may change between minor releases without a deprecation period. Breaking changes bump the minor version (0.x semantics) and are called out in the changelog. Expect rough edges — bug reports are very welcome.

LLM agents forget everything between sessions, and stateless RAG only bolts retrieval onto that amnesia. The alternative is a knowledge base the agent itself builds and maintains over time — but letting an agent loose on a folder of files ends in broken links, lost history, and silent corruption. Cartographer is the governance layer that makes the pattern safe: the agent works the wiki exclusively through MCP tools, and the server enforces every invariant — validation, linking, immutability gates, one git commit per write.

Demo

What is it

Cartographer implements the Agentic Wiki: a persistent knowledge base of interlinked Markdown files that an LLM agent grows and curates by talking to the server over the MCP protocol. The agent never touches the files directly.

The wiki is grounded in Karpathy's "LLM Wiki" pattern (operating model: knowledge accretes over time, it is not stateless RAG) on top of the OKF substrate (Open Knowledge Format v0.1 by Google Cloud) — each KB is a folder of .md files with YAML frontmatter, self-contained and version-controlled with git. Zero lock-in: the wiki is readable by any tool, including Obsidian and any text editor.

Cartographer offers two complementary profiles:

  • Local Core — single agent, stdio transport, local git. Captures the value of the pattern with minimal complexity.
  • Server — multi-KB, HTTP + token auth, optional semantic embeddings. For shared and remote deployments.

Key features

  • 🔧 Full MCP tool suite — complete list in docs/control-plane.md
  • 📖 Read & navigation — kb_overview, concept_read, archive_list / dossier_list, graph_neighbors
  • 🔍 Search — keyword (pure-Go inverted index) plus optional hybrid semantic search via Ollama
  • ✍️ Validated writes with optimistic concurrency (if_match / content-hash)
  • 🛡️ Governance — deterministic lint (broken link, stale claim, orphan), commit_gate, gate_check, supersede, contradiction tracking
  • 🧬 Transactional git — one commit per write operation; optional synchronization to a remote (fetch/pull-rebase before and push after every write) — git as a sync layer across multiple instances; agentic conflict handling (concepts flagged degraded + conflicts_list tool + guided skill)
  • 🗂️ Multi-KB with ?kb=<name> routing; bearer-token auth with scopes / RBAC
  • 🔐 Audit log — append-only with hash-chain and Ed25519 signature
  • 🧩 Domain skills (SKILL.md / agentskills.io format) with provisioning and client↔server sync
  • 🔑 Secrets via SOPS — references only, plaintext values never stored
  • ⚙️ Multi-provider configurator — generates MCP config for Claude Code, Codex CLI, Kiro, OpenCode
  • 📦 OKF-compliant — each KB is an OKF bundle and a standalone git repo, zero lock-in (just git + Markdown)

Architecture

Cartographer separates a data plane from a control plane:

  • Data plane — the KB itself: OKF Markdown files under data/, organized as archive → dossier → concept. Plain files + git: history, diff, backup, sharing for free.
  • Control plane — the MCP tools the agent calls. The server applies every invariant (validation, gates, immutability) so the agent operates safely without direct filesystem access.

The interaction rests on the MCP + Skill + Hook triad: MCP carries data and capabilities, Skills carry procedural know-how loaded on demand, Hooks carry deterministic 0-token automation.

flowchart LR
    A["🤖 Agent (LLM)<br/><i>only via MCP — never touches files</i>"]
    S["Cartographer<br/>Go MCP server<br/><i>invariants enforced server-side</i>"]
    KB[("KB<br/>Markdown + git")]
    R[("remote git")]
    A -- "MCP tools" --> S
    S -- "bounded reads" --> A
    S -- "one commit<br/>per write" --> KB
    KB -. "sync in/out" .-> R

Install

# macOS (Homebrew)
brew install beppetemp/tap/cartographer

# Linux / macOS without Homebrew
curl -fsSL https://raw.githubusercontent.com/BeppeTemp/cartographer/main/install.sh | sh

# From source (Go 1.26+)
go install github.com/BeppeTemp/cartographer/cmd/cartographer@latest

Quick start

# Local stdio (Local Core)
cartographer serve --kb /path/to/kb --init

# HTTP multi-KB (Server profile, auth disabled)
CARTOGRAPHER_KB=/data/kb CARTOGRAPHER_HTTP=:8080 CARTOGRAPHER_AUTH=false \
  cartographer serve

# HTTP with auth
CARTOGRAPHER_KB=/data/kb CARTOGRAPHER_HTTP=:8080 CARTOGRAPHER_AUTH=true \
  CARTOGRAPHER_TOKENS=mytoken cartographer serve

# Local native service (launchd on macOS, systemd user unit on Linux)
cartographer service install   # generates config, installs and starts the service
cartographer service status    # exit 0 running / 3 stopped / 4 not installed

# Connect an agent client (Claude Code, OpenCode, Codex, Kiro) to a running server
cartographer connect
cartographer status   # drift check: exit 0 in-sync / 1 drift / 2 error
cartographer sync     # re-apply after drift

connect with no flags in a TTY opens an interactive form (server URL, server name, token env var, auth) instead of the flag defaults; pass --no-input to force the non-interactive behavior.

Configuration

Environment variable Default Description
CARTOGRAPHER_KB — KB path(s) (single, or multiple comma-separated)
CARTOGRAPHER_DATA — Directory whose subfolders are auto-discovered KBs
CARTOGRAPHER_HTTP — HTTP address (e.g. :8080). Absent = stdio only
CARTOGRAPHER_AUTH auto true / false / unset (auto on HTTP)
CARTOGRAPHER_TOKENS — Comma-separated bearer tokens
CARTOGRAPHER_GIT_AUTOCOMMIT true One git commit per write operation
CARTOGRAPHER_GIT_SYNC true fetch/pull-rebase + push on origin around each write
CARTOGRAPHER_OLLAMA — Ollama server URL for semantic search
CARTOGRAPHER_OLLAMA_MODEL nomic-embed-text Ollama embedding model
CARTOGRAPHER_AUDIT_LOG — Audit log file path
CARTOGRAPHER_AUDIT_KEY — Ed25519 key for audit signing

Full list with CLI flags and defaults → docs/deployment.md.

Building and testing

make build         # → bin/cartographer
make test          # Unit tests (go test ./...)
make smoke         # stdio smoke test
make smoke-http    # operator-level HTTP smoke test (creates temp KBs via curl)
make e2e           # agent-level E2E tests with headless OpenCode (9 scenarios)
make e2e-quick     # CRUD scenario only

The E2E harness drives OpenCode in headless mode as a real agent against a local server, using a deliberately economical model as a clarity gate: if a cheap model can complete the mandates, the system is clear enough for production. It needs an OpenAI-compatible endpoint (E2E_LLM_BASE_URL); full strategy → docs/testing.md.

Project structure

cmd/
  cartographer/main.go      # Entry point: subcommand dispatch (serve/version/help/agents/connect/status/sync)
  cartographer/serve.go     # Server: flags + env vars + YAML config, stdio/HTTP
  cartographer/tui.go       # Interactive dashboard (no-args, TTY)
internal/
  config/                   # Server YAML config (flag > env > YAML > default)
  okf/                      # OKF primitives: ConceptID, frontmatter, content-hash
  kb/                       # Data plane: Open, Init, Read/WriteConcept, Validate
  kb/graph.go               # Graph navigation: ExtractLinks, GraphNeighbors
  kb/gate.go                # CommitGate
  kb/gitsync.go             # Transactional git: lock, commit, sync in/out
  kb/conflicts.go           # Conflict registry, MarkDegraded
  mcpserver/                # MCP server: stdio, HTTP handler, MultiKBServer, tools (split by domain)
  mcpserver/gitwrap.go      # Write wrapper: lock + commit + sync
  search/                   # Pure-Go inverted index
  sqlindex/                 # Persisted SQLite index: FTS5 trigram + embedding cache
  lint/                     # Deterministic lint
  gitx/                     # git wrapper: commit, rebase, push, fetch, stash
  audit/                    # Audit log: JSONL hash-chain + Ed25519
  auth/                     # TokenStore, middleware, RBAC, scopes
  embed/                    # Embedder interface + Ollama adapter + vector store
  skill/                    # SKILL.md loader and validator (agentskills.io)
  sops/                     # SOPS decryption wrapper
  configurator/             # Multi-provider adapters, HTTP-only (Claude Code, Codex, Kiro, OpenCode)
  provisioning/             # Manifest, lock (v1/v2 multi-provider), diff, apply — client↔server sync
  agents/                   # Detect() installed agent CLIs on this machine
  clientconfig/             # .cartographer.yaml (server URL, connected agents)
  client/                   # Minimal MCP client (JSON-RPC over HTTP) for the client subcommands
docs/                       # Full documentation (see docs/index.md)
test/e2e/                   # Agent-level E2E harness

Documentation

The full index lives in docs/index.md. Main entry points:

Contributing

Issues and PRs are welcome — see CONTRIBUTING.md for the build/test loop, the PR flow (squash-merge, conventional titles, docs updated in the same PR), and how to find your way around the codebase. Cartographer is a personal project maintained on a best-effort basis: no response-time SLA. For security reports, see SECURITY.md.

License

Released under the Apache License 2.0. See LICENSE.

Directories

Path Synopsis
cmd
cartographer command
connectform.go implements the connect form as a standalone bubbletea component: server URL, server name, token env var, auth toggle, and trust toggle.
connectform.go implements the connect form as a standalone bubbletea component: server URL, server name, token env var, auth toggle, and trust toggle.
internal
agents
Package agents detects which LLM agent CLIs/apps are installed on the local machine (Claude Code, OpenCode, Codex CLI, Kiro), so `cartographer agents` and `cartographer connect all` know which providers to target.
Package agents detects which LLM agent CLIs/apps are installed on the local machine (Claude Code, OpenCode, Codex CLI, Kiro), so `cartographer agents` and `cartographer connect all` know which providers to target.
blocktext
Package blocktext implements the marker-delimited "managed block" primitive used by every Cartographer feature that must own a slice of a hand-curated user file (comments, ordering, everything else preserved) without parsing the file's own format: the Codex MCP server entry and per-hook registrations in config.toml (D58, TOML `#` comment markers).
Package blocktext implements the marker-delimited "managed block" primitive used by every Cartographer feature that must own a slice of a hand-curated user file (comments, ordering, everything else preserved) without parsing the file's own format: the Codex MCP server entry and per-hook registrations in config.toml (D58, TOML `#` comment markers).
client
Package client implements a minimal MCP client over HTTP (JSON-RPC 2.0), used by `cartographer agents/connect/status/sync` to talk to a remote cartographer server.
Package client implements a minimal MCP client over HTTP (JSON-RPC 2.0), used by `cartographer agents/connect/status/sync` to talk to a remote cartographer server.
clientconfig
Package clientconfig reads and writes the client-side `.cartographer.yaml` file: the record of which server this machine talks to and which agent providers have been connected via `cartographer connect`.
Package clientconfig reads and writes the client-side `.cartographer.yaml` file: the record of which server this machine talks to and which agent providers have been connected via `cartographer connect`.
config
Package config provides the YAML-based server configuration for `cartographer serve`, merged with environment variables and CLI flags.
Package config provides the YAML-based server configuration for `cartographer serve`, merged with environment variables and CLI flags.
configurator
Package configurator generates MCP configuration files for multiple LLM providers (Claude Code, Codex CLI, Kiro, OpenCode).
Package configurator generates MCP configuration files for multiple LLM providers (Claude Code, Codex CLI, Kiro, OpenCode).
gitx
Package gitx provides a git wrapper via os/exec for the Agentic Wiki.
Package gitx provides a git wrapper via os/exec for the Agentic Wiki.
kb
Package kb — conflict registry and degraded-marker support (Step 3).
Package kb — conflict registry and degraded-marker support (Step 3).
lint
Package lint implements deterministic lint checks on a KB scope.
Package lint implements deterministic lint checks on a KB scope.
mcpserver
Package mcpserver implements an MCP (Model Context Protocol) server over stdio, based on newline-delimited JSON-RPC 2.0, with no external dependencies.
Package mcpserver implements an MCP (Model Context Protocol) server over stdio, based on newline-delimited JSON-RPC 2.0, with no external dependencies.
okf
Package okf — parser/serializer for the YAML subset used in OKF frontmatter.
Package okf — parser/serializer for the YAML subset used in OKF frontmatter.
provisioning
bootstrap.go (D60) — the "cartographer-bootstrap" hook: a synthetic artifact, generated entirely by the client (not by the server/KB manifest), that at session start silently runs `cartographer sync --auto-trust` so the LLM agent always starts aligned with the server, without the user having to run `sync` by hand.
bootstrap.go (D60) — the "cartographer-bootstrap" hook: a synthetic artifact, generated entirely by the client (not by the server/KB manifest), that at session start silently runs `cartographer sync --auto-trust` so the LLM agent always starts aligned with the server, without the user having to run `sync` by hand.
repoindex
Package repoindex resolves `{{repo:<key>}}` placeholders (D75) to a local clone path: it scans a set of search roots for git repositories, reads each one's `origin` remote from `.git/config` (no `git` exec — the file is parsed directly, see readOriginURL), and normalizes the remote URL to a canonical "host/owner/name" key that is stable across every machine on the team.
Package repoindex resolves `{{repo:<key>}}` placeholders (D75) to a local clone path: it scans a set of search roots for git repositories, reads each one's `origin` remote from `.git/config` (no `git` exec — the file is parsed directly, see readOriginURL), and normalizes the remote URL to a canonical "host/owner/name" key that is stable across every machine on the team.
search
Package search implements an in-memory inverted keyword index for KB concepts.
Package search implements an in-memory inverted keyword index for KB concepts.
service
Package service manages the cartographer MCP server as a native per-user service: a launchd agent on macOS, a systemd user unit on Linux.
Package service manages the cartographer MCP server as a native per-user service: a launchd agent on macOS, a systemd user unit on Linux.
skill
Package skill implements loading and validation of SKILL.md files (agentskills.io format).
Package skill implements loading and validation of SKILL.md files (agentskills.io format).
sqlindex
Package sqlindex implements a persistent SQLite-backed keyword and embedding index with per-content-hash embedding caching.
Package sqlindex implements a persistent SQLite-backed keyword and embedding index with per-content-hash embedding caching.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL