{"id":47705129,"url":"https://github.com/liliang-cn/cortexdb","last_synced_at":"2026-06-28T04:01:03.358Z","repository":{"id":308653555,"uuid":"1033618518","full_name":"liliang-cn/cortexdb","owner":"liliang-cn","description":"A pure-Go, single-file AI memory and knowledge graph library. ","archived":false,"fork":false,"pushed_at":"2026-06-23T13:12:23.000Z","size":26006,"stargazers_count":40,"open_issues_count":1,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-23T15:08:20.800Z","etag":null,"topics":["embeddings","hindsight","llm","rag","sqlite","vector-database","vector-search"],"latest_commit_sha":null,"homepage":"https://cortex.superleo.app/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liliang-cn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-07T05:15:45.000Z","updated_at":"2026-06-23T13:12:42.000Z","dependencies_parsed_at":"2025-08-28T10:16:26.474Z","dependency_job_id":"2d6e532f-8483-4fd1-9f05-094c43092044","html_url":"https://github.com/liliang-cn/cortexdb","commit_stats":null,"previous_names":["liliang-cn/sqvect"],"tags_count":56,"template":false,"template_full_name":null,"purl":"pkg:github/liliang-cn/cortexdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liliang-cn%2Fcortexdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liliang-cn%2Fcortexdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liliang-cn%2Fcortexdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liliang-cn%2Fcortexdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liliang-cn","download_url":"https://codeload.github.com/liliang-cn/cortexdb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liliang-cn%2Fcortexdb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34876271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embeddings","hindsight","llm","rag","sqlite","vector-database","vector-search"],"created_at":"2026-04-02T17:53:28.702Z","updated_at":"2026-06-28T04:01:03.348Z","avatar_url":"https://github.com/liliang-cn.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CortexDB\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/liliang-cn/cortexdb/v2.svg)](https://pkg.go.dev/github.com/liliang-cn/cortexdb/v2) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nPure-Go, single-file AI memory and knowledge graph library. SQLite is the kernel — one file holds vectors, lexical/RAG search, scoped agent memory, an RDF/SPARQL/RDFS/SHACL knowledge graph, and MCP tools. Built for local-first agents that need durable memory without a separate vector DB, graph DB, or MCP stack. Works with no embedder (lexical mode) or any OpenAI-compatible embeddings endpoint.\n\n## Why CortexDB?\n\nUse CortexDB when you want an agent memory layer that is embedded, inspectable, and graph-aware without standing up more infrastructure.\n\n| If you were considering... | CortexDB gives you... | Trade-off |\n| --- | --- | --- |\n| `chromem-go` or a small embedded vector store | Vectors plus lexical search, durable knowledge, scoped memory, RDF/SPARQL, and MCP tools in one SQLite file | More surface area if all you need is a tiny vector collection |\n| `sqlite-vec` or raw SQLite extensions | A Go facade for RAG, memory, hybrid retrieval, graph facts, and agent tools | Less low-level SQL control than wiring extensions yourself |\n| Chroma, Qdrant, LanceDB, or a hosted vector DB | No service to run, no separate storage plane, and lexical mode with no API key | Not trying to be a distributed vector database |\n| Fuseki, GraphDB, Stardog, or a standalone graph DB | Enough RDF/SPARQL/RDFS/SHACL for local-first agent workflows, next to the text and memory store | Not a full enterprise RDF server |\n| Custom memory tables for Claude Code/Codex | A packaged plugin, MCP server, auto-recall path, and reusable memory/KG tools | Bring your own product-specific memory policy |\n\nPlanning a launch or community post? See [docs/LAUNCH_KIT.md](docs/LAUNCH_KIT.md) for ready-to-edit Show HN, Reddit, and demo scripts.\n\n## Install \u0026 Quick Start\n\n```bash\ngo get github.com/liliang-cn/cortexdb/v2\n```\n\n```go\ndb, _ := cortexdb.Open(cortexdb.DefaultConfig(\"KnowledgeMemory.db\"))\ndefer db.Close()\n\nq := db.Quick()\n_, _ = q.Add(ctx, []float32{0.1, 0.2, 0.9}, \"SQLite is a single-file database.\")\nhits, _ := q.Search(ctx, []float32{0.1, 0.2, 0.8}, 1)\n\n// No-embedder RAG (lexical):\n_, _ = db.SaveKnowledge(ctx, cortexdb.KnowledgeSaveRequest{\n    KnowledgeID: \"apollo\", Content: \"Alice owns Apollo. Apollo ships Friday.\"})\nresp, _ := db.SearchKnowledge(ctx, cortexdb.KnowledgeSearchRequest{\n    Query: \"Who owns Apollo?\", RetrievalMode: cortexdb.RetrievalModeLexical, TopK: 3})\n```\n\n## Layers — pick the right one\n\n```text\npkg/cortexdb   Main facade: vectors, text/RAG search, knowledge, memory, KG, tools, MCP.  ← start here\npkg/memoryflow Agent memory workflow: transcript ingest, recall, wake-up layers, promotion.\npkg/graphflow  Corpus → extract → build → analyze → report → export (HTML).\npkg/importflow Import CSV / SQL dumps / live Postgres-MySQL into RAG + KG (DDL → graph).\npkg/connector  Privacy gate over importflow: PII masking, signed plan, reversible vault, CDC sync.\npkg/graph      Low-level RDF/SPARQL/RDFS/SHACL + property graph.\npkg/core       SQLite storage, embeddings, FTS5, vector indexes (HNSW/IVF/Flat).\n```\n\n## Knowledge Graph\n\nEmbedded RDF on the same file: triples/quads, namespaces, N-Triples/Turtle/TriG I/O, a practical SPARQL subset (SELECT/ASK/CONSTRUCT/DESCRIBE, updates, OPTIONAL/UNION/MINUS/VALUES/BIND/FILTER, aggregates, subqueries, property paths `^p p|q p+ p*`), RDFS-lite materialized inference, and SHACL-lite validation.\n\n```go\ndb.UpsertKnowledgeGraph(ctx, cortexdb.KnowledgeGraphUpsertRequest{Triples: triples})\nres, _ := db.QueryKnowledgeGraph(ctx, cortexdb.KnowledgeGraphQueryRequest{\n    Query: `SELECT ?name WHERE { \u003chttps://example.com/alice\u003e \u003chttps://schema.org/name\u003e ?name }`})\n```\n\n## Tools, MCP \u0026 Plugin\n\n```go\ntools := db.GraphRAGTools()                             // in-process tool calling\nserver := db.NewMCPServer(cortexdb.MCPServerOptions{})  // MCP server\n```\n\nTool groups: GraphRAG (`ingest_document`, `search_text`, `build_context`), knowledge/memory (`knowledge_save`, `memory_search`, …), KG (`knowledge_graph_query`, `_shacl_validate`), KnowledgeMemory (`knowledge_memory_recall`, `_reflect`). `memoryflow`/`graphflow`/`importflow`/`connector` expose their own toolboxes too.\n\n## Claude Code plugin\n\nGive Claude Code (and Codex) durable memory + a knowledge graph as a plugin. It bundles the `cortexdb` skill plus a live MCP server, runs in no-embedder **lexical mode** by default (no API key, no Go toolchain — the server binary is fetched from the matching release), and stores everything in one **global** SQLite file shared by every project.\n\n**Install** — in Claude Code, run each as a slash command:\n\n```text\n/plugin marketplace add liliang-cn/cortexdb\n/plugin install cortexdb@cortexdb\n/reload-plugins\n```\n\nFor Codex: `codex plugin marketplace add liliang-cn/cortexdb \u0026\u0026 codex plugin install cortexdb@cortexdb`.\n\n**Use** — just talk to Claude; it calls the MCP tools for you (\"remember that I prefer …\", \"what do you know about X?\"). Or use the slash commands: `/remember \u003ctext\u003e`, `/recall \u003cquery\u003e`, `/cortexdb-graph` (interactive knowledge-graph view), or `/cortexdb` for the skill. Key tools: `memory_save` / `memory_search`, `knowledge_save` / `knowledge_search`, `knowledge_graph_query`, and the unified `knowledge_memory_recall`. When enabled, a `SessionStart` directive + `UserPromptSubmit` auto-recall hook make Claude recall and save proactively (it asks once, per machine).\n\n**Where data lives** — `~/.cortexdb/cortexdb.db` by default, so memory follows you across projects (multiple sessions share it safely via SQLite WAL). Override per project:\n\n```bash\nexport CORTEXDB_PATH=.cortexdb/cortexdb.db   # inherited by the launched server\n```\n\nTo upgrade: `/plugin update cortexdb` then `/reload-plugins` — the server binary auto-refreshes (version-pinned cache). See `plugins/cortexdb/README.md` for all env vars.\n\n## Other languages (gRPC sidecar)\n\n`cortexdb-grpc` serves the full facade over gRPC, with typed clients for Rust/Python/Node:\n\n```bash\ngo install github.com/liliang-cn/cortexdb/v2/cmd/cortexdb-grpc@latest\nCORTEXDB_PATH=my.db CORTEXDB_GRPC_TOKEN=s3cret cortexdb-grpc   # 127.0.0.1:47821\ncargo add cortexdb-client   # pip install cortexdb-client   # npm install cortexdb-client\n```\n\n## Examples \u0026 Status\n\n`examples/01_core` … `15_cortex_query` are small and architecture-oriented (`go run ./examples/01_core`); 01-07/09/15 run standalone, others need an LLM/embeddings/live DB — see [examples/README.md](examples/README.md).\n\nAn embedded local-first AI memory/KG library — not a drop-in replacement for Fuseki/GraphDB/Stardog. One file, Go APIs, tool/MCP surfaces, and enough RDF/SPARQL/RDFS/SHACL to build real memory workflows.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliliang-cn%2Fcortexdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliliang-cn%2Fcortexdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliliang-cn%2Fcortexdb/lists"}