memory-garden GitHub Details, Stars and Alternatives | OpenRepoFinder
Yaoniguan-Money / repository
memory-garden
Local-first memory layer and memory skill for AI agents that mitigates long-context attention dilution with traceable retrieval, policy-aware memory lifecycle, and auditable forget. 面向 AI Agent 的本地优先记忆层与记忆 Skill,在应用层缓解长上下文注意力稀释与上下文遗忘,支持可追溯检索、策略化记忆生命周期与可审计遗忘
A transparent discovery signal based on current public GitHub metadata.
Recent activity35% weight
100
Community adoption25% weight
0
Maintenance state20% weight
100
License clarity10% weight
100
Project information10% weight
75
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
README preview
记忆花园 Memory Garden
记忆花园 Memory Garden is a local-first, auditable memory layer for AI agents, also usable as a memory skill in agent hosts.
It helps agents resist long-context attention dilution and context-window forgetting at the application layer. Instead of stuffing more raw history into the prompt, it retrieves the right local memory before each reply and injects a compact, traceable brief. You can adopt it as a Python package, wire it into an agent runtime, or expose it as a memory skill. The default path is rules-only and makes no network calls. Optional LLM providers are caller-owned and explicit.
Local-first memory layer for AI coding agents. Captures issues, attempts, decisions, and cross-project library gotchas — your AI starts experienced, not amnesiac. Native MCP server verified across Claude Desktop, Cursor, Antigravity, and Codex. 100% local · no cloud · no telemetry · MIT.
An agent can chat with you for 50 turns and still forget that you prefer short Chinese replies with English technical terms. Plain vector recall can retrieve similar text, but it often lacks provenance, deletion proof, and policy boundaries.
Memory Garden does not claim to modify a Transformer's internal attention mechanism. It mitigates the practical symptom of attention drop in long conversations by selecting durable, relevant memory outside the live context window and reintroducing it only when needed. The core is a memory layer; the skill form is one delivery surface for that capability.
Every long-term memory is traceable to source ids. Content that cannot be traced does not enter durable memory.
Quickstart
pip install memory-garden
memory-garden demo
memory-garden health
For optional LLM assistance, prefer environment variables:
export DEEPSEEK_API_KEY="..."
from memory_garden.sdk import MemoryGarden
garden = MemoryGarden.local("./my_garden")
skill = garden.as_skill().with_deepseek()
Claude Code hook usage:
python -m memory_garden.integrations.adapters.claude_code before
python -m memory_garden.integrations.adapters.claude_code after
Adapter CLIs stay rules-only by default. If you explicitly want them to auto-load
provider credentials from environment variables or local provider_config.json,
set MEMORY_GARDEN_ENABLE_PROVIDER_AUTOLOAD=1 for that session.
Install as a Codex Skill
The distributable skill lives in packaging/codex-skills/memory-garden. The
skill does not vendor the Python package, so install memory-garden in the
Python environment used by your agent host first:
pip install memory-garden
For local development from this repository:
python -m pip install -e . --no-deps
Then copy the skill folder into Codex's skill discovery directory.
The skill is explicit by default (allow_implicit_invocation: false). In a new
Codex session, call it directly:
Use $memory-garden to retrieve relevant local memory before answering this task.
Use $memory-garden to propose a memory from this note, but do not approve it yet.
Use $memory-garden to forget memory id <id> and report the proof.
Use From Another Program
Use the Python SDK when your application owns the conversation loop. Choose a
garden home outside the repository and keep it out of Git.
from memory_garden.sdk import MemoryGarden
garden = MemoryGarden.local("./.memory_garden")
skill = garden.as_skill()
try:
skill.open_session()
# Reviewable write: creates proposals only.
proposals = skill.propose_memory("remember: prefer concise release notes")
if proposals:
card = skill.approve_memory_proposal(proposals[0].id)
# Trusted write: use only when your app policy allows auto-approval.
result = skill.remember_memory(
"remember: prefer dark mode dashboards",
mode="trusted",
)
query = "How should I format this release note?"
brief = skill.build_memory_brief(
query,
context={"project_id": "atlas", "task_type": "writing"},
)
messages = [
{"role": "system", "content": brief.use},
{"role": "user", "content": query},
]
assistant_reply = call_your_model(messages)
skill.after(query, assistant_reply)
finally:
garden.close()
For a hook-style integration around each model call:
By default this is local and rules-only: no LLM, embedding, reranker, or network
provider is called. If your application owns external providers, register them
explicitly with ProviderRegistry and an opt-in ProviderPolicy.
Integration
Claude Code:
from memory_garden.sdk import MemoryGarden
from memory_garden.integrations.adapters.claude_code import ClaudeCodeSession
garden = MemoryGarden.local("./my_garden")
session = ClaudeCodeSession(garden=garden)
context = session.before(user_message="How should I reply?")
session.after(assistant_reply="...")
session.close()
Custom agent via skill API:
skill = garden.as_skill()
ctx = skill.before("I prefer short replies.")
reply = call_your_model(ctx.brief_text)
skill.after("I prefer short replies.", reply)
Session commands
花花开 (Hua Hua Kai) opens a garden session and begins harvesting memory.
花花关 (Hua Hua Guan) closes the session and emits structured feedback.
Control commands are never stored as user memory.
Effect
Older rule-only briefs expose source identifiers in the human-facing text:
[use] If relevant, reference memory ids: id1, id2, id3, id4.
With an LLM brief writer configured, the hook injects a natural-language summary while retaining source ids internally:
[use] The user prefers short replies in Chinese, with technical terms kept in English. They mainly use VS Code and Go/Rust for backend work.
Architecture
Core Seed, Court, Growth, Dream, Harvest, Brief
Covenant Policy, trust rules, visibility boundaries
Harvest Local retrieval, ranking, and source-preserving briefs
Cognition Optional LLM enhancement for harvest-time writing and ranking
Product Proposal review, versioning, retrieval, forget proof
Soil Local home, SQLite storage, FTS index, health checks
Adapters Claude Code, Codex, Hermes, OpenAI/Anthropic, LangChain, LangGraph, FastAPI, LlamaIndex
The default rules-only behavior remains stable. LLM output is validated with Pydantic and must carry traceable source_ids, memory_ids, or seed_ids.
Tech Stack
Memory Garden is intentionally small at runtime and explicit at integration boundaries:
Area
Technologies
Language & packaging
Python 3.10+, setuptools, PEP 621 pyproject.toml, optional dependency extras
Data modeling
Pydantic v2 models, typed dataclasses, schema validation for LLM output
Config & policy
PyYAML, local policy files, ProviderPolicy, ProviderRegistry
Persistence
SQLite, JSON payload columns, local garden home layout, manifest files