[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-93267":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":13,"stars30d":13,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":19,"hasPages":17,"topics":20,"createdAt":9,"pushedAt":9,"updatedAt":21,"readmeContent":22,"aiSummary":23,"trendingCount":15,"starSnapshotCount":15,"syncStatus":14,"lastSyncTime":24,"discoverSource":25},93267,"understory","thecodacus\u002Funderstory","thecodacus","understory — memory that grows. Self-wiring, plain-markdown memory for AI agents (MCP + local models + a living graph).",null,"TypeScript",127,20,6,2,0,44.57,false,"main",true,[],"2026-07-22 04:02:08","# understory 🌱\n\n**Memory that grows.**\n\nThe layer beneath your agents: a self-wiring, plain-markdown memory. Every fact your agents learn is filed as a markdown concept, cross-linked into a living knowledge graph, and kept healthy by the agent itself — searchable, diffable, and entirely yours. Runs great on local models.\n\nBundles follow the [Open Knowledge Format (OKF) v0.1 spec](https:\u002F\u002Fgithub.com\u002FGoogleCloudPlatform\u002Fknowledge-catalog\u002Fblob\u002Fmain\u002Fokf\u002FSPEC.md) — plain markdown files with YAML frontmatter, readable by humans, diffable in git, portable across tools.\n\n**Three ways in, one agent:**\n\n- **MCP server** — `memory_query` \u002F `memory_add` \u002F `memory_update` \u002F `memory_status` \u002F `memory_maintain` tools over stdio or streamable HTTP. Each call drives an internal LLM agent with the OKF spec in its system prompt.\n- **Web UI** — browse the bundle (tree, concept viewer, update log, conformance badge), see the memory as an Obsidian-style **force-directed graph** (drag\u002Fpan\u002Fzoom, colored by type, sized by connections, orphans ringed red, click to open), and chat with the same agent to test it. Tool calls render inline so you can watch it work.\n- **Query-path replay** — every agent run (query\u002Fmutation\u002Fchat) records its traversal (searches → reads → writes) as a compact notation, persisted under `\u003Cbundle>\u002F.traces\u002F`. The graph view lists recent runs; selecting one replays the path as numbered directed hops over the graph — visited concepts ringed, search hits dotted, everything else faded.\n- **CLI** — `pnpm agent:query \"...\"` \u002F `pnpm agent:mutate \"...\"` smoke entries.\n\n**Design rule: conformance is enforced in code, not prompts.** The deterministic bundle layer validates frontmatter (`type` required), regenerates `index.md` files, appends `log.md` entries (newest-first, spec §7), and sandboxes all paths to the bundle root. The LLM decides *what* to change; the code guarantees the result is a conformant bundle.\n\n## Quick start (Docker)\n\nNo clone needed — the image is public. Save this as `docker-compose.yml`:\n\n```yaml\nservices:\n  understory:\n    image: ghcr.io\u002Fthecodacus\u002Funderstory:latest\n    ports:\n      - \"3800:3800\"\n    volumes:\n      # Your memory lives here as plain markdown — a named volume, or point\n      # a bind mount (e.g. .\u002Fmy-memory:\u002Fbundle) at any OKF bundle.\n      - understory-memory:\u002Fbundle\n    environment:\n      BUNDLE_ROOT: \u002Fbundle\n      # Pick ONE provider:\n      # 1) Local llama.cpp \u002F llama-swap (model auto-discovered; start llama-server with --jinja)\n      LLM_PROVIDER: llamacpp\n      LLAMACPP_BASE_URL: http:\u002F\u002Fyour-inference-box:8080\n      # 2) Anthropic\n      #LLM_PROVIDER: anthropic\n      #ANTHROPIC_API_KEY: sk-ant-...\n      # 3) OpenRouter\n      #LLM_PROVIDER: openrouter\n      #OPENROUTER_API_KEY: sk-or-...\n    restart: unless-stopped\n\nvolumes:\n  understory-memory:\n```\n\n```bash\ndocker compose up -d\n```\n\nThen:\n\n- **Web UI** → http:\u002F\u002Flocalhost:3800 — browse the memory, watch the graph, chat with the agent\n- **MCP endpoint** → `http:\u002F\u002Flocalhost:3800\u002Fmcp` (streamable HTTP) — register it in any MCP client:\n  ```bash\n  claude mcp add --transport http ustory http:\u002F\u002Flocalhost:3800\u002Fmcp\n  ```\n- Your agent now has `memory_query` \u002F `memory_add` \u002F `memory_update` \u002F `memory_status` \u002F `memory_maintain`, and gets a seed overview of the memory at every session start.\n\nTeach it something (`memory_add`: \"We deploy on Fridays, never Mondays\"), then open the graph and watch the concept wire itself in. Deploying with Portainer? Use [docker-compose.portainer.yml](docker-compose.portainer.yml) as a repository stack.\n\n## Stack\n\npnpm monorepo:\n\n| Package | What |\n|---|---|\n| `packages\u002Fcore` | OKF bundle layer (zero LLM) + agent (Vercel AI SDK tool loop: search\u002Fread\u002Flist\u002Fwrite\u002Fpatch\u002Fdelete) + provider registry |\n| `packages\u002Fserver` | Express: MCP streamable-HTTP at `\u002Fmcp`, stdio bin, REST browse API at `\u002Fapi\u002F*`, streaming chat at `\u002Fapi\u002Fchat`, serves the web build |\n| `packages\u002Fweb` | Vite + React + TS + Tailwind: bundle browser + agent chat (`useChat`) |\n\nProviders (env-selected, swappable per chat): **Anthropic** (default), **OpenRouter**, **llamacpp** (llama.cpp `llama-server` \u002F llama-swap — model auto-discovered from `\u002Fv1\u002Fmodels`, loaded model preferred), **local** (any other OpenAI-compatible endpoint).\n\n### llama.cpp\n\n```bash\n# on the inference box — --jinja enables OpenAI-style tool calling\nllama-server -m model.gguf --jinja --host 0.0.0.0 --port 8080\n\n# here — no model id needed, it's discovered\nLLM_PROVIDER=llamacpp LLAMACPP_BASE_URL=http:\u002F\u002Finference-box:8080 \\\nBUNDLE_ROOT=.\u002Fsample-bundle node packages\u002Fserver\u002Fdist\u002Findex.js\n```\n\nWorks behind llama-swap too: discovery prefers the currently **loaded** model so a query doesn't trigger a multi-minute model swap. Pin a specific model with `LLM_MODEL=`.\n\n## From source\n\n```bash\npnpm install\npnpm build\ncp .env.example .env   # add your API key\n\nBUNDLE_ROOT=.\u002Fsample-bundle ANTHROPIC_API_KEY=sk-... node packages\u002Fserver\u002Fdist\u002Findex.js\n# → http:\u002F\u002Flocalhost:3800  (web UI + \u002Fapi + \u002Fmcp)\n```\n\nOr build the container yourself: `docker compose up --build` (the repo's [docker-compose.yml](docker-compose.yml) builds from source and mounts `.\u002Fsample-bundle`).\n\nDev mode (server on :3800, Vite HMR on :5180 with proxy):\n\n```bash\nBUNDLE_ROOT=.\u002Fsample-bundle pnpm --filter @understory\u002Fserver dev\npnpm --filter @understory\u002Fweb dev\n```\n\n## MCP registration (Claude Code \u002F Desktop)\n\n```bash\nclaude mcp add ustory \\\n  -e BUNDLE_ROOT=\u002Fpath\u002Fto\u002Fyour\u002Fbundle \\\n  -e ANTHROPIC_API_KEY=sk-... \\\n  -- node \u002Fpath\u002Fto\u002Funderstory\u002Fpackages\u002Fserver\u002Fdist\u002Fmcp\u002Fstdio.js\n```\n\nOr point an HTTP MCP client at `http:\u002F\u002Fhost:3800\u002Fmcp`.\n\n### Seed memory\n\nA client LLM that only sees four bare tool names never gets the instinct to check memory. So at **session start** the server injects a compact overview of what the knowledge base contains (directories, concepts with types + descriptions, recent activity) through both channels that reach the model:\n\n1. the MCP initialize **`instructions`** field (clients like Claude put it in the system prompt), and\n2. the **`memory_query` tool description** — the universal fallback every tool-calling client loads.\n\nThe seed regenerates fresh for every new session. After `memory_add` \u002F `memory_update` in a long-lived (stdio) session, the tool description refreshes via `tools\u002Flist_changed`, so the session sees its own writes. Out-of-band edits (hand edits, other clients) are picked up on the next session.\n\n### Graph health & maintenance\n\nMemory is a graph, not a pile of notes, and graphs rot: concepts go **orphaned** (nothing links to them) and links go **broken**. Two mechanisms keep it healthy:\n\n- **Write-time linking** — new knowledge either enriches the concept it belongs to (an attribute of an existing entity is patched in, not filed separately) or, when it's a distinct entity, is created *and* back-linked from related concepts. Contradictions are superseded in place, never left standing alongside the old value.\n- **`memory_maintain`** — a deterministic lint (orphans + broken links, surfaced in `memory_status` under `graph`) drives an internal agent to wire orphans into related concepts and fix dangling links. Run it periodically to counter drift; it's a no-op when the graph is already healthy.\n\nThis design mirrors the pattern in Karpathy's [LLM Wiki](https:\u002F\u002Fgist.github.com\u002Fkarpathy\u002F442a6bf555914893e9891c11519de94f) (index.md + log.md, create-vs-enrich, lint for orphans). Deferred from that pattern until scale warrants: an explicit page-type schema, and hybrid FTS5+embedding search (the naive scan in `search.ts` is fine into the low thousands of concepts).\n\n## Tests\n\n```bash\npnpm test                                  # core: 18 tests (spec §5\u002F§6\u002F§7\u002F§9, sandbox, search, concurrency)\npnpm --filter @understory\u002Fserver exec tsx scripts\u002Fmcp-smoke.mts   # MCP stdio round-trip (needs SMOKE_BUNDLE + an API key)\n```\n\n## Environment\n\nSee [.env.example](.env.example). `BUNDLE_ROOT` is required; `GIT_AUTOCOMMIT=true` commits every mutation.\n","understory 是一个面向 AI 代理的本地化、可演化的知识记忆系统，以纯 Markdown 文件（遵循 Open Knowledge Format 规范）构建自维护的知识图谱。核心功能包括：基于 MCP 协议的内存操作接口（query\u002Fadd\u002Fupdate）、可视化力导向图谱浏览、查询路径回放追踪、以及由代码强制保障的 OKF 合规性校验（如 frontmatter 类型检查、index\u002Flog 自动生成）。它不依赖中心化服务，支持本地 LLM（如 llama.cpp）或云 API，强调人类可读、Git 可 diff、跨工具可移植。适用于需要长期积累、可审计、可协作演化的 AI 代理记忆场景，如个人知识管理增强、多代理协同记忆、离线研究辅助等。","2026-07-15 02:30:03","CREATED_QUERY"]