* Add server beta runtime foundation * Address server beta review findings * Resolve server beta review comments * Tighten server beta review follow-ups * Harden server beta auth and search * Avoid unnecessary FTS rebuilds * Block scoped keys from creating projects * Release BullMQ claims best effort on close * Address server beta review blockers * Reset BullMQ claims best effort * Add Postgres observation storage foundation * feat(server-beta): add independent runtime service Introduce src/server/runtime/ as a self-contained server-beta runtime that owns its lifecycle, Postgres bootstrap, and HTTP boundary without depending on WorkerService. ServerBetaService wraps the existing Server class, exposes /healthz and /v1/info with runtime="server-beta", and persists state to dedicated paths (.server-beta.pid|.port|.runtime.json). The four boundary managers (queue, generation worker, provider registry, event broadcaster) are intentionally disabled in this phase and report their status through /v1/info; later phases activate them. Adds plans/2026-05-07-finish-bullmq-branch-ship-plan.md to track the remaining work for this branch. Phase 2 of plans/2026-05-07-server-beta-independent-bullmq-observation-runtime.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(server-beta): route CLI lifecycle and bundle separate runtime scripts/build-hooks.js now produces plugin/scripts/server-beta-service.cjs as a separate Node CJS bundle, alongside the existing worker-service bundle. The server-beta runtime is now installable independently. src/npx-cli/commands/server.ts routes start|stop|restart|status to the server-beta lifecycle instead of the legacy worker. The worker keeps its own start|stop|restart|status under the worker namespace; the two runtimes can be operated independently. src/services/worker-service.ts adds a server-* command parser branch that delegates to the sibling server-beta-service.cjs bundle so direct worker-service invocations still route to the right runtime. tests/npx-cli-server-namespace.test.ts updated to expect server-beta lifecycle routing. Includes rebuilt plugin/scripts/*.cjs bundles produced by build-and-sync. Phase 2 of plans/2026-05-07-server-beta-independent-bullmq-observation-runtime.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(server-beta): add BullMQ job queue primitives Introduce src/server/jobs/ as the queue-side primitives that Phase 3 of the server-beta runtime needs to operate. types.ts defines a discriminated union over the four job kinds (event, event-batch, summary, reindex) and maps each to a per-kind BullMQ queue name and deterministic-ID prefix. job-id.ts builds deterministic, colon-free BullMQ jobIds from (kind, team, project, source). The colon ban exists because BullMQ uses ':' as a Redis key separator internally; embedding ':' in jobIds breaks scan and state lookups. ServerJobQueue.ts is a thin wrapper over BullMQ Queue + Worker that enforces autorun:false, default concurrency 1, and an attached error listener — all per BullMQ docs requirements. Test seams accept queue and worker factories so unit tests do not need Redis. outbox.ts publishes through the Postgres ObservationGenerationJob repository as canonical history. enqueueOutbox writes the row first, then publishes to BullMQ; if BullMQ throws, the row is transitioned to failed and a failed event is appended. reconcileOnStartup re-enqueues queued + processing rows after a restart, replacing terminal BullMQ jobs that may still be holding the deterministic ID slot. markCompleted and markFailed wrap transitionStatus and append the matching event row. Includes 20 unit tests covering deterministic ID stability, colon-free output, queue lifecycle, error-listener attachment, double-start refusal, idempotent enqueue, BullMQ failure rollback, startup reconciliation, max-attempts skipping, and completion / failure / retry transitions. Phase 3 commit 1 of plans/2026-05-07-server-beta-independent-bullmq-observation-runtime.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(server-beta): activate queue boundary in runtime service Wire ActiveServerBetaQueueManager into the server-beta runtime graph. The active manager owns one ServerJobQueue per generation kind (event, event-batch, summary, reindex) and surfaces lane metadata through boundary health. Selection is opt-in and fail-fast: if CLAUDE_MEM_QUEUE_ENGINE is set to bullmq the active manager is constructed (and any Redis/config error throws — no silent fallback to SQLite, per Phase 3 anti-pattern guard). For any other engine the disabled boundary remains so worker-era and test setups stay compatible. Widens ServerBetaBoundaryHealth.status to a discriminated union ('disabled' | 'active' | 'errored') with optional details. The disabled adapter still emits status='disabled', which keeps the existing server-beta-service test green. ServerBetaService receives the manager through a new optional queueManager field on CreateServerBetaServiceOptions so test graphs and Phase 4 wiring can inject custom managers. Adds tests/server/runtime/active-queue-manager.test.ts covering bullmq guard, active health shape, per-kind queue access, close behavior, and post-close errored health. Phase 3 commit 2 of plans/2026-05-07-server-beta-independent-bullmq-observation-runtime.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(server-beta): cap /v1/events/batch at 500 events Prevents unbounded array DoS surface flagged in PR review. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
12 KiB
🌐 这是自动翻译。欢迎社区修正!
🇨🇳 中文 • 🇹🇼 繁體中文 • 🇯🇵 日本語 • 🇧🇷 Português • 🇰🇷 한국어 • 🇪🇸 Español • 🇩🇪 Deutsch • 🇫🇷 Français 🇮🇱 עברית • 🇸🇦 العربية • 🇷🇺 Русский • 🇵🇱 Polski • 🇨🇿 Čeština • 🇳🇱 Nederlands • 🇹🇷 Türkçe • 🇺🇦 Українська • 🇻🇳 Tiếng Việt • 🇮🇩 Indonesia • 🇹🇭 ไทย • 🇮🇳 हिन्दी • 🇧🇩 বাংলা • 🇵🇰 اردو • 🇷🇴 Română • 🇸🇪 Svenska • 🇮🇹 Italiano • 🇬🇷 Ελληνικά • 🇭🇺 Magyar • 🇫🇮 Suomi • 🇩🇰 Dansk • 🇳🇴 Norsk
为 Claude Code 构建的持久化内存压缩系统。
快速开始 • 工作原理 • 搜索工具 • 文档 • 配置 • 故障排除 • 许可证
Claude-Mem 通过自动捕获工具使用观察、生成语义摘要并使其可用于未来会话,无缝保留跨会话的上下文。这使 Claude 能够在会话结束或重新连接后仍保持对项目的知识连续性。
快速开始
在终端中启动新的 Claude Code 会话并输入以下命令:
> /plugin marketplace add thedotmack/claude-mem
> /plugin install claude-mem
重启 Claude Code。来自先前会话的上下文将自动出现在新会话中。
核心特性:
- 🧠 持久化内存 - 上下文跨会话保留
- 📊 渐进式披露 - 分层内存检索,具有令牌成本可见性
- 🔍 基于技能的搜索 - 使用 mem-search 技能查询项目历史
- 🖥️ Web 查看器界面 - 在 http://localhost:37777 实时查看内存流
- 💻 Claude Desktop 技能 - 从 Claude Desktop 对话中搜索内存
- 🔒 隐私控制 - 使用
<private>标签排除敏感内容的存储 - ⚙️ 上下文配置 - 精细控制注入的上下文内容
- 🤖 自动操作 - 无需手动干预
- 🔗 引用 - 使用 ID 引用过去的观察(通过 http://localhost:37777/api/observation/{id} 访问,或在 http://localhost:37777 的 Web 查看器中查看全部)
- 🧪 测试版渠道 - 通过版本切换尝试实验性功能,如无尽模式
文档
📚 查看完整文档 - 在官方网站浏览
入门指南
最佳实践
架构
- 概述 - 系统组件与数据流
- 架构演进 - 从 v3 到 v5 的旅程
- 钩子架构 - Claude-Mem 如何使用生命周期钩子
- 钩子参考 - 7 个钩子脚本详解
- Worker 服务 - HTTP API 与 Bun 管理
- 数据库 - SQLite 模式与 FTS5 搜索
- 搜索架构 - 使用 Chroma 向量数据库的混合搜索
配置与开发
工作原理
核心组件:
- 5 个生命周期钩子 - SessionStart、UserPromptSubmit、PostToolUse、Stop、SessionEnd(6 个钩子脚本)
- 智能安装 - 缓存依赖检查器(预钩子脚本,不是生命周期钩子)
- Worker 服务 - 在端口 37777 上的 HTTP API,带有 Web 查看器界面和 10 个搜索端点,由 Bun 管理
- SQLite 数据库 - 存储会话、观察、摘要
- mem-search 技能 - 具有渐进式披露的自然语言查询
- Chroma 向量数据库 - 混合语义 + 关键词搜索,实现智能上下文检索
详见架构概述。
mem-search 技能
Claude-Mem 通过 mem-search 技能提供智能搜索,当您询问过去的工作时会自动调用:
工作方式:
- 只需自然提问:"上次会话我们做了什么?" 或 "我们之前修复过这个 bug 吗?"
- Claude 自动调用 mem-search 技能查找相关上下文
可用搜索操作:
- 搜索观察 - 跨观察的全文搜索
- 搜索会话 - 跨会话摘要的全文搜索
- 搜索提示 - 搜索原始用户请求
- 按概念搜索 - 按概念标签查找(发现、问题-解决方案、模式等)
- 按文件搜索 - 查找引用特定文件的观察
- 按类型搜索 - 按类型查找(决策、bug修复、功能、重构、发现、更改)
- 最近上下文 - 获取项目的最近会话上下文
- 时间线 - 获取特定时间点周围的统一上下文时间线
- 按查询的时间线 - 搜索观察并获取最佳匹配周围的时间线上下文
- API 帮助 - 获取搜索 API 文档
自然语言查询示例:
"What bugs did we fix last session?"
"How did we implement authentication?"
"What changes were made to worker-service.ts?"
"Show me recent work on this project"
"What was happening when we added the viewer UI?"
详见搜索工具指南的详细示例。
测试版功能
Claude-Mem 提供测试版渠道,包含实验性功能,如无尽模式(用于扩展会话的仿生记忆架构)。从 Web 查看器界面 http://localhost:37777 → 设置 切换稳定版和测试版。
详见 测试版功能文档 了解无尽模式的详细信息和试用方法。
系统要求
- Node.js: 18.0.0 或更高版本
- Claude Code: 支持插件的最新版本
- Bun: JavaScript 运行时和进程管理器(如缺失会自动安装)
- uv: 用于向量搜索的 Python 包管理器(如缺失会自动安装)
- SQLite 3: 用于持久化存储(已内置)
配置
设置在 ~/.claude-mem/settings.json 中管理(首次运行时自动创建默认设置)。可配置 AI 模型、worker 端口、数据目录、日志级别和上下文注入设置。
详见 配置指南 了解所有可用设置和示例。
开发
详见 开发指南 了解构建说明、测试和贡献工作流程。
故障排除
如果遇到问题,向 Claude 描述问题,troubleshoot 技能将自动诊断并提供修复方案。
详见 故障排除指南 了解常见问题和解决方案。
Bug 报告
使用自动生成器创建全面的 bug 报告:
cd ~/.claude/plugins/marketplaces/thedotmack
npm run bug-report
贡献
欢迎贡献!请:
- Fork 仓库
- 创建功能分支
- 进行更改并添加测试
- 更新文档
- 提交 Pull Request
详见开发指南了解贡献工作流程。
License
This project is licensed under the Apache License 2.0 (Apache-2.0).
Copyright (C) 2025 Alex Newman (@thedotmack). All rights reserved.
See the LICENSE file for full details.
Apache-2.0 allows broad use, modification, distribution, and commercial use, subject to its terms.
Ragtime note: The ragtime/ directory is licensed under the Apache License 2.0. See ragtime/LICENSE for details.
支持
- 文档: docs/
- 问题反馈: GitHub Issues
- 仓库: github.com/thedotmack/claude-mem
- 作者: Alex Newman (@thedotmack)
使用 Claude Agent SDK 构建 | 由 Claude Code 驱动 | 使用 TypeScript 制作