# membook - Doramagic AI Context Pack

> 定位：安装前体验与判断资产。它帮助宿主 AI 有一个好的开始，但不代表已经安装、执行或验证目标项目。

## 充分原则

- **充分原则，不是压缩原则**：AI Context Pack 应该充分到让宿主 AI 在开工前理解项目价值、能力边界、使用入口、风险和证据来源；它可以分层组织，但不以最短摘要为目标。
- **压缩策略**：只压缩噪声和重复内容，不压缩会影响判断和开工质量的上下文。

## 给宿主 AI 的使用方式

你正在读取 Doramagic 为 membook 编译的 AI Context Pack。请把它当作开工前上下文：帮助用户理解适合谁、能做什么、如何开始、哪些必须安装后验证、风险在哪里。不要声称你已经安装、运行或执行了目标项目。

## Claim 消费规则

- **事实来源**：Repo Evidence + Claim/Evidence Graph；Human Wiki 只提供显著性、术语和叙事结构。
- **事实最低状态**：`supported`
- `supported`：可以作为项目事实使用，但回答中必须引用 claim_id 和证据路径。
- `weak`：只能作为低置信度线索，必须要求用户继续核实。
- `inferred`：只能用于风险提示或待确认问题，不能包装成项目事实。
- `unverified`：不得作为事实使用，应明确说证据不足。
- `contradicted`：必须展示冲突来源，不得替用户强行选择一个版本。

## 它最适合谁

- **正在使用 Claude/Codex/Cursor/Gemini 等宿主 AI 的开发者**：README 或插件配置提到多个宿主 AI。 证据：`README.md` Claim：`clm_0002` supported 0.86

## 它能做什么

- **命令行启动或安装流程**（需要安装后验证）：项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 证据：`packages/cli/README.md`, `packages/mcp/README.md` Claim：`clm_0001` supported 0.86

## 怎么开始

- `npx membook init` 证据：`packages/cli/README.md` Claim：`clm_0003` supported 0.86
- `claude mcp add membook -- npx -y @membook/mcp` 证据：`packages/mcp/README.md` Claim：`clm_0004` supported 0.86

## 继续前判断卡

- **当前建议**：需要管理员/安全审批
- **为什么**：继续前可能涉及密钥、账号、外部服务或敏感上下文，建议先经过管理员或安全审批。

### 30 秒判断

- **现在怎么做**：需要管理员/安全审批
- **最小安全下一步**：先跑 Prompt Preview；若涉及凭证或企业环境，先审批再试装
- **先别相信**：角色质量和任务匹配不能直接相信。
- **继续会触碰**：角色选择偏差、命令执行、宿主 AI 配置

### 现在可以相信

- **适合人群线索：正在使用 Claude/Codex/Cursor/Gemini 等宿主 AI 的开发者**（supported）：有 supported claim 或项目证据支撑，但仍不等于真实安装效果。 证据：`README.md` Claim：`clm_0002` supported 0.86
- **能力存在：命令行启动或安装流程**（supported）：可以相信项目包含这类能力线索；是否适合你的具体任务仍要试用或安装后验证。 证据：`packages/cli/README.md`, `packages/mcp/README.md` Claim：`clm_0001` supported 0.86
- **存在 Quick Start / 安装命令线索**（supported）：可以相信项目文档出现过启动或安装入口；不要因此直接在主力环境运行。 证据：`packages/cli/README.md` Claim：`clm_0003` supported 0.86

### 现在还不能相信

- **角色质量和任务匹配不能直接相信。**（unverified）：角色库证明有很多角色，不证明每个角色都适合你的具体任务，也不证明角色能产生高质量结果。
- **不能把角色文案当成真实执行能力。**（unverified）：安装前只能判断角色描述和任务画像是否匹配，不能证明它能在宿主 AI 里完成任务。
- **真实输出质量不能在安装前相信。**（unverified）：Prompt Preview 只能展示引导方式，不能证明真实项目中的结果质量。
- **宿主 AI 版本兼容性不能在安装前相信。**（unverified）：Claude、Cursor、Codex、Gemini 等宿主加载规则和版本差异必须在真实环境验证。
- **不会污染现有宿主 AI 行为，不能直接相信。**（inferred）：Skill、plugin、AGENTS/CLAUDE/GEMINI 指令可能改变宿主 AI 的默认行为。 证据：`CLAUDE.md`
- **可安全回滚不能默认相信。**（unverified）：除非项目明确提供卸载和恢复说明，否则必须先在隔离环境验证。
- **真实安装后是否与用户当前宿主 AI 版本兼容？**（unverified）：兼容性只能通过实际宿主环境验证。
- **项目输出质量是否满足用户具体任务？**（unverified）：安装前预览只能展示流程和边界，不能替代真实评测。

### 继续会触碰什么

- **角色选择偏差**：用户对任务应该由哪个专家角色处理的判断。 原因：选错角色会让 AI 从错误专业视角回答，浪费时间或误导决策。
- **命令执行**：包管理器、网络下载、本地插件目录、项目配置或用户主目录。 原因：运行第一条命令就可能产生环境改动；必须先判断是否值得跑。 证据：`packages/cli/README.md`, `packages/mcp/README.md`
- **宿主 AI 配置**：Claude/Codex/Cursor/Gemini/OpenCode 等宿主的 plugin、Skill 或规则加载配置。 原因：宿主配置会改变 AI 后续工作方式，可能和用户已有规则冲突。 证据：`CLAUDE.md`
- **本地环境或项目文件**：安装结果、插件缓存、项目配置或本地依赖目录。 原因：安装前无法证明写入范围和回滚方式，需要隔离验证。 证据：`packages/cli/README.md`, `packages/mcp/README.md`
- **环境变量 / API Key**：项目入口文档明确出现 API key、token、secret 或账号凭证配置。 原因：如果真实安装需要凭证，应先使用测试凭证并经过权限/合规判断。 证据：`README.md`, `packages/cli/README.md`, `packages/core/README.md`
- **宿主 AI 上下文**：AI Context Pack、Prompt Preview、Skill 路由、风险规则和项目事实。 原因：导入上下文会影响宿主 AI 后续判断，必须避免把未验证项包装成事实。

### 最小安全下一步

- **先跑 Prompt Preview**：先用交互式试用验证任务画像和角色匹配，不要先导入整套角色库。（适用：任何项目都适用，尤其是输出质量未知时。）
- **只在隔离目录或测试账号试装**：避免安装命令污染主力宿主 AI、真实项目或用户主目录。（适用：存在命令执行、插件配置或本地写入线索时。）
- **先备份宿主 AI 配置**：Skill、plugin、规则文件可能改变 Claude/Cursor/Codex 的默认行为。（适用：存在插件 manifest、Skill 或宿主规则入口时。）
- **不要使用真实生产凭证**：环境变量/API key 一旦进入宿主或工具链，可能产生账号和合规风险。（适用：出现 API、TOKEN、KEY、SECRET 等环境线索时。）
- **安装后只验证一个最小任务**：先验证加载、兼容、输出质量和回滚，再决定是否深用。（适用：准备从试用进入真实工作流时。）

### 退出方式

- **保留安装前状态**：记录原始宿主配置和项目状态，后续才能判断是否可恢复。
- **准备移除宿主 plugin / Skill / 规则入口**：如果试装后行为异常，可以把宿主 AI 恢复到试装前状态。
- **保留原始角色选择记录**：如果输出偏题，可以回到任务画像阶段重新选择角色，而不是继续沿着错误角色推进。
- **记录安装命令和写入路径**：没有明确卸载说明时，至少要知道哪些目录或配置需要手动清理。
- **准备撤销测试 API key 或 token**：测试凭证泄露或误用时，可以快速止损。
- **如果没有回滚路径，不进入主力环境**：不可回滚是继续前阻断项，不应靠信任或运气继续。

## 哪些只能预览

- 解释项目适合谁和能做什么
- 基于项目文档演示典型对话流程
- 帮助用户判断是否值得安装或继续研究

## 哪些必须安装后验证

- 真实安装 Skill、插件或 CLI
- 执行脚本、修改本地文件或访问外部服务
- 验证真实输出质量、性能和兼容性

## 边界与风险判断卡

- **把安装前预览误认为真实运行**：用户可能高估项目已经完成的配置、权限和兼容性验证。 处理方式：明确区分 prompt_preview_can_do 与 runtime_required。 Claim：`clm_0005` inferred 0.45
- **命令执行会修改本地环境**：安装命令可能写入用户主目录、宿主插件目录或项目配置。 处理方式：先在隔离环境或测试账号中运行。 证据：`packages/cli/README.md`, `packages/mcp/README.md` Claim：`clm_0006` supported 0.86
- **待确认**：真实安装后是否与用户当前宿主 AI 版本兼容？。原因：兼容性只能通过实际宿主环境验证。
- **待确认**：项目输出质量是否满足用户具体任务？。原因：安装前预览只能展示流程和边界，不能替代真实评测。
- **待确认**：安装命令是否需要网络、权限或全局写入？。原因：这影响企业环境和个人环境的安装风险。

## 开工前工作上下文

### 加载顺序

- 先读取 how_to_use.host_ai_instruction，建立安装前判断资产的边界。
- 读取 claim_graph_summary，确认事实来自 Claim/Evidence Graph，而不是 Human Wiki 叙事。
- 再读取 intended_users、capabilities 和 quick_start_candidates，判断用户是否匹配。
- 需要执行具体任务时，优先查 role_skill_index，再查 evidence_index。
- 遇到真实安装、文件修改、网络访问、性能或兼容性问题时，转入 risk_card 和 boundaries.runtime_required。

### 任务路由

- **命令行启动或安装流程**：先说明这是安装后验证能力，再给出安装前检查清单。 边界：必须真实安装或运行后验证。 证据：`packages/cli/README.md`, `packages/mcp/README.md` Claim：`clm_0001` supported 0.86

### 上下文规模

- 文件总数：113
- 重要文件覆盖：40/113
- 证据索引条目：76
- 角色 / Skill 条目：26

### 证据不足时的处理

- **missing_evidence**：说明证据不足，要求用户提供目标文件、README 段落或安装后验证记录；不要补全事实。
- **out_of_scope_request**：说明该任务超出当前 AI Context Pack 证据范围，并建议用户先查看 Human Manual 或真实安装后验证。
- **runtime_request**：给出安装前检查清单和命令来源，但不要替用户执行命令或声称已执行。
- **source_conflict**：同时展示冲突来源，标记为待核实，不要强行选择一个版本。

## Prompt Recipes

### 适配判断

- 目标：判断这个项目是否适合用户当前任务。
- 预期输出：适配结论、关键理由、证据引用、安装前可预览内容、必须安装后验证内容、下一步建议。

```text
请基于 membook 的 AI Context Pack，先问我 3 个必要问题，然后判断它是否适合我的任务。回答必须包含：适合谁、能做什么、不能做什么、是否值得安装、证据来自哪里。所有项目事实必须引用 evidence_refs、source_paths 或 claim_id。
```

### 安装前体验

- 目标：让用户在安装前感受核心工作流，同时避免把预览包装成真实能力或营销承诺。
- 预期输出：一段带边界标签的体验剧本、安装后验证清单和谨慎建议；不含真实运行承诺或强营销表述。

```text
请把 membook 当作安装前体验资产，而不是已安装工具或真实运行环境。

请严格输出四段：
1. 先问我 3 个必要问题。
2. 给出一段“体验剧本”：用 [安装前可预览]、[必须安装后验证]、[证据不足] 三种标签展示它可能如何引导工作流。
3. 给出安装后验证清单：列出哪些能力只有真实安装、真实宿主加载、真实项目运行后才能确认。
4. 给出谨慎建议：只能说“值得继续研究/试装”“先补充信息后再判断”或“不建议继续”，不得替项目背书。

硬性边界：
- 不要声称已经安装、运行、执行测试、修改文件或产生真实结果。
- 不要写“自动适配”“确保通过”“完美适配”“强烈建议安装”等承诺性表达。
- 如果描述安装后的工作方式，必须使用“如果安装成功且宿主正确加载 Skill，它可能会……”这种条件句。
- 体验剧本只能写成“示例台词/假设流程”：使用“可能会询问/可能会建议/可能会展示”，不要写“已写入、已生成、已通过、正在运行、正在生成”。
- Prompt Preview 不负责给安装命令；如用户准备试装，只能提示先阅读 Quick Start 和 Risk Card，并在隔离环境验证。
- 所有项目事实必须来自 supported claim、evidence_refs 或 source_paths；inferred/unverified 只能作风险或待确认项。

```

### 角色 / Skill 选择

- 目标：从项目里的角色或 Skill 中挑选最匹配的资产。
- 预期输出：候选角色或 Skill 列表，每项包含适用场景、证据路径、风险边界和是否需要安装后验证。

```text
请读取 role_skill_index，根据我的目标任务推荐 3-5 个最相关的角色或 Skill。每个推荐都要说明适用场景、可能输出、风险边界和 evidence_refs。
```

### 风险预检

- 目标：安装或引入前识别环境、权限、规则冲突和质量风险。
- 预期输出：环境、权限、依赖、许可、宿主冲突、质量风险和未知项的检查清单。

```text
请基于 risk_card、boundaries 和 quick_start_candidates，给我一份安装前风险预检清单。不要替我执行命令，只说明我应该检查什么、为什么检查、失败会有什么影响。
```

### 宿主 AI 开工指令

- 目标：把项目上下文转成一次对话开始前的宿主 AI 指令。
- 预期输出：一段边界明确、证据引用明确、适合复制给宿主 AI 的开工前指令。

```text
请基于 membook 的 AI Context Pack，生成一段我可以粘贴给宿主 AI 的开工前指令。这段指令必须遵守 not_runtime=true，不能声称项目已经安装、运行或产生真实结果。
```

## 角色 / Skill 索引

- 共索引 26 个角色 / Skill / 项目文档条目。

- **CLAUDE.md — Membook**（project_doc）：This file is the build context for the Membook repository. It is written to be read by coding agents Claude Code, Cursor, Codex and humans alike. Keep it under control: stable decisions live here; session learnings go in .membook/ once the tool can eat its own dog food. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`CLAUDE.md`
- **Membook**（project_doc）：Memory that stays true. A verifiable memory engine for coding agents. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`README.md`
- **membook**（project_doc）：Memory that stays true. The command line for Membook https://github.com/getmembook/membook — durable project knowledge, anchored to code and checked against it. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`packages/cli/README.md`
- **@membook/core**（project_doc）：The Membook engine: store, index, retrieve. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`packages/core/README.md`
- **@membook/mcp**（project_doc）：The Membook MCP server. Serves a repository's memories to any MCP-capable coding agent over stdio. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`packages/mcp/README.md`
- **Contributing to Membook**（project_doc）：Thanks for considering it. This project is MIT and intends to stay that way. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`CONTRIBUTING.md`
- **Membook — Founding Concept Document**（project_doc）：Membook — Founding Concept Document 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/concept.md`
- **Dogfood log**（project_doc）：Two weeks of ordinary work with Membook running on a real repository. Plain entries: what happened, what the tool did, what annoyed you. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/dogfood.md`
- **Releasing**（project_doc）：How Membook gets published, and the things that will bite you if you improvise it. Everything here was learned by doing it wrong first, on 2026-07-24. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/releasing.md`
- **v0.2 — Multi-repo workspaces**（project_doc）：Status: design, ruled. Build after the v0.1 dogfood fortnight, informed by its telemetry. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/design/v0.2-workspaces.md`
- **Project memory**（project_doc）：Durable, project-specific knowledge for anyone — human or agent — working in this repository: decisions and why they were made, traps that are not obvious from the code, and paths already known to be dead ends. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`MEMBOOK.md`
- **Security Policy**（project_doc）：Do not open a public issue for a security report. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`SECURITY.md`
- **Distillation Prompt — v1**（project_doc）：This file is versioned and reviewed like code. Changes here change product behaviour and require the same review rigor as a code change. Used by membook distill to turn notes from a working session into candidate memories. Compare with prompts/seed.md , which distills existing documentation instead. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`prompts/distill.md`
- **Re-check Prompt — v2**（project_doc）：v2 2026-07-24 : a restore must cite evidence, and the citation is checked. The first live re-check returned three restores whose reasons cited a different memory's subject, argued for caution, and were factually wrong. The verdicts matched ground truth only because the memories happened to be true — a model that restores for bad reasons will restore false memories for bad reasons too. Prose alone cannot be trusted,… 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`prompts/recheck.md`
- **Seed Prompt — v1**（project_doc）：This file is versioned and reviewed like code. Changes here change product behaviour and require the same review rigor as a code change. Used by membook seed to distill a repository's existing prose — CLAUDE.md , AGENTS.md , ADRs, design docs, READMEs — into candidate memories. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`prompts/seed.md`
- **M 6F7C.Mem**（project_doc）：npm view 404s for minutes after a first publish while the package exists fine; use npm owner ls to confirm, since it reads a different path. Also --tag alpha does not stop npm setting latest — a package's first publish always takes latest whatever tag you pass. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`.membook/memories/m-6f7c.mem.md`
- **Proud Geese Workspace**（project_doc）：The workspace manifest and resolver — step 1 of the v0.2 multi-repo sequence. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`.changeset/proud-geese-workspace.md`
- **Contributor Covenant Code of Conduct**（project_doc）：Contributor Covenant Code of Conduct 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`CODE_OF_CONDUCT.md`
- **M 0542.Mem**（project_doc）：Never add a gitleaks allowlist or --no-verify for scanner test fixtures; assemble credential-shaped strings at runtime from fragments instead. This repo is upstream of a standard, so every mechanism in its history is a worked example someone copies, and an allowlist entry is a published tutorial in annotating past a scanner. Expect two rounds: leak detection is context-sensitive, so a fragment that matches no rule a… 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`.membook/memories/m-0542.mem.md`
- **M 1389.Mem**（project_doc）：memfile is a z.literal, so bumping the spec version makes OUR OWN reader reject every existing file, not just old readers — every memory in every repo quarantines on upgrade. v0.2 therefore holds explicit versioned schemas with parse dispatching on the field, read tolerance for all versions <= current forever, writes always at current, and no silent upgrade-on-touch: files are committed, so migration must be a revie… 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`.membook/memories/m-1389.mem.md`
- **M 83Be.Mem**（project_doc）：Timestamps serialize double-quoted, in canonical UTC second precision, by explicit serializer rule. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`.membook/memories/m-83be.mem.md`
- **M 88A8.Mem**（project_doc）：The wire schema is the Memfile standard; Date tolerance is a one-directional reader courtesy of this implementation. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`.membook/memories/m-88a8.mem.md`
- **M 9940.Mem**（project_doc）：Every workspace package resolves its siblings to SOURCE, not to built dist: a vitest alias for tests and tsconfig paths for typecheck, with rootDir removed so paths may point outside the package. Without this a fresh clone cannot run pnpm test or pnpm typecheck until something has been built, and CI passes only by the luck of running build first. Package exports still point at dist, because source-pointing exports w… 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`.membook/memories/m-9940.mem.md`
- **M 9C90.Mem**（project_doc）：Do not tune retrieval on BM25 alone: on a small corpus its IDF is degenerate, so a memory matching one rare term of a multi-term query outranks one that actually answers it. Term coverage scales relevance to fix this. The small-corpus regime is the normal case, not an edge case — every repository's book starts tiny, so precision-at-small-N is where this has to work. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`.membook/memories/m-9c90.mem.md`
- **M Be36.Mem**（project_doc）：Anchor kind is always serialized explicitly, and leads every anchor map. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`.membook/memories/m-be36.mem.md`
- **M Bf6B.Mem**（project_doc）：scope becomes a discriminated union in v0.2: user-scope memories forbid anchors entirely, and the verification vocabulary status , verified is absent from their shape rather than perpetually unverified. An anchor is what makes a memory a checkable claim about the world; a user preference is testimony about the human, so verification is a category error against it, not a pending obligation. If you have a file to poin… 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`.membook/memories/m-bf6b.mem.md`

## 证据索引

- 共索引 76 条证据。

- **CLAUDE.md — Membook**（documentation）：This file is the build context for the Membook repository. It is written to be read by coding agents Claude Code, Cursor, Codex and humans alike. Keep it under control: stable decisions live here; session learnings go in .membook/ once the tool can eat its own dog food. 证据：`CLAUDE.md`
- **Membook**（documentation）：Memory that stays true. A verifiable memory engine for coding agents. 证据：`README.md`
- **membook**（documentation）：Memory that stays true. The command line for Membook https://github.com/getmembook/membook — durable project knowledge, anchored to code and checked against it. 证据：`packages/cli/README.md`
- **@membook/core**（documentation）：The Membook engine: store, index, retrieve. 证据：`packages/core/README.md`
- **@membook/mcp**（documentation）：The Membook MCP server. Serves a repository's memories to any MCP-capable coding agent over stdio. 证据：`packages/mcp/README.md`
- **Package**（package_manifest）：{ "name": "membook-monorepo", "private": true, "license": "MIT", "author": "Stag.ai Ltd", "description": "Membook — a verifiable memory engine for coding agents. Memory that stays true.", "homepage": "https://github.com/getmembook/membook", "repository": { "type": "git", "url": "https://github.com/getmembook/membook" }, "bugs": { "url": "https://github.com/getmembook/membook/issues" }, "engines": { "node": " =20" }, "packageManager": "pnpm@9.15.0", "scripts": { "build": "pnpm -r build", "test": "pnpm -r test", "typecheck": "pnpm -r typecheck", "changeset": "changeset", "version-packages": "changeset version", "release": "pnpm build && changeset publish", "version": "changeset version" }, "d… 证据：`package.json`
- **Contributing to Membook**（documentation）：Thanks for considering it. This project is MIT and intends to stay that way. 证据：`CONTRIBUTING.md`
- **Package**（package_manifest）：{ "name": "membook", "version": "0.2.0", "description": "Memory that stays true — a verifiable memory engine for coding agents", "license": "MIT", "author": "Stag.ai Ltd", "repository": { "type": "git", "url": "git+https://github.com/getmembook/membook.git", "directory": "packages/cli" }, "homepage": "https://github.com/getmembook/membook", "bugs": { "url": "https://github.com/getmembook/membook/issues" }, "keywords": "membook", "agent-memory", "ai-memory", "coding-agent", "cli", "verification" , "type": "module", "bin": { "membook": "./dist/cli.js" }, "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } }, "files": "dist", "README.md", "LICENSE" , "publishConfig"… 证据：`packages/cli/package.json`
- **Package**（package_manifest）：{ "name": "@membook/core", "version": "0.2.0", "description": "Membook engine — store, index, retrieve. Files are the truth; the database is a cache.", "license": "MIT", "author": "Stag.ai Ltd", "repository": { "type": "git", "url": "git+https://github.com/getmembook/membook.git", "directory": "packages/core" }, "type": "module", "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } }, "files": "dist", "README.md", "LICENSE" , "scripts": { "build": "tsup src/index.ts --format esm --dts --clean", "test": "vitest run", "typecheck": "tsc --noEmit" }, "engines": { "node": " =20.5.0" }, "dependencies": { "@membook/spec": "workspace: ", "better-sqlite3": "^12.11.1", "exe… 证据：`packages/core/package.json`
- **Package**（package_manifest）：{ "name": "@membook/mcp", "version": "0.1.3", "description": "Membook MCP server — serves verified memories to coding agents over stdio", "license": "MIT", "author": "Stag.ai Ltd", "repository": { "type": "git", "url": "git+https://github.com/getmembook/membook.git", "directory": "packages/mcp" }, "homepage": "https://github.com/getmembook/membook", "bugs": { "url": "https://github.com/getmembook/membook/issues" }, "keywords": "membook", "mcp", "model-context-protocol", "agent-memory", "ai-memory", "coding-agent" , "type": "module", "bin": { "membook-mcp": "./dist/cli.js" }, "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } }, "files": "dist", "README.md", "LIC… 证据：`packages/mcp/package.json`
- **Membook — Founding Concept Document**（documentation）：Membook — Founding Concept Document 证据：`docs/concept.md`
- **Dogfood log**（documentation）：Two weeks of ordinary work with Membook running on a real repository. Plain entries: what happened, what the tool did, what annoyed you. 证据：`docs/dogfood.md`
- **Releasing**（documentation）：How Membook gets published, and the things that will bite you if you improvise it. Everything here was learned by doing it wrong first, on 2026-07-24. 证据：`docs/releasing.md`
- **v0.2 — Multi-repo workspaces**（documentation）：Status: design, ruled. Build after the v0.1 dogfood fortnight, informed by its telemetry. 证据：`docs/design/v0.2-workspaces.md`
- **License**（source_file）：Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files the "Software" , to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 证据：`LICENSE`
- **License**（source_file）：Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files the "Software" , to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 证据：`packages/cli/LICENSE`
- **License**（source_file）：Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files the "Software" , to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 证据：`packages/core/LICENSE`
- **License**（source_file）：Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files the "Software" , to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 证据：`packages/mcp/LICENSE`
- **Project memory**（documentation）：Durable, project-specific knowledge for anyone — human or agent — working in this repository: decisions and why they were made, traps that are not obvious from the code, and paths already known to be dead ends. 证据：`MEMBOOK.md`
- **Security Policy**（documentation）：Do not open a public issue for a security report. 证据：`SECURITY.md`
- **Distillation Prompt — v1**（documentation）：This file is versioned and reviewed like code. Changes here change product behaviour and require the same review rigor as a code change. Used by membook distill to turn notes from a working session into candidate memories. Compare with prompts/seed.md , which distills existing documentation instead. 证据：`prompts/distill.md`
- **Re-check Prompt — v2**（documentation）：v2 2026-07-24 : a restore must cite evidence, and the citation is checked. The first live re-check returned three restores whose reasons cited a different memory's subject, argued for caution, and were factually wrong. The verdicts matched ground truth only because the memories happened to be true — a model that restores for bad reasons will restore false memories for bad reasons too. Prose alone cannot be trusted, so a restore now requires a verbatim evidence quote which is string-matched against the anchored file. Unmatched evidence is a non-answer: the memory stays stale and the verdict is logged reason grounded: false . 证据：`prompts/recheck.md`
- **Seed Prompt — v1**（documentation）：This file is versioned and reviewed like code. Changes here change product behaviour and require the same review rigor as a code change. Used by membook seed to distill a repository's existing prose — CLAUDE.md , AGENTS.md , ADRs, design docs, READMEs — into candidate memories. 证据：`prompts/seed.md`
- **M 6F7C.Mem**（documentation）：npm view 404s for minutes after a first publish while the package exists fine; use npm owner ls to confirm, since it reads a different path. Also --tag alpha does not stop npm setting latest — a package's first publish always takes latest whatever tag you pass. 证据：`.membook/memories/m-6f7c.mem.md`
- **Config**（structured_config）：{ "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", "changelog": "@changesets/changelog-github", { "repo": "getmembook/membook" } , "commit": false, "fixed": , "linked": , "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", "ignore": } 证据：`.changeset/config.json`
- **Tsconfig.Base**（structured_config）：{ "compilerOptions": { "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", "strict": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "forceConsistentCasingInFileNames": true, "skipLibCheck": true, "declaration": true, "sourceMap": true, "isolatedModules": true, "verbatimModuleSyntax": true } } 证据：`tsconfig.base.json`
- **Tsconfig**（structured_config）：{ "extends": "../../tsconfig.base.json", "compilerOptions": { // No rootDir: tsup does the emitting, and rootDir would forbid the // sibling-source paths below. "outDir": "dist", "types": "node" , // Resolve workspace siblings to source, so pnpm typecheck works on a // fresh clone rather than only after a build has produced their .d.ts. "paths": { "@membook/spec": "../spec/src/index.ts" , "@membook/core": "../core/src/index.ts" } }, "include": "src" } 证据：`packages/cli/tsconfig.json`
- **Tsconfig**（structured_config）：{ "extends": "../../tsconfig.base.json", "compilerOptions": { // No rootDir: tsup does the emitting, and rootDir would forbid the // sibling-source paths below. "outDir": "dist", "types": "node" , // Resolve workspace siblings to source, so pnpm typecheck works on a // fresh clone rather than only after a build has produced their .d.ts. "paths": { "@membook/spec": "../spec/src/index.ts" } }, "include": "src" } 证据：`packages/core/tsconfig.json`
- **Tsconfig**（structured_config）：{ "extends": "../../tsconfig.base.json", "compilerOptions": { // No rootDir: tsup does the emitting, and rootDir would forbid the // sibling-source paths below. "outDir": "dist", "types": "node" , // Resolve workspace siblings to source, so pnpm typecheck works on a // fresh clone rather than only after a build has produced their .d.ts. "paths": { "@membook/spec": "../spec/src/index.ts" , "@membook/core": "../core/src/index.ts" } }, "include": "src" } 证据：`packages/mcp/tsconfig.json`
- **.Mise**（source_file）：tools node = "24" 证据：`.mise.toml`
- **.nvmrc**（source_file）：24 证据：`.nvmrc`
- **Pnpm Workspace**（source_file）：packages: - "packages/ " engineStrict: true 证据：`pnpm-workspace.yaml`
- **Backtest**（source_file）：const flag = name, fallback = ⋮---- const git = cwd = a = execa "git", a, ⋮---- const countSource = async sha ⋮---- const touchesOf = path ⋮---- function resolveRenameChain path 证据：`scripts/backtest.mjs`
- **Calibrate**（source_file）：function provider ⋮---- async function build ⋮---- const git = args = execa "git", args, ⋮---- readAnchor: async path = 证据：`scripts/calibrate.mjs`
- **Post Public Setup**（source_file）：set -euo pipefail REPO=getmembook/membook echo "== Branch protection on main" gh api -X PUT "repos/$REPO/branches/main/protection" \ --input - Require signed commits on main" gh api -X POST "repos/$REPO/branches/main/protection/required signatures" /dev/null gh api "repos/$REPO/branches/main/protection/required signatures" \ --jq '" required signatures: \ .enabled "' echo "== Private vulnerability reporting SECURITY.md links to this " gh api -X PUT "repos/$REPO/private-vulnerability-reporting" echo "== Secret scanning and push protection" gh api -X PATCH "repos/$REPO" --input - Verify" gh api "repos/$REPO/branches/main/protection" \ --jq '{force push:.allow force pushes.enabled, deletions:.… 证据：`scripts/post-public-setup.sh`
- **Query Replay**（source_file）：function isRealQuestion text ⋮---- function projectDir repo ⋮---- async function collectPrompts limit, repo ⋮---- // Malformed line: skip it, this is a measurement not a parser. ⋮---- / Short excerpt — enough to judge relevance, not to reproduce. Runs the product's own scanner first. The first run of this harness printed a live npm token to the terminal, because real transcripts contain credentials people pasted while working. recall already redacts queries before they reach the telemetry log; a script that reads the same text owes the same care. / const excerpt = s = ⋮---- / Simulate the HOOK, not bare recall. An earlier run reported "WHat is next" as an injection because it called recall… 证据：`scripts/query-replay.mjs`
- **Cli**（source_file）：import { Command } from "commander"; import { createRequire } from "node:module"; import { MEMORY TYPES, type MemoryType } from "@membook/spec"; import { init } from "./commands/init.js"; import { status } from "./commands/status.js"; import { review } from "./commands/review.js"; import { book, migrate, recall, reindex, remember, verify, } from "./commands/misc.js"; import { seed } from "./commands/seed.js"; import { distill } from "./commands/distill.js"; import { hookPrompt } from "./commands/hook.js"; import { die } from "./output.js"; ⋮---- const root = : string = program.opts< 证据：`packages/cli/src/cli.ts`
- **Distill**（source_file）：import { readFile } from "node:fs/promises"; import { resolve } from "node:path"; import { DISTILL SYSTEM, Membook, SecretScanGuard, distill as runDistill, headSha, isGitRepository, pathExistsAt, seedFrontmatter, type ModelProvider, } from "@membook/core"; import { providerFromEnv } from "./misc.js"; import { bad, dim, die, heading, ok, plural, wrap } from "../output.js"; ⋮---- export interface DistillOptions { root: string; log?: line: string = void; file?: string; dryRun?: boolean; model?: string; provider?: ModelProvider; now?: = Date; readInput?: = Promise ; } ⋮---- async function readStdin : Promise ⋮---- export async function distill options: DistillOptions : Promise ⋮---- function su… 证据：`packages/cli/src/commands/distill.ts`
- **Hook**（source_file）：import { Membook, RANKING, queryTerms, type RecallHit, } from "@membook/core"; ⋮---- export interface HookOptions { root: string; log?: line: string = void; readInput?: = Promise ; } ⋮---- async function readStdin : Promise ⋮---- function renderHit hit: RecallHit : string ⋮---- / Answer a UserPromptSubmit hook. Reads the harness's JSON on stdin, recalls against the user's prompt, and prints anything worth knowing. Silence is the common and correct case: printing something on every prompt would train the reader to skip it, and would spend context on a tool that had nothing to say. / export async function hookPrompt options: HookOptions : Promise ⋮---- // Stale memories are never injected. Un… 证据：`packages/cli/src/commands/hook.ts`
- **Init**（source_file）：import { mkdir, readFile, writeFile } from "node:fs/promises"; import { existsSync } from "node:fs"; import { join } from "node:path"; import { Membook, isGitRepository, repoPaths } from "@membook/core"; import { die, heading, dim, ok, wrap } from "../output.js"; ⋮---- async function ensureGitignore root: string : Promise ⋮---- async function ensureAgentPointer root: string : Promise ; key: string : unknown; } ⋮---- async function ensureHooks root: string : Promise ⋮---- export interface InitOptions { root: string; log?: line: string = void; hooks?: boolean; } ⋮---- export async function init options: InitOptions : Promise 证据：`packages/cli/src/commands/init.ts`
- **Misc**（source_file）：import { readFile } from "node:fs/promises"; import { join } from "node:path"; import { MEMFILE SPEC VERSION, type MemoryInput, type MemoryType, } from "@membook/spec"; import { AnthropicProvider, LlmRechecker, Membook, OpenAiCompatibleProvider, SecretScanGuard, changesSince, headSha, findMissingAnchorPaths, isGitRepository, type AnchorRechecker, type ModelProvider, type Instrumentation, } from "@membook/core"; import { bad, die, dim, heading, ok, plural, statusLabel, warn, wrap, } from "../output.js"; ⋮---- export interface CommonOptions { root: string; log?: line: string = void; } ⋮---- const out = options: CommonOptions ⋮---- export async function reindex options: CommonOptions : Promise… 证据：`packages/cli/src/commands/misc.ts`
- **Review**（source_file）：import { createInterface } from "node:readline/promises"; import { stdin, stdout } from "node:process"; import type { MemoryStatus } from "@membook/spec"; import { Membook, headSha, isGitRepository, type StoredMemory, } from "@membook/core"; import { STATUS MEANING, dim, heading, ok, plural, statusLabel, wrap, } from "../output.js"; ⋮---- export interface ReviewOptions { root: string; list?: boolean; log?: line: string = void; ask?: question: string = Promise ; now?: = Date; } ⋮---- function describe memory: StoredMemory : string ⋮---- export async function review options: ReviewOptions : Promise ⋮---- / The reader is created LAZILY, on the first prompt. Created up front, it starts consumin… 证据：`packages/cli/src/commands/review.ts`
- **Seed**（source_file）：import { Membook, SEED SYSTEM, SecretScanGuard, headSha, isGitRepository, seed as runSeed, seedFrontmatter, type ModelProvider, type SeedCandidate, } from "@membook/core"; import { providerFromEnv } from "./misc.js"; import { bad, dim, die, heading, ok, plural, warn, wrap } from "../output.js"; ⋮---- export interface SeedOptions { root: string; log?: line: string = void; dryRun?: boolean; maxFiles?: number; model?: string; provider?: ModelProvider; now?: = Date; } ⋮---- export async function seed options: SeedOptions : Promise ⋮---- // A guard refusing at the write is not a crash: record it and continue, // or one bad candidate would discard every good one after it. ⋮---- / Report what was… 证据：`packages/cli/src/commands/seed.ts`
- **Status**（source_file）：import type { MemoryStatus } from "@membook/spec"; import { Membook, isGitRepository } from "@membook/core"; import { STATUS MEANING, dim, heading, ok, plural, statusLabel, warn, wrap, } from "../output.js"; ⋮---- export interface StatusOptions { root: string; check?: boolean; log?: line: string = void; } ⋮---- export async function status options: StatusOptions : Promise ⋮---- // Mixed-version stores are legal indefinitely — this is information, not a // health warning. Nothing forces the rewrite; the count just stays visible // until someone chooses to close it. ⋮---- // Each of these is a different call to action, so each gets its own line // rather than being folded into a single "needs… 证据：`packages/cli/src/commands/status.ts`
- **Output**（source_file）：import pc from "picocolors"; import type { MemoryStatus } from "@membook/spec"; ⋮---- export function statusLabel status: MemoryStatus : string ⋮---- export function plural n: number, one: string, many: string : string ⋮---- export function heading text: string : string ⋮---- export function dim text: string : string ⋮---- export function wrap text: string, width = 76, indent = "" : string ⋮---- export function ok text: string : string ⋮---- export function warn text: string : string ⋮---- export function bad text: string : string ⋮---- export function die message: string, hint?: string : never 证据：`packages/cli/src/output.ts`
- **Book**（source_file）：import { writeFile } from "node:fs/promises"; import type { Memory, MemoryStatus, MemoryType } from "@membook/spec"; import type { MemoryStore, StoredMemory } from "./store.js"; import type { RepoPaths } from "./paths.js"; ⋮---- export interface BookEntry { id: string; type: MemoryType; status: MemoryStatus; body: string; anchors: string ; density: number; tokens: number; } ⋮---- export interface BookReport { content: string; entries: BookEntry ; tokens: number; omitted: number; excluded: number; } ⋮---- export function estimateTokens text: string : number ⋮---- function recencyFactor memory: Memory, now: Date : number ⋮---- export function expectedValue memory: Memory, now: Date : number ⋮… 证据：`packages/core/src/book.ts`
- **Distill**（source_file）：import { createHash } from "node:crypto"; import { z } from "zod"; import { MEMORY TYPES, type MemoryType } from "@membook/spec"; import type { ModelProvider } from "./provider.js"; import { ProviderError } from "./provider.js"; import type { Instrumentation } from "./instrumentation.js"; import { NullInstrumentation } from "./instrumentation.js"; import { scanForSecrets } from "./secret-scan.js"; ⋮---- export interface DistillCandidate { statement: string; type: MemoryType; paths: string ; symbol?: string; confidence: number; } ⋮---- export type RejectionReason = "ungrounded-anchor" "secret" "duplicate" "malformed"; ⋮---- export interface DistillRejection { statement: string; reason: Rejec… 证据：`packages/core/src/distill.ts`
- **Git Fixture**（source_file）：import { execa } from "execa"; import { mkdtemp, rm, writeFile, mkdir, unlink } from "node:fs/promises"; import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; ⋮---- export class GitFixture ⋮---- private constructor root: string ⋮---- static async create : Promise ⋮---- async git args: string : Promise ⋮---- async write path: string, content: string : Promise ⋮---- async commit message: string : Promise ⋮---- async commitFile path: string, content: string, message?: string : Promise ⋮---- async edit path: string, content: string : Promise ⋮---- async rename from: string, to: string : Promise ⋮---- async remove path: string : Promise ⋮---- async removeUntracked path: st… 证据：`packages/core/src/git-fixture.ts`
- **Git**（source_file）：import { execa, ExecaError } from "execa"; ⋮---- export class GitError extends Error ⋮---- constructor command: string, cause: ExecaError ⋮---- export class NotAGitRepositoryError extends Error ⋮---- constructor cwd: string ⋮---- async function git cwd: string, args: string : Promise ⋮---- export async function isGitRepository cwd: string : Promise ⋮---- export async function headSha cwd: string : Promise ⋮---- export async function originUrl cwd: string : Promise ⋮---- export async function commitExists cwd: string, sha: string : Promise ⋮---- export type ChangeKind = "modified" "added" "deleted" "renamed"; ⋮---- export interface PathChange { kind: ChangeKind; path: string; renamedTo?: str… 证据：`packages/core/src/git.ts`
- **Guard**（source_file）：import type { Memory } from "@membook/spec"; import type { WriteGuardFinding } from "./errors.js"; ⋮---- export interface WriteCandidate { frontmatter: Memory; body: string; text: string; file: string; } ⋮---- export interface WriteGuard { readonly name: string; inspect candidate: WriteCandidate, : WriteGuardFinding Promise ; } ⋮---- inspect candidate: WriteCandidate, : WriteGuardFinding Promise ; ⋮---- export class NoopWriteGuard implements WriteGuard ⋮---- inspect : WriteGuardFinding ⋮---- export async function runGuards guards: readonly WriteGuard , candidate: WriteCandidate, : Promise< 证据：`packages/core/src/guard.ts`
- **Index Db**（source_file）：import Database from "better-sqlite3"; import { mkdirSync } from "node:fs"; import { dirname } from "node:path"; import { MEMFILE SPEC VERSION } from "@membook/spec"; import { IndexMetadataMismatchError } from "./errors.js"; ⋮---- export type IndexMetadata = typeof INDEX METADATA; ⋮---- function ftsSchema tokenizer: string : string ⋮---- export type IndexDb = Database.Database; ⋮---- export interface OpenIndexOptions { create?: boolean; } ⋮---- export function openIndex file: string, options: OpenIndexOptions = {} : IndexDb ⋮---- export function readMetadata db: IndexDb : Record ⋮---- export function writeMetadata db: IndexDb : void ⋮---- export function assertMetadataMatches stored: Record… 证据：`packages/core/src/index-db.ts`
- **Llm Recheck**（source_file）：import { z } from "zod"; import { formatAnchor } from "@membook/spec"; import type { AnchorRechecker, RecheckRequest, RecheckResult, RecheckVerdict, } from "./recheck.js"; import type { ModelProvider } from "./provider.js"; import type { Instrumentation } from "./instrumentation.js"; import { NullInstrumentation } from "./instrumentation.js"; ⋮---- export function quoteAppearsIn haystack: string, quote: string : boolean ⋮---- const normalise = s: string ⋮---- export interface LlmRecheckerOptions { provider: ModelProvider; instrumentation?: Instrumentation; readAnchor?: path: string = Promise ; readDiff?: path: string, since: string = Promise ; maxContextChars?: number; } ⋮---- function extr… 证据：`packages/core/src/llm-recheck.ts`
- **Membook**（source_file）：import { MEMFILE SPEC VERSION, type MemoryInput } from "@membook/spec"; import { repoPaths, type RepoPaths } from "./paths.js"; import { MemoryStore, type StoredMemory, type MemoryStoreOptions, } from "./store.js"; import { openIndex, type IndexDb } from "./index-db.js"; import { indexMemory, removeFromIndex, reindex, type ReindexResult, } from "./reindex.js"; import { search, type SearchHit, type SearchOptions } from "./search.js"; import { verifyPass, type VerifyOptions, type VerifyReport } from "./verify.js"; import { recall, type RecallOptions, type RecallResult } from "./recall.js"; import { compileBook, writeBook, type BookReport } from "./book.js"; import { migrateStore, type Migrate… 证据：`packages/core/src/membook.ts`
- **Migrate**（source_file）：import { MEMFILE SPEC VERSION, serializeMemfile, type MemoryInput, } from "@membook/spec"; import type { MemoryStore, ReadAllResult } from "./store.js"; import type { QuarantineRecord } from "./errors.js"; ⋮---- export interface MigrateEntry { id: string; file: string; from: number; to: number; reason: "older-version" "non-canonical"; } ⋮---- export interface MigrateReport { examined: number; alreadyCanonical: number; rewritten: MigrateEntry ; quarantined: QuarantineRecord ; needsNewerMembook: ReadAllResult "needsNewerMembook" ; dryRun: boolean; } ⋮---- export interface MigrateOptions { dryRun?: boolean; } ⋮---- export async function migrateStore store: MemoryStore, options: MigrateOptions… 证据：`packages/core/src/migrate.ts`
- **Paths**（source_file）：import { join } from "node:path"; ⋮---- export interface RepoPaths { root: string; membook: string; memories: string; index: string; indexFile: string; quarantine: string; telemetry: string; book: string; } ⋮---- export function repoPaths root: string : RepoPaths 证据：`packages/core/src/paths.ts`
- **Provider**（source_file）：import { z } from "zod"; ⋮---- export interface CompletionRequest { system: string; user: string; maxTokens?: number; } ⋮---- export interface CompletionResult { text: string; inputTokens: number null; outputTokens: number null; } ⋮---- export interface ModelProvider { readonly name: string; readonly model: string; complete request: CompletionRequest : Promise ; } ⋮---- complete request: CompletionRequest : Promise ; ⋮---- export class ProviderError extends Error ⋮---- constructor message: string, status?: number ⋮---- export interface AnthropicOptions { apiKey: string; model?: string; baseUrl?: string; fetchImpl?: typeof fetch; } ⋮---- export class AnthropicProvider implements ModelProvide… 证据：`packages/core/src/provider.ts`
- **Recall**（source_file）：import type { MemoryStatus, MemoryType } from "@membook/spec"; import type { IndexDb } from "./index-db.js"; import { toMatchQuery, type MatchMode } from "./search.js"; ⋮---- export interface RecallAnchor { path: string; symbol?: string; } ⋮---- export function queryTerms query: string : string ⋮---- export function matchedTerms body: string, terms: readonly string : number ⋮---- export function termCoverage body: string, terms: readonly string : number ⋮---- export function evidenceFactor matched: number : number ⋮---- export interface RecallHit { id: string; file: string; type: MemoryType; status: MemoryStatus; confidence: number; body: string; anchors: RecallAnchor ; score: number; signa… 证据：`packages/core/src/recall.ts`
- **Recheck**（source_file）：import type { Anchor, Memory } from "@membook/spec"; import type { PathChange } from "./git.js"; ⋮---- export interface TouchedAnchor { anchor: Anchor; change: PathChange; } ⋮---- export interface RecheckRequest { memory: Memory; body: string; touched: TouchedAnchor ; } ⋮---- export type RecheckVerdict = "verified" "stale" "invalidated"; ⋮---- export interface RecheckResult { verdict: RecheckVerdict; reason: string; } ⋮---- export interface AnchorRechecker { readonly name: string; recheck request: RecheckRequest : RecheckResult Promise ; } ⋮---- recheck request: RecheckRequest : RecheckResult Promise ; ⋮---- export class ConservativeRechecker implements AnchorRechecker ⋮---- recheck request… 证据：`packages/core/src/recheck.ts`
- **Reindex**（source_file）：import { rm } from "node:fs/promises"; import type { Memory } from "@membook/spec"; import type { IndexDb } from "./index-db.js"; import { openIndex } from "./index-db.js"; import type { MemoryStore, StoredMemory } from "./store.js"; import type { QuarantineRecord } from "./errors.js"; import type { RepoPaths } from "./paths.js"; ⋮---- export interface ReindexResult { indexed: number; quarantined: QuarantineRecord ; } ⋮---- export function indexMemory db: IndexDb, memory: StoredMemory, rowid: number : void ⋮---- export function removeFromIndex db: IndexDb, id: string : void ⋮---- export async function reindex paths: RepoPaths, store: MemoryStore, : Promise 证据：`packages/core/src/reindex.ts`
- **Search**（source_file）：import type { MemoryStatus, MemoryType } from "@membook/spec"; import type { IndexDb } from "./index-db.js"; ⋮---- export interface SearchHit { id: string; file: string; type: MemoryType; status: MemoryStatus; score: number; } ⋮---- export type MatchMode = "any" "all"; ⋮---- export interface SearchOptions { limit?: number; mode?: MatchMode; statuses?: readonly MemoryStatus ; } ⋮---- export function toMatchQuery query: string, mode: MatchMode = "any" : string ⋮---- export function search db: IndexDb, query: string, options: SearchOptions = {}, : SearchHit 证据：`packages/core/src/search.ts`
- 其余 16 条证据见 `AI_CONTEXT_PACK.json` 或 `EVIDENCE_INDEX.json`。

## 宿主 AI 必须遵守的规则

- **把本资产当作开工前上下文，而不是运行环境。**：AI Context Pack 只包含证据化项目理解，不包含目标项目的可执行状态。 证据：`CLAUDE.md`, `README.md`, `packages/cli/README.md`
- **回答用户时区分可预览内容与必须安装后才能验证的内容。**：安装前体验的消费者价值来自降低误装和误判，而不是伪装成真实运行。 证据：`CLAUDE.md`, `README.md`, `packages/cli/README.md`

## 用户开工前应该回答的问题

- 你准备在哪个宿主 AI 或本地环境中使用它？
- 你只是想先体验工作流，还是准备真实安装？
- 你最在意的是安装成本、输出质量、还是和现有规则的冲突？

## 验收标准

- 所有能力声明都能回指到 evidence_refs 中的文件路径。
- AI_CONTEXT_PACK.md 没有把预览包装成真实运行。
- 用户能在 3 分钟内看懂适合谁、能做什么、如何开始和风险边界。

---

## Doramagic Context Augmentation

下面内容用于强化 Repomix/AI Context Pack 主体。Human Manual 只提供阅读骨架；踩坑日志会被转成宿主 AI 必须遵守的工作约束。

## Human Manual 骨架

使用规则：这里只是项目阅读路线和显著性信号，不是事实权威。具体事实仍必须回到 repo evidence / Claim Graph。

宿主 AI 硬性规则：
- 不得把页标题、章节顺序、摘要或 importance 当作项目事实证据。
- 解释 Human Manual 骨架时，必须明确说它只是阅读路线/显著性信号。
- 能力、安装、兼容性、运行状态和风险判断必须引用 repo evidence、source path 或 Claim Graph。

- **项目概述：可验证的记忆**：importance `high`
  - source_paths: README.md, MEMBOOK.md, docs/concept.md, CLAUDE.md
- **整体架构与包结构**：importance `high`
  - source_paths: pnpm-workspace.yaml, package.json, tsconfig.base.json, packages/core/src/index.ts, packages/mcp/src/index.ts
- **Memfile 格式规范**：importance `high`
  - source_paths: packages/spec/README.md, packages/core/src/membook.ts, packages/core/src/migrate.ts, .membook/memories/m-6f7c.mem.md
- **验证循环与锚点**：importance `high`
  - source_paths: packages/core/src/verify.ts, packages/core/src/recheck.ts, packages/core/src/llm-recheck.ts, packages/core/src/git.ts, packages/core/src/git-fixture.ts
- **存储与数据模型**：importance `high`
  - source_paths: packages/core/src/store.ts, packages/core/src/index-db.ts, packages/core/src/membook.ts, packages/core/src/guard.ts, packages/core/src/paths.ts
- **召回与搜索**：importance `medium`
  - source_paths: packages/core/src/recall.ts, packages/core/src/search.ts, packages/core/src/book.ts, scripts/query-replay.mjs, scripts/calibrate.mjs
- **MCP 服务器与代理集成**：importance `high`
  - source_paths: packages/mcp/src/server.ts, packages/mcp/src/index.ts, packages/mcp/src/cli.ts, packages/mcp/README.md, packages/cli/src/commands/hook.ts
- **CLI 命令与人类工作流**：importance `high`
  - source_paths: packages/cli/src/cli.ts, packages/cli/src/commands/init.ts, packages/cli/src/commands/status.ts, packages/cli/src/commands/review.ts, packages/cli/src/commands/misc.ts

## Repo Inspection Evidence / 源码检查证据

- repo_clone_verified: true
- repo_inspection_verified: true
- repo_commit: `e5a4ac6a7d8108f5bd2b9e84e57fea010db979c8`
- inspected_files: `README.md`, `package.json`, `pnpm-lock.yaml`, `docs/concept.md`, `docs/design/v0.2-workspaces.md`, `docs/dogfood.md`, `docs/releasing.md`, `packages/cli/CHANGELOG.md`, `packages/cli/README.md`, `packages/cli/package.json`, `packages/cli/src/cli.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/distill.ts`, `packages/cli/src/commands/hook.ts`, `packages/cli/src/commands/init.ts`, `packages/cli/src/commands/misc.ts`, `packages/cli/src/commands/review.ts`, `packages/cli/src/commands/seed.ts`, `packages/cli/src/commands/status.ts`, `packages/cli/src/index.ts`

宿主 AI 硬性规则：
- 没有 repo_clone_verified=true 时，不得声称已经读过源码。
- 没有 repo_inspection_verified=true 时，不得把 README/docs/package 文件判断写成事实。
- 没有 quick_start_verified=true 时，不得声称 Quick Start 已跑通。

## Doramagic Pitfall Constraints / 踩坑约束

这些规则来自 Doramagic 发现、验证或编译过程中的项目专属坑点。宿主 AI 必须把它们当作工作约束，而不是普通说明文字。

### Constraint 1: 可能修改宿主 AI 配置

- Trigger: 项目面向 Claude/Cursor/Codex/Gemini/OpenCode 等宿主，或安装命令涉及用户配置目录。
- Host AI rule: 列出会写入的配置文件、目录和卸载/回滚步骤。
- Why it matters: 安装可能改变本机 AI 工具行为，用户需要知道写入位置和回滚方法。
- Evidence: capability.host_targets | https://github.com/getmembook/membook | host_targets=mcp_host, claude, claude_code
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 2: 失败模式：configuration: membook@0.1.0

- Trigger: Developers should check this configuration risk before relying on the project: membook@0.1.0
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: membook@0.1.0. Context: Source discussion did not expose a precise runtime context.
- Why it matters: Upgrade or migration may change expected behavior: membook@0.1.0
- Evidence: failure_mode_cluster:github_release | https://github.com/getmembook/membook/releases/tag/membook%400.1.0 | membook@0.1.0
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 3: 能力判断依赖假设

- Trigger: README/documentation is current enough for a first validation pass.
- Host AI rule: 将假设转成下游验证清单。
- Why it matters: 假设不成立时，用户拿不到承诺的能力。
- Evidence: capability.assumptions | https://github.com/getmembook/membook | README/documentation is current enough for a first validation pass.
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 4: 失败模式：runtime: @membook/mcp@0.1.2

- Trigger: Developers should check this runtime risk before relying on the project: @membook/mcp@0.1.2
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: @membook/mcp@0.1.2. Context: Source discussion did not expose a precise runtime context.
- Why it matters: Upgrade or migration may change expected behavior: @membook/mcp@0.1.2
- Evidence: failure_mode_cluster:github_release | https://github.com/getmembook/membook/releases/tag/%40membook/mcp%400.1.2 | @membook/mcp@0.1.2
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 5: 失败模式：runtime: membook@0.1.2

- Trigger: Developers should check this runtime risk before relying on the project: membook@0.1.2
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: membook@0.1.2. Context: Source discussion did not expose a precise runtime context.
- Why it matters: Upgrade or migration may change expected behavior: membook@0.1.2
- Evidence: failure_mode_cluster:github_release | https://github.com/getmembook/membook/releases/tag/membook%400.1.2 | membook@0.1.2
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 6: 维护活跃度未知

- Trigger: 未记录 last_activity_observed。
- Host AI rule: 补 GitHub 最近 commit、release、issue/PR 响应信号。
- Why it matters: 新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。
- Evidence: evidence.maintainer_signals | https://github.com/getmembook/membook | last_activity_observed missing
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

- Trigger: no_demo
- Evidence: downstream_validation.risk_items | https://github.com/getmembook/membook | no_demo; severity=medium
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 8: 存在评分风险

- Trigger: no_demo
- Why it matters: 风险会影响是否适合普通用户安装。
- Evidence: risks.scoring_risks | https://github.com/getmembook/membook | no_demo; severity=medium
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 9: 失败模式：performance: @membook/core@0.1.1

- Trigger: Developers should check this performance risk before relying on the project: @membook/core@0.1.1
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: @membook/core@0.1.1. Context: Observed when using windows
- Why it matters: Upgrade or migration may change expected behavior: @membook/core@0.1.1
- Evidence: failure_mode_cluster:github_release | https://github.com/getmembook/membook/releases/tag/%40membook/core%400.1.1 | @membook/core@0.1.1
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 10: 失败模式：performance: @membook/core@0.2.0

- Trigger: Developers should check this performance risk before relying on the project: @membook/core@0.2.0
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: @membook/core@0.2.0. Context: Source discussion did not expose a precise runtime context.
- Why it matters: Upgrade or migration may change expected behavior: @membook/core@0.2.0
- Evidence: failure_mode_cluster:github_release | https://github.com/getmembook/membook/releases/tag/%40membook/core%400.2.0 | @membook/core@0.2.0
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。
