apo
Health Uyari
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 5 GitHub stars
Code Gecti
- Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
Local vault data for AI agents — typed schemas on disk, contract-governed, searchable. Files are the source of truth; the index is rebuildable.
Local vault data for AI agents
Typed schemas on disk, contract-governed, searchable.
Files are the source of truth; the index is rebuildable.
Quickstart · Onboard · Contracts · Multi-vault
- Why Apo
- Vault data & contracts
- Features
- Architecture
- Quick start
- How agents use it
- MCP tools
- Configuration
- Docs
- Boundaries
Why Apo
Most “AI memory” stacks ask you to trust a second database. Apo treats a folder of Markdown and YAML you already own as a local data plane for agents: typed records, contract-governed writes, structured query, and hybrid search over the same files.
| Approach | Source of truth | What agents edit | Ops |
|---|---|---|---|
| Cloud memory APIs | Vendor store | Opaque records | Account, network, retention policy |
| Vector DB + sync job | Vectors (+ maybe files) | Often the DB, not the note | Schema, embeddings pipeline |
| Spreadsheet / SaaS DB + RAG | Proprietary rows | The SaaS UI or a parallel upload | Schema drift, access silos |
| Apo | Your .md / .yaml files |
The same files you open in an editor | One machine, vault contracts, optional watcher |
You keep Obsidian / git / plain-text workflows. Agents filter and surgically update typed fields through MCP, and use hybrid search when meaning recall beats exact catalog queries. Delete index.db anytime — rebuild with just reindex. Embeddings (Ollama bge-m3 by default) are how Apo updates the card catalog after the shelves change — pride of craft, not the product identity.
Stack rank: vault data plane → contracts → filter_notes / surgical writes → hybrid search → OKF interchange. Apo is not “an OKF product”; Open Knowledge Format is the flagship contract for typed Knowledge Bundles.
Vault data & contracts
Apo indexes arbitrary YAML frontmatter (Markdown), standalone YAML mappings,
and top-level JSON objects into sqlite. JSON writes preserve the exact supplied
representation and never receive OKF/frontmatter wrappers. Arrays and scalars stay
on disk but return unsupported_json_top_level and are omitted from the catalog.
Invalid JSON is rejected by mutators and omitted by direct/rebuild indexing.
Git-ref catalogs apply the same object-only rule.filter_notes is the catalog API; patch_note / set_field mutates rows in place.
# examples — any key you put in frontmatter / YAML notes is fair game
filter_notes(where={"okf_type": "EvidenceRequest", "status": "open"}, folder="projects/…")
filter_notes(where={"status": {"$in": ["blocked", "in-progress"]}}, folder="projects/")
filter_notes(where={"okf_type": "Project"}, limit=50)
filter_notes(where={"todos": {"$elemMatch": {"status": "pending"}}}, folder="projects/")
Substrate split: use Markdown for prose, History, session logs, wiki (append_note, headings). Use .yaml / .yml for structure-first atoms (queues, inventories, thin typed records) — whole file is the catalog row; patch with set_field / delete_field (dotted paths, list indices, [id=…] selectors). Machine contracts under system/config/*-contract.schema.yaml stay out of the catalog by default.
No separate issue tracker required for “show me open X in folder Y.” Prefer filter_notes for frontmatter/status sweeps; use search_notes for semantic or keyword recall.
Contracts: Apo is convention-agnostic until the vault encodes a contract it understands. Ship system/contracts/okf-contract.schema.yaml (or set APO_OKF_CONTRACT) for OKF stamp/soft/hard and apo-engine okf validate|fix|export|ingest|linkify|indexes. Legacy system/config/ still resolves. Templates: docs/contracts/. Desk: vault(request={action: "merge"|"project"}) + ~/.apo/desk.yaml (docs/examples/desk.example.yaml).
Multi-vault: set APO_VAULTS_ROOT (parent directory of vaults, autoconfigure) and/or APO_VAULT_PATHS (explicit roots) plus APO_DEFAULT_VAULT. APO_COLLECTION_ROOT remains a deprecated alias for one migration window; matching dual values are accepted and conflicts fail. Tools take vault=; watch runs one thread per vault. Foreign OKF bundles can register as read-only vaults. APO_VAULTS (JSON registry) still loads as a legacy roots-only compat shim. See docs/multi-vault.md.
Git sync
With a git contract and sync.enabled: true, the watcher debounces commit+push after Apo writes and runs an idle git pull --ff-only every pull_interval_seconds. State lives in <vault>/.apo/git-sync-status.json; git_sync action=status reports it.
| State | Cause | What sync does |
|---|---|---|
ok / idle |
Last op succeeded | Normal debounce + idle pull |
offline |
Remote unreachable (DNS, connect refused/timeout, dropped link) | Keeps committing locally. Retries pull then push of the backlog at 60s × 2^n, capped at pull_interval_seconds. Clears itself when the remote answers. No on_block_command. |
blocked |
Conflict, non-fast-forward, auth/permission, unsafe tree | Stops until git_sync action=clear_block (or rebase). Fires on_block_command once. |
A vault blocked by a network error from an older engine self-heals to offline on the next watcher tick. Network ops never prompt (GIT_TERMINAL_PROMPT=0) and abort stalled transfers (http.lowSpeedLimit/lowSpeedTime). Every successful idle pull also pushes any local commits that are ahead of upstream.
OKF conformance
Apo speaks Open Knowledge Format as a first-class vault contract — it is still local markdown memory, not an OKF product.
| State | |
|---|---|
| Produces | Conformant v0.1 bundles. Every stamped concept carries the spec's type alongside Apo's native okf_type; §11 permits both, so no vault migration is needed. |
| Reads | v0.1 and v0.2. Both readers always run, so the §13.1 fallbacks work: generated.at else timestamp, sources else a # Citations body list. Plus §7 actors, verified, status / stale_after, usage_window. |
| Emits from v0.2 | generated: {by, at}, opt-in via generated_policy: forward. The other v0.2 families are read-only. |
| Consumes foreign bundles | okf ingest mounts one as a read-only vault — searchable via vault=, never writable. |
| Not implemented | Attested Computation (runtime / executor / attester); emitting sources / verified. |
Adopt it on any vault:
just okf init --vault-root ~/Notes/Yours # contract + bundle-root index
just okf fix --vault-root ~/Notes/Yours # stamp the gaps
just okf validate --vault-root ~/Notes/Yours --profile okf # SPEC §11 exactly
just okf linkify --vault-root ~/Notes/Yours areas # `## OKF links` with bundle-relative URLs
just okf indexes --vault-root ~/Notes/Yours # regenerate index.md listings
--profile okf checks only what the spec requires and will not fail you for missing description / timestamp; --profile apo (default) is the stricter house style. A vault with no contract reports that rather than claiming to be clean. Field-by-field table and policy knobs: docs/contracts/okf-bundle.md.
Features
| Structured catalogs | filter_notes on any property — Markdown frontmatter, whole-file YAML mappings, or top-level JSON objects |
| Surgical writes | append_note / patch_note with heading / chunk_hash anchors and expected_mtime |
| Vault contracts | Optional OKF / search / git / usage contracts — stamp and validate on write; OKF CLI for lint/export/ingest |
| Hybrid search | BM25 + dense vectors (RRF-style fusion) over chunked Markdown (+ YAML title/description fields) |
| Typed query expansion | Opt-in expand=true — lex/vec/hyde sub-queries RRF-fused with a top-rank bonus and position-aware rerank blend (adapted from tobi/qmd) |
| MCP surface | 12 top-level tools + 7 admin capabilities via apo_admin (plus CLI-shaped aliases, not counted) |
| Index-backed graphs | backlinks + history (mtime browse; file git log when git contract active) hit sqlite / git — not a vault walk |
| Live updates | Optional watcher drains ~/.apo/deferred-*.json after agent writes |
| Measurable quality | Labeled search eval (just search-eval, hit@k / MRR) + optional local cross-encoder reranker |
| Convention-agnostic | Paths + YAML (frontmatter or catalog notes); PARA / wiki / OKF presets are optional |
Architecture
flowchart LR
Agent["Cursor / Claude Code"]
MCP["stdio MCP"]
Queue["Deferred queue"]
Watch["apo-engine watch"]
Index["index.db"]
Vault["Markdown + YAML vault"]
Embed["Ollama bge-m3"]
Agent -->|"search · read · write"| MCP
MCP --> Vault
MCP --> Queue
Queue --> Watch
Watch -->|"chunk · embed"| Embed
Embed --> Index
Watch -->|"sole writer"| Index
MCP -->|"hybrid query"| Index
Embeddings: the default path depends on a local Ollama daemon and the
bge-m3model (just ollama && ollama pull bge-m3). Optional ONNX viafastembedis supported, but Ollama is the desk/share default.
Write path (why the watcher matters):
sequenceDiagram
participant Agent
participant MCP
participant Vault as Markdown files
participant Queue as Deferred queue
participant Watch as apo-engine watch
participant Index as index.db
Agent->>MCP: append_note / patch_note
MCP->>Vault: write bytes
MCP->>Queue: enqueue path
Queue->>Watch: wake
Watch->>Vault: read changed note
Watch->>Index: re-embed chunks
Agent->>MCP: search_notes
MCP->>Index: BM25 + vector
Index-->>Agent: hits with chunk_hash
| Layer | Role |
|---|---|
Engine (engine/) |
Chunk, embed, hybrid search; cache frontmatter + typed links (wiki, markdown, frontmatter — docs/links.md) |
MCP (engine/mcp/) |
Tool schema for hosts; never lets the agent write sqlite directly |
| Watcher | FS events + deferred queue → sole index.db writer |
Quick start
Need: macOS or Linux, Homebrew (or equivalent), Ollama, a folder of .md notes, ~3 GB free while bge-m3 is loaded.
git clone https://github.com/jenorris/apo.git ~/Code/apo # or your preferred path
cd ~/Code/apo
brew install ollama just # Ollama is required for default embeddings; Python 3.11+
cp .env.example .env # set APO_NOTES_ROOT
just setup
just ollama && ollama pull bge-m3 # local embed daemon + model
just index
just search "a phrase you know is in your vault"
Register MCP for Cursor or Claude Code, install the watcher, and verify tool counts in docs/quickstart.md.
Then paste the onboard prompt so agent write habits match your vault — not a canned layout.
CLI entry points
just setup runs uv sync --locked --extra mcp --extra dev --extra otlp,
reinstalls the apo-optima watch-hook
plugin (editable, from APO_OPTIMA_DIR, default ../optima) when that checkout
exists, and links four console scripts from engine/.venv/bin into ~/.local/bin. Ensure~/.local/bin is on PATH. apo is the one to reach for by hand going
forward — it dispatches by leading token, so the other three never need
separate memorizing:
| Command | Routes to | Covers |
|---|---|---|
apo <note-verb> ... |
same backend as apo-local |
read, search, write, append, patch, patch-table, graph-neighbors, filter, backlinks, history — mirrors the MCP note tools |
apo engine <cmd> ... |
same backend as apo-engine |
index, search-eval, stats, watch, desk-project, okf |
apo mcp |
same backend as apo-mcp |
run the MCP server in place (stdio/http) |
apo-engine / apo-local / apo-mcp still work unchanged as their own commands — nothing that depends on those exact names (launchd plists, shell aliases, MCP host config) needs to change. just's own recipes (search/stats/index/mcp/...) still shell out to the original names too, so they keep working whether or not apo has been reinstalled yet.
How agents use it
1. filter_notes {status: open, …} → exact frontmatter catalog (typed / PM)
2. search_notes "quarterly planning" → semantic/keyword hits + chunk_hash
3. append_note / patch_note → edit at heading or chunk_hash
4. watcher re-embeds → next search/filter sees the change
CLI equivalent while you are wiring things up (via just, apo, or directly — apo-local
search / apo-engine stats share the same ops.search/ops.stats backend as the MCP tools
now, so the JSON shape matches):
just search "quarterly planning" # == apo search "quarterly planning" (apo-local backend)
just stats # == apo engine stats
apo search "quarterly planning" # note-verb search — mirrors search_notes, folder=/vaults=/etc.
Prefer append_note / patch_note over full-file write_note for day-to-day edits.
apo-local's exit codes (for scripting): 0 ok, 2 not found, 1 any other error — the JSON payload's error/message fields have the specifics either way.
MCP tools
| Surface | Count | Notes |
|---|---|---|
| Top-level | 12 | Core search/write + vault + apo_admin |
Via apo_admin |
7 | memory_status, index_health, reindex, reload_config, delete_note, git_sync, list_refs |
| Aliases | 6 | CLI-shaped names for the *_note tools; not counted as top-level tools (see below) |
Counts are checked against the live tool registry and admin handlers byscripts/check_public_facts.py — if this table drifts from the code, CI fails.
Aliases. Each *_note tool also answers to its CLI verb, registered on the same function with the same arguments and return shape: read = read_note, search = search_notes, write = write_note, append = append_note, patch = patch_note, filter = filter_notes. The _note names stay canonical. Aliases are callable but hidden from tools/list (no change to existing clients or schema size); set APO_MCP_LIST_ALIASES=1 to list them. graph_neighbors, patch_table, backlinks, history, vault, and apo_admin have no alias.
Habit KPIs (optional): vault(request={action: "stats"}). Operator traces: OTel → Jaeger (Workbench harness/observability/).
Transport
Default is stdio — one subprocess per client (Claude Code, Cursor, each Hermes
gateway), the way mcp_servers.apo config launches apo-mcp today.just mcp-http (or APO_MCP_TRANSPORT=http) runs a shared, long-lived server over
HTTP instead — many clients can point at one warm process (adapted from
tobi/qmd's qmd mcp --http), avoiding N cold-loaded
copies of the same embed model / bindings cache / metrics state. DNS-rebinding
protection is on (host_origin_protection="auto", FastMCP's own guard, off by
default upstream — verify this stays true after any FastMCP upgrade viaengine/tests/test_mcp_http_transport.py); loopback is always trusted,APO_MCP_ALLOWED_HOSTS / APO_MCP_ALLOWED_ORIGINS (comma-separated) only ever add a
non-loopback client on top.
Docker
Dockerfile (repo root) packages the HTTP-transport server — vault data is
bind-mounted, not baked in. docker build -t apo-engine . then see the
Dockerfile's header comment for a full docker run example (vault mount,
persistent ~/.apo state volume, optional APO_MCP_AUTH=google). Pairs withclient/ — a single static Go binary (apo-remote) that talks
to whichever host/port the container publishes, with no local vault access
and none of this repo's Python dependencies.
Configuration
Minimum to boot: set APO_NOTES_ROOT (and usually APO_INDEX) in .env.
| Var | Default | Meaning |
|---|---|---|
APO_NOTES_ROOT |
(required) | Absolute path to the vault root |
APO_INDEX |
engine/index.db |
sqlite-vec database path — recommend ~/.apo/index.db (survives clean checkouts; multi-vault defaults there) |
APO_RUNTIME_COLLECTION |
notes_global |
Deferred-queue / runtime namespace (APO_COLLECTION is deprecated) |
APO_DEFERRED_DIR |
~/.apo |
Runtime dir for queues + tool metrics (tests/sandboxes override) |
APO_TOOL_METRICS |
1 |
Record MCP tool-use events in ~/.apo/metrics.sqlite (SQLite, WAL) (0/false/no/off disables) |
APO_WATCH_EVENTS |
1 |
apo-engine watch uses filesystem events (0/false/no/off falls back to poll-only) |
APO_SEARCH_EXCLUDE |
(empty) | Deprecated desk-wide fallback when a vault has no search-contract; prefer system/contracts/search-contract.schema.yaml |
APO_RERANK |
0 |
Opt-in local cross-encoder reranker (pip install -e '.[rerank]') |
APO_RERANK_MODEL |
Xenova/ms-marco-MiniLM-L-6-v2 |
fastembed cross-encoder id |
APO_RERANK_POOL |
24 |
Fused candidates rescored before the cut to k |
APO_QUERY_EXPAND |
0 |
Opt-in typed lex/vec/hyde query expansion (adds an Ollama call) — search_notes(expand=true). One-time model setup: just setup-query-expand-model (docs/models/qmd-query-expansion.md) |
APO_QUERY_EXPAND_MODEL |
apo-query-expand |
Ollama model for expansion — qmd's own fine-tuned model, see above |
APO_QUERY_EXPAND_TIMEOUT |
20 |
Seconds — covers a cold model load, not just inference |
APO_QUERY_EXPAND_KEEP_ALIVE |
5m |
Per-request Ollama keep_alive for the expansion call only |
APO_MCP_TRANSPORT |
stdio |
http runs a shared server (just mcp-http) instead of one subprocess per client |
APO_MCP_HOST / APO_MCP_PORT |
127.0.0.1 / 8878 |
HTTP transport bind address |
APO_MCP_ALLOWED_HOSTS / APO_MCP_ALLOWED_ORIGINS |
(empty) | Comma-separated additions to the loopback allowlist (HTTP transport) |
APO_INGEST_DIR |
resources/wiki |
Advisory convention for wiki ingest paths |
APO_SEND_ALLOW_ROOTS |
(empty) | Colon-separated host roots place may read. Unset allows no host path. |
APO_SEND_MAX_BYTES |
5242880 |
Max size for host-source .md copies (place op) |
APO_EMBED_BACKEND |
ollama |
ollama or fastembed (ONNX) |
APO_MODEL |
bge-m3 |
Ollama model, or a FastEmbed id when backend is fastembed |
OLLAMA_KEEP_ALIVE |
5m |
Keep embed model warm; 0 = unload when idle |
APO_WATCH_INTERVAL |
30 |
Periodic mtime scan (seconds); deprecated alias: WATCH_INTERVAL |
APO_WATCH_RECONCILE_INTERVAL |
300 |
Full-vault reconcile interval with filesystem events; deprecated alias: WATCH_RECONCILE_INTERVAL |
APO_WATCH_DEBOUNCE |
2 |
Quiet seconds before re-embedding a path |
Optional ONNX: APO_EMBED_BACKEND=fastembed, APO_MODEL=BAAI/bge-large-en-v1.5, then just reindex. Vectors are not interchangeable across models.
Tuning: docs/index-concurrency.md.
Docs
| Doc | For |
|---|---|
| docs/quickstart.md | Install, MCP registration, verify, troubleshoot |
| docs/onboard-prompt.md | Infer vault rules → propose persistent agent instructions |
| docs/agent-throughput.md | Agent habits that make Apo fast (folder=, fields=, anchors, expected_mtime) |
| docs/tables.md | Table row indexing, JSON transit, row-key patch_note ops, column-op gate |
| docs/toc-navigation.md | read_note(mode=toc), sibling hops, hash staleness, pagination |
| docs/patch-note-ops.md | patch_note wire contract (typed ops, aliases, error codes) |
| docs/search-quality.md | Eval harness, measured hit@k / MRR, reranker guidance |
| docs/library-scribe.md | Library scribe: flaws[], trailing-WS auto-fix, vault(request={action: "lint"}) |
| docs/contracts/archival.md | Archival contract (suggest shipped; auto deferred) |
| docs/contracts/ | Contract templates (PARA, llm-wiki, OKF bundle) |
| docs/contracts/okf-bundle.md | OKF conformance table, apo-engine okf CLI, type/provenance policies |
| docs/multi-vault.md | Multi-index vault registry (APO_VAULTS_ROOT / APO_VAULT_PATHS) |
| docs/glossary.md | Canonical vocabulary for vaults, contracts, projections, and catalogs |
| docs/hermes.md | Hermes/Lyra: Mnemosyne + Apo two-tier; desk projection (body + guidance) |
| docs/index-concurrency.md | Indexer / latency internals |
| docs/assets/apo-icon-prompt.md | App mark brief |
| client/README.md | apo-remote — thin Go MCP client for a running (e.g. containerized) engine |
| VERSIONING.md | Semver + jj release cut checklist |
Boundaries
- Scope: one machine, one vault root, local engine — no cloud gateway in this repo.
- Embeddings: default stack needs Ollama +
bge-m3running locally; ONNX is opt-in, not a drop-in without reindex. - Maturity: daily-driver + shareable install path; Hermes projection and usage contracts ship for autonomous hosts.
- Interop: produces conformant OKF v0.1 bundles and reads v0.1 + v0.2; a foreign bundle mounts read-only via
okf ingest. Apo stays local markdown memory — OKF is a contract it honors, not its identity. - Layouts: PARA / OKF / thread workflows are optional vault contracts (or a template), not engine requirements — frontmatter filtering works either way. Apo’s principal capability is the vault data plane; OKF is the flagship contract, not a hard requirement.
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi