
Tempera
io.github.anvanster由 GitHub 账号 anvanster 发布v0.4.29更新于 Oct 24, 2026
Persistent episodic memory for AI coding: capture, retrieve, brief, dream cycle, cross-project.
概览
为 Claude Code 提供持久的情节记忆,记录编码会话、检索相似的过往片段,并按学习到的有用程度排序。
- 可以做什么
- Tempera 把编码会话保存为情节(episode),为其建立语义搜索索引,并在遇到相似任务时呈现相关的过往解决方案。工具覆盖会话预热(tempera_session_start、tempera_brief、tempera_retrieve、tempera_template)、记录纠正与遗漏提问、捕获会话并提交有用性反馈,以及状态、统计、传播和整理等诊断与维护操作。每晚在预算内运行的 dream cycle 会执行反思、模式检测、矛盾探查和模板提取,声明还可设定作用域,使可迁移知识跨项目出现。
- 适用场景
- 适合长期使用 Claude Code 处理重复性任务的开发者,希望每次会话都能召回过去的修复、纠正和推理步骤,而不是重新解决。最适合多会话或多项目、且累积的、按反馈排序的记忆值得投入配置的场景。
- 运行要求
- 作为本地 stdio MCP 服务器运行,通过 npm 包 @astudioplus/tempera-mcp 安装(README 也记录了 Rust 构建和 cargo install)。需要本地运行时和 ~/.tempera/ 下的磁盘空间;BGE-Small 嵌入模型(约 128MB)首次使用时从 HuggingFace 下载,因此需要一次联网。ANTHROPIC_API_KEY 用于基于 LLM 的意图提取,dream cycle 会产生付费模型调用。
安装
在 SourceWeft 中
- 打开 控制台中的 Tempera,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Tempera - Persistent Memory for Claude Code
Tempera gives Claude Code a persistent memory that learns from experience. Instead of starting fresh each session, Claude can recall past solutions, learn what works, and get smarter over time.
Why Tempera?
The Problem: Claude Code forgets everything between sessions. You solve the same problems repeatedly, and Claude can't learn from past successes or failures.
The Solution: Tempera captures coding sessions as "episodes", indexes them for semantic search, and uses reinforcement learning to surface the most valuable memories when relevant.
How It Works
The Learning Loop
What Makes It "Learn"
Over time, frequently helpful knowledge rises to the top, while stale or unhelpful memories fade away — and the system itself accumulates a per-project picture of where it tends to be wrong.
The bigger surfaces (v0.6 onward)
Beyond the basic capture/retrieve loop, Tempera ships several higher-order surfaces. Each is opt-in but all flow through the same MCP tools — Claude can use them without any custom client code.
- Grounded capture (v0.6): Every captured claim carries a
falsifiabilityscore, acategory, and aValidityScope(Forever / Language / Crate / Domain / Workaround / Project). Decay rates are per-scope — universal truths never expire, project-specific conventions fade in months, workarounds expire when the underlying issue closes. - Dream cycle (v0.7): A budgeted nightly pipeline that runs
verify_advance → decay → reflect → patterns → contradict → templates. Reflections turn high-signal days into prose; patterns surface themes that keep recurring; contradict probes pairs of frequently-retrieved episodes for factual disagreements; templates extract reusable step sequences from successful task clusters. - Self-improvement (v0.8): Calibration tracks the ratio of declared vs. verified successes per (task, project). Mistakes log records corrections the agent made. Should-have-asked log records questions it realized it should have asked first. Ask-backs are clarifying questions the system itself drafts via Haiku when a capture ends in failure with vague intent — queued for the next session in that project.
- Brief surface (v0.9): One MCP call joins all of the above against the file set the agent is about to touch.
tempera_brief(files, task_type?, domain?)returns pending ask-backs, the matching reasoning template, top correction categories for those files, should-have-asked triggers, and a calibration warning if the agent's track record on this kind of task is shaky. - Cross-project learning (v0.10):
tempera_retrieveandtempera_briefboth acceptcross_project=true. Transferable claims (anything not project-scoped) surface across projects; Project-scoped knowledge stays bound to its codebase. Legacy captures default to non-transferable until reclassified.
Installation
Build from Source
Install from crates.io
First Run - Model Download
On first use, Tempera downloads the BGE-Small embedding model (~128MB) for semantic search. This happens automatically and only once:
The model is cached globally at ~/.tempera/models/ and shared across all projects.
Setup with Claude Code
1. Add the MCP Server
The --scope user flag makes it available across all your projects.
2. Restart Claude Code
Exit and restart Claude Code to load the new MCP server.
3. Verify
Run /mcp in Claude Code. You should see tempera with 12 tools.
MCP Tools
Once connected, Claude has access to these 12 tools, grouped by purpose:
Session warmup (call at task start)
During task
End of task
Diagnostics + maintenance
Standard warmup pattern
Key Lifecycle Behaviors
Start of session: Call tempera_session_start first to consume any pending ask-back, then tempera_brief once the file set is known.
End of task: Capture successful sessions with tempera_capture — don't wait to be asked. Capture also drafts an ask-back via Haiku if the outcome was Failure/Partial with vague intent, so the next session in this project sees the gap.
Session chaining: Episodes captured within 2 hours of each other in the same project are automatically linked. Multi-step tasks share utility and context.
Cross-project routing: New captures get a ValidityScope suggestion from the intent-extraction LLM (v0.10.3). Project-scoped claims stay bound to one codebase; Language / Crate / Domain / Workaround / Forever claims surface across projects when retrieval opts in.
tempera_retrieve Modes
Example Conversation
CLI Commands
The CLI mirrors the MCP tool surface so you can drive everything Claude does from a shell.
Basics
The brief surface (v0.9)
Session warmup (v0.8.5)
Self-improvement surfaces (v0.8)
Reasoning templates (v0.8.3)
Calibration (v0.8.1)
Dream cycle (v0.7)
Verification (v0.6.1)
Maintenance + analytics
Data Storage
Tempera stores everything locally in ~/.tempera/ (shared across all projects). One memory pool serves every project; the project filter is applied at query time.
SQLite tables (in jobs.sqlite)
Everything that needs SQL lives here. Each store opens the DB on first use and runs its migration; migrations are in migrations/ and run in order.
All projects share the same pool. Cross-project routing is controlled by each episode's ValidityScope (see below) — not by separate storage.
Configuration
All knobs live in ~/.tempera/config.toml. The defaults are tuned to be useful out of the box; you only need to touch this if you want to change retrieval ranking, dream-cycle behavior, or per-phase budgets.
Retrieval + ranking
Capture + verification
Dream cycle (v0.7)
Storage + maintenance
Decay rates are scope-aware (per the ValidityScope on each episode's claim):
Under the Hood
Multi-hop Bellman Propagation
Value from helpful episodes spreads through the similarity graph in multiple hops:
Session Chaining
Episodes captured within 2 hours of each other in the same project are automatically linked:
The Dream Cycle (v0.7)
A budgeted background pipeline that runs nightly (or on demand). Each phase shares a CostBudget; free phases ignore it, paid phases check try_spend() before each LLM call.
- verify_advance: bumps episodes from
MergedtoStableNoRevertafterstable_threshold_days. - decay: scope-aware utility decay (see table above).
- reflect: Haiku triage gates Sonnet authorship; high-signal days get a reflection page.
- patterns: agglomerative clustering on reflection embeddings → cross-day themes.
- contradict: pairs frequently-retrieved BKM episodes and asks Haiku whether they disagree on a factual claim; surfaces a Wilson 95% CI on the contradiction rate.
- templates: groups successful verified episodes by
(task_type, domain), extracts reusable step sequences via Sonnet.
Worst case per full cycle: roughly $0.50 with default settings.
Scoring Formula
Retrieval ranking combines three signals with normalized weights:
Default in hybrid mode: 85% similarity (RRF-normalized over vector + BM25), 15% utility, 0% recency. The VerificationState of each episode multiplies into salience — well-verified successes weigh more.
Cross-project routing (v0.10)
Every claim carries a ValidityScope that determines:
- Decay rate (table above).
- Transferability:
is_transferable()returns true for everything exceptProject { name }. The retrieve and brief surfaces use this to decide what surfaces when the agent opts intocross_project=true.
Legacy episodes captured before v0.6.4 don't have a scope set, so they stay project-bound by default. New captures (v0.10.3+) get a scope suggested automatically by the intent-extraction LLM call — using a colon-encoded format like language:rust, crate:[email protected], domain:async-rust, workaround:repo#123, or project. The default when in doubt is project, keeping the system conservative.
Maintenance
Run periodically to keep memory healthy:
The dream cycle is the load-bearing piece for long-running memory hygiene. It uses Haiku for cheap gating and Sonnet for authorship — the default $0.50 cap is the worst case across every phase.
Environment Variables
Troubleshooting
MCP server not loading
- Check path:
ls /path/to/tempera-mcp - Check config:
cat ~/.claude.json - Restart Claude Code completely
- Run
/mcpto verify
Embeddings slow on first run
The BGE-Small model (~128MB) downloads on first use from HuggingFace. This requires internet access. After download, the model is cached at ~/.tempera/models/ and works offline.
Vector search not finding anything
Run tempera index to create/update the vector database.
Model download fails
If behind a firewall or proxy, ensure access to huggingface.co. The model files are downloaded via HTTPS.
tempera_brief returns "nothing to surface"
This is normal early on — the brief joins against signal data (mistakes, asks, templates, calibration) that accrues over time. Specifically:
- The mistakes / should-have-asked sections only fire when the files you pass overlap with previously-logged rows.
- The template section only fires when at least 3 successful verified episodes share the
(task_type, domain)pair (templates accrue during the dream cycle). - The calibration warning needs ≥5 declared-success captures in the bucket before it surfaces.
Fall back to tempera_retrieve for episode-level recall.
tempera retrieve --cross-project finds nothing
Episodes captured before v0.6.4 don't have a ValidityScope set, and v0.10's cross-project filter treats unscoped claims as project-bound (conservative default). Either (a) capture new episodes with v0.10.3+, which auto-suggests a scope, or (b) manually classify legacy episodes via the MCP validity_scope parameter on capture.
License
Apache 2.0
Contributing
Contributions welcome! Please open an issue or PR.
来源:README.md,提交 3e6f0e5
工具
0版本历史
1- v0.4.29最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分