# SinoMem **Repository Path**: P1M0U/SinoMem ## Basic Information - **Project Name**: SinoMem - **Description**: 中文开箱即用的本地 Agent 记忆系统:零 LLM API key、零分词扩展、无需更换 embedding 模型。SQLite + FTS5 + jieba + 本地向量搜索,零 API 调用。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2026-06-26 - **Last Updated**: 2026-11-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: agent-plugins, Agent-Memory, MCP, sqlite-vec, jieba ## README # SinoMem

SinoMem — local memory for AI agents: 0 API calls, 0 LLM key, 100% local, MCP ready

English | [中文](README.md)

Version Python SQLite jieba ONNX sqlite-vec MCP uv License

> Give your AI Agent a long-term memory that never forgets. > One command to install, one config to connect; zero API cost, 100% local storage. Agent memory that works in Chinese out of the box — three things you do NOT need: no LLM API key, no tokenizer extension to install, no embedding model to swap. SQLite + FTS5 + jieba + local ONNX embeddings, zero API calls, fully offline. Connects to Claude Code, Cursor, Cline, Hermes, and any MCP-compatible Agent. > 🎯 A local long-term memory component built for AI Agents, compatible with the standard MCP protocol. ⭐ If SinoMem helps you, a Star would be greatly appreciated — it helps more developers discover the project! ## 📑 Table of Contents - [Preview](#-preview) - [Quick Start (30 seconds)](#quick-start-30-seconds) - [Who Is This For?](#who-is-this-for) - [Who Is This NOT For?](#who-is-this-not-for) - [Core Features](#core-features) - [Project Structure](#project-structure) - [Installation](#installation) - [Download Embedding Model (Optional, for Semantic Search)](#download-embedding-model-optional-for-semantic-search) - [Manual Hermes MCP Config](#manual-hermes-mcp-config) - [Multi-Agent Auto Memory Sync (Plugin System)](#multi-agent-auto-memory-sync-plugin-system) - [Usage](docs/USAGE_EN.md) - [Search Modes](docs/SEARCH_MODES_EN.md) - [Uninstall](#uninstall) - [FAQ](#faq) - [Roadmap](#roadmap) - [Contributing](#contributing) - [License](#license) - [Contact](#contact) --- ## 🖼 Preview ### System Architecture ![SinoMem System Architecture](assets/sinomem-architecture.webp) ### Demo Video / GIF (Coming Soon) > **📌 Demo GIF path: `assets/demo.gif` (shows store / search operations).** *(Demo assets are on the way — feel free to contribute a demo GIF via PR.)* --- ## Quick Start (30 seconds) ```bash # China / Asia users (Gitee, recommended) curl -fsSL https://gitee.com/P1M0U/SinoMem/raw/main/install.sh | bash # International users (GitHub — temporarily unavailable due to an account issue) curl -fsSL https://github.com/P1M0U/SinoMem/raw/main/install.sh | bash -s -- --mirror github # Open a new terminal, then: sinomem store "User prefers Docker for deployment" -c user_pref sinomem search "Docker" # Output: #1 user_pref score=0.2 # User prefers Docker for deployment ``` > **GitHub entry note**: The GitHub account `P1M0U` is currently hidden from anonymous access (the profile and all public repositories return 404), so the GitHub command above is temporarily unavailable. Please use Gitee for now. The GitHub path will work again once the account is restored; at that point, remove this note and the inline "temporarily unavailable" annotations. > ⚠️ **You must open a new terminal window** (or run `source ~/.bashrc`) after install — otherwise the `sinomem` command won't be recognized. > > 💾 The default memory database lives at `~/.sinomem/memory.db`. To back it up, run `sinomem export -o backup.db --format db` — copying a live `.db` by hand drops committed transactions still sitting in `-wal`. --- ## Who Is This For? - 🤖 Developers using AI coding assistants like Claude Code, Cursor, Cline, or Hermes - 🇨🇳 Applications that need Chinese to work out of the box (jieba built in — no tokenizer extension to install, no model to swap) - 🔒 Individuals with data compliance requirements (100% local SQLite storage) - 💰 Individual developers who don't want to pay per-token embedding API costs (local ONNX inference) - 🔗 Sharing the same long-term memory across multiple AI tools --- ## Who Is This NOT For? - Team collaboration / multi-tenant: the store is a single SQLite file with no accounts, permissions, or per-user isolation - Cloud multi-device sync: data stays 100% on this machine; export a snapshot with `sinomem export -o backup.db --format db` and copy that (copying a live `.db` drops writes not yet checkpointed) - Enterprise compliance auditing: no audit log and no compliance report — keeping data local is not the same as being auditable - End-to-end task-level memory, graph relations, or semantic evolution: SinoMem only stores and retrieves memories, it does no inference or relation modeling, so use a purpose-built system for that If your need is any of the above, SinoMem is not the right fit — and this is not a gap that configuration can close. --- ## Core Features - **Chinese FTS5 Search** — jieba tokenization + SQLite FTS5, same tokenizer for write and query, token-aligned - **Semantic Search** — Local ONNX embedding model (~24MB min), optional install, defaults to bge-small-zh-v1.5 (Chinese-tuned) - **Hybrid Search** — RRF (Reciprocal Rank Fusion), auto-balancing keyword and semantic results without manual weighting - **MCP Server** — Standard protocol, 17 tools, works with any MCP-compatible Agent - **Multi-Agent Auto-Sync Plugins** — Claude Code / LangChain / CrewAI / AutoGen / Hermes, all supported - **Zero Service Dependencies** — a single SQLite file, no database server or container; one `.db` can be shared across multiple agents - **Backup & Migration** — `export` / `restore` support JSONL and `.db` snapshots (the latter includes FTS5 indexes and vectors) - **Visual Panel** — `export --format html` writes a single self-contained page with Chart.js 4.5.1 (MIT), four charts synced with filters, fully offline - **CLI Tool** — 20 subcommands (store / search / get / update / delete / list / stats / vacuum / fsck / clean / reindex / cleanup / consolidate / migrate / import / export / restore / models / store-batch / search-batch) - **Data Migration** — Import from holographic memory, generate embeddings for existing memories - **Auto Deduplication** — Skips duplicate content by default - **Database Maintenance** — VACUUM, reindex, batch delete by category - **Content Validation** — Auto-truncation of overly long content (8000 chars) - **Concurrency-safe** — WAL journal mode + a 5-second busy timeout + exponential-backoff retry on write locks; multiple agents on the same machine can read and write the same store --- ## Project Structure ```text sinomem/ # Core memory engine ├── core/ # Storage, search, tokenization, embeddings ├── dicts/ # Custom jieba dictionaries ├── entrypoints/ # CLI and MCP Server ├── plugins/ # Multi-agent auto-sync plugins │ ├── base.py # Plugin base class │ ├── claude_code/ # Claude Code hook plugin │ ├── langchain/ # LangChain BaseMemory component │ ├── crewai/ # CrewAI Memory component (WIP) │ ├── autogen/ # AutoGen memory_provider (WIP) │ └── hermes/ # Hermes MemoryProvider core │ └── provider.py # on_memory_write auto-sync └── tools/ # Data migration & maintenance tools hermes_plugin/ # Hermes plugin entry (plugin.yaml + re-export) installers/ # Claude Code installer script tests/ # Tests docs/ # Documentation (usage / search modes / agent install / Hermes adapter / dev notes) assets/ # Architecture diagram and demo media models/embedding/ # ONNX embedding model (auto-download) install.sh # One-liner install script ``` --- ## Installation > **💡 This section is the one-liner install for human readers.** If you want to hand the install instructions to an AI Agent, use the dedicated step-by-step guide in [AGENT_INSTALL.md](docs/AGENT_INSTALL.md) (instructions for AI Agents, language-agnostic). ### Option 1: uv install (Recommended) ```bash # China / Asia users (Gitee source, faster) uv tool install "sinomem[embedding] @ git+https://gitee.com/P1M0U/SinoMem.git" # International users (temporarily unavailable due to an account issue) uv tool install "sinomem[embedding] @ git+https://github.com/P1M0U/SinoMem.git" # Download the embedding model (~24MB, needed for semantic search; # skip it and semantic search degrades to keyword search) sinomem models download ``` After install, `sinomem` / `sino` / `sinomem-mcp` and the Claude Code hook commands are all on PATH — **independent of where the repo lives**. No clone, no symlink. Drop `[embedding]` if you don't need semantic search. > **If you get `sinomem: command not found`**: `~/.local/bin` isn't on your current shell's PATH yet — run `source ~/.bashrc` as uv suggests (or open a new terminal). > > Not yet published to PyPI, hence the `git+https://` form; once published, `uv tool install sinomem` will work directly. ### Option 2: One-Liner Script ```bash # China / Asia users — Gitee + Tsinghua mirror (recommended) curl -fsSL https://gitee.com/P1M0U/SinoMem/raw/main/install.sh | bash # International users — GitHub + PyPI (temporarily unavailable due to an account issue) curl -fsSL https://github.com/P1M0U/SinoMem/raw/main/install.sh | bash -s -- --mirror github # Full install with semantic search curl -fsSL https://gitee.com/P1M0U/SinoMem/raw/main/install.sh | bash -s -- --with-embedding ``` > The script clones the repo to `~/.local/share/sinomem/` and creates a venv — best for users who want the source tree (or repo-local models). > **💡 If you're using Hermes Agent**, we recommend installing via the **Memory Provider plugin** for a better integration experience (auto sync, in-process calls, tool deduplication). See [Hermes Memory Provider Adapter Guide](docs/HERMES_ADAPTER.md). Note that a `hermes update` which changes the dependency set switches Hermes to a new runtime environment and the plugin must be reinstalled — see the troubleshooting section there. > **🤖 For the full step-by-step install guide for AI Agents**, see [AGENT_INSTALL.md](docs/AGENT_INSTALL.md). --- ## Download Embedding Model (Optional, for Semantic Search) This project uses **bge-small-zh-v1.5** (a lightweight Chinese-optimized model): | Model | Size | Dim | Language | Best For | |-------|------|-----|----------|----------| | **bge-small-zh-v1.5** | ~24MB | 512 | Chinese-optimized | Primarily Chinese, smaller size, better Chinese accuracy | ```bash # One command (probes reachable mirrors automatically) sinomem models download ``` The model goes to `~/.sinomem/models/embedding` by default (override with `SINOMEM_MODEL_DIR`). In China, `hf-mirror.com` is tried first, falling back to the official source.
Manual download (without the CLI) ```bash # China users: set HuggingFace mirror (hf-mirror.com is stable and reliable) export HF_ENDPOINT="https://hf-mirror.com" # Install download tool (China users: use Tsinghua pip mirror) pip install -i https://pypi.tuna.tsinghua.edu.cn/simple huggingface-hub # Download into models/embedding (source-install layout) python -c " from huggingface_hub import hf_hub_download hf_hub_download('Xenova/bge-small-zh-v1.5', 'onnx/model_quantized.onnx', local_dir='models/embedding') hf_hub_download('Xenova/bge-small-zh-v1.5', 'tokenizer.json', local_dir='models/embedding') " ```
Without the model, semantic search degrades gracefully to keyword search. --- ## Manual Hermes MCP Config Add to `~/.hermes/config.yaml` under `mcp_servers:`: > **📌 Tip**: paste the config below as a **child** of `mcp_servers:` — keep the YAML indentation as shown. ```yaml sinomem: args: [] command: sinomem-mcp ``` Restart Hermes to activate. --- ## Multi-Agent Auto Memory Sync (Plugin System) Beyond MCP's active-call mode, SinoMem provides **auto-sync plugins** — the Agent automatically manages long-term memory without explicitly calling memory tools. ### Claude Code (one-click install) ```bash bash installers/install_claude_code.sh ``` Installs 3 hooks: inject memory context before prompts, capture writes, and persist at session end. ### LangChain (one-line import) ```python from sinomem.plugins.langchain import SinoMemory agent = create_react_agent(llm, tools, memory=SinoMemory()) ``` ### CrewAI (one-line import) ```python from sinomem.plugins.crewai import SinoCrewMemory crew = Crew(agents=[...], tasks=[...], memory=SinoCrewMemory()) ``` ### AutoGen (one-line import) ```python from sinomem.plugins.autogen import SinoAutoGenMemory assistant = AssistantAgent(name="agent", memory_provider=SinoAutoGenMemory()) ``` ### Generic Python API ```python from sinomem.plugins import create_plugin plugin = create_plugin() plugin.auto_store("User prefers Docker") results = plugin.auto_search("deployment tools") ``` --- ## Usage Common commands at a glance: ```bash # Store and search sinomem store "User prefers Docker for deployment" -c user_pref sinomem search "Docker" sinomem search "how to send files to user" -m hybrid # Backup and restore sinomem export -o backup.db --format db sinomem restore -i backup.db --format db --force # Migration and maintenance sinomem import sinomem migrate sinomem fsck sinomem consolidate ``` See the [Usage Guide](docs/USAGE_EN.md) for the full CLI reference, 17 MCP tools, data migration, backup/restore and database maintenance. --- ## Search Modes Search supports `keyword`, `semantic` and `hybrid`. See [Search Modes](docs/SEARCH_MODES_EN.md) for use cases, the `score` / `retrieval` contract, degradation detection, access counters and consolidation-based retirement. --- ## Uninstall A one-liner uninstall script is provided to cleanly remove SinoMem and all related configurations: ```bash # GitHub (temporarily unavailable due to an account issue) curl -fsSL https://github.com/P1M0U/SinoMem/raw/main/uninstall.sh | bash # Gitee (faster in China) curl -fsSL https://gitee.com/P1M0U/SinoMem/raw/main/uninstall.sh | bash # Or run locally (after cloning the repo) bash uninstall.sh ``` **What gets cleaned up:** | Step | Item | Details | |------|------|---------| | pip package | sinomem | Uninstalls from both
system pip and Hermes venv | | Install directory | `~/.local/share/sinomem/` | Removes all project files | | Environment variables | SINOMEM_HOME /
PATH / HF_ENDPOINT | Removes from `.bashrc` /
`.zshrc` / `.profile` | | Hermes plugin | `~/.hermes/plugins/sinomem` | Removes symlink | | Memory database | `~/.sinomem/memory.db` | **Interactive prompt** —
keep or delete | | Hermes deps | jieba / tokenizers | Uninstalls from Hermes venv
(installed by install.sh) | | Claude Code hooks | `settings.local.json` | Detects and prompts for cleanup
(stale hooks cause errors) | | jieba cache | `~/.cache/jieba` | Asks before cleaning | > 💡 Before deleting the database, the script shows memory count and file size, and requires a second confirmation. You can keep the database and reuse it after reinstalling. --- ## FAQ ### Q1: Can I still use semantic search without downloading an embedding model? Yes. Without the model, semantic search degrades gracefully to keyword search. Download a model (~24MB min) whenever you need semantic search. ### Q2: How do I use SinoMem as Hermes' Memory Provider? The **Hermes Memory Provider plugin** is the recommended way — see the [Hermes Memory Provider Adapter Guide](docs/HERMES_ADAPTER.md). You can also configure SinoMem as an MCP Server (see [Manual Hermes MCP Config](#manual-hermes-mcp-config)). ### Q3: Can multiple agents share the same memory? Yes — but **on the same machine only**. SinoMem stores data in a single SQLite file (WAL journal mode, a 5-second busy timeout, and exponential-backoff retry on write locks) and supports concurrent access from multiple agents on that machine. One `.db` file can be shared across Claude Code, Cursor, Cline, and Hermes. Do **not** put the `.db` on a network share for multiple machines to connect to directly: WAL relies on shared memory between processes, and SQLite's documentation states plainly that "All processes using a database must be on the same host computer; WAL does not work over a network filesystem" — forcing it can corrupt the database. To move data across devices, run `sinomem export -o backup.db --format db` and copy that snapshot — it uses SQLite's online backup API, which folds any not-yet-checkpointed `-wal` content into the file. **Do not copy the `.db` by hand**: that silently drops committed transactions still sitting in `-wal`, leaving you an incomplete copy that looks fine. ### Q4: How do I migrate from other memory systems? Use `sinomem import` to import from holographic memory, and `sinomem migrate` to generate embeddings for existing memories. See [Data Migration](docs/USAGE_EN.md#data-migration). ### Q5: Does SinoMem call any cloud APIs? No. All data is stored 100% locally, and embeddings are computed with a local ONNX model — zero API calls, zero cost. ### Q6: I get "sinomem: command not found" after install The installer modifies the `PATH` environment variable — **open a new terminal window** (or run `source ~/.bashrc`) for it to take effect. You can also invoke it via the full path: ```bash ~/.local/share/sinomem/.venv/bin/sinomem ``` ### Q7: MCP Server fails to start — virtual environment not found? Make sure the one-liner install script finished completely; **do not move or rename** the `~/.local/share/sinomem` directory, otherwise the absolute paths in the MCP Server config will break. If you already moved it, re-run the install script to repair. --- ## Roadmap - [x] SQLite + FTS5 Chinese full-text search (jieba tokenization) - [x] Local ONNX semantic search (optional install, bge Chinese lightweight model) - [x] Hybrid search (RRF — Reciprocal Rank Fusion) - [x] MCP Server (17 tools) - [x] Multi-agent auto-sync plugins (Claude Code / LangChain / Hermes) - [x] One-liner install & uninstall scripts - [x] Memory backup / restore (JSONL text + SQLite snapshot, merge-dedup or exact restore) - [ ] CrewAI / AutoGen plugin polish (currently WIP) - [ ] Record a CLI demo GIF (stored at `assets/demo.gif`) - [ ] More embedding model support - [x] Memory visualization panel --- ## Contributing Contributions are welcome! Whether it's reporting a bug, improving docs, or adding a feature, your participation is appreciated. - 🐛 Found a bug → open an [Issue](https://gitee.com/P1M0U/SinoMem/issues) - ✨ New feature / improvement → open a [PR](https://gitee.com/P1M0U/SinoMem/pulls) - 📝 Docs or demo assets → submit a PR directly (place GIFs and other media under `assets/`) Beginner-friendly tasks are labeled with **good first issue** — new contributors are welcome! **Development conventions**: keep the design modular with high cohesion and low coupling; run `ruff check` and `ruff format` on every `.py` file before committing; follow the Conventional Commits spec. Please read [CONTRIBUTING.md](CONTRIBUTING.md) before submitting a contribution. It documents the contribution license terms (inbound = outbound, i.e. contributions are licensed under Apache-2.0). --- ## License [Apache 2.0](LICENSE) Copyright © 2026 [P1M0U](https://github.com/P1M0U) (GitHub profile temporarily unavailable) · [Gitee](https://gitee.com/P1M0U) --- ## Contact - Email: [p1m0u@foxmail.com](mailto:p1m0u@foxmail.com) - GitHub: [https://github.com/P1M0U/SinoMem](https://github.com/P1M0U/SinoMem) (temporarily unavailable due to an account issue) - Gitee: [https://gitee.com/P1M0U/SinoMem](https://gitee.com/P1M0U/SinoMem)