# witness - Doramagic AI Context Pack

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

## 充分原则

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

## 给宿主 AI 的使用方式

你正在读取 Doramagic 为 witness 编译的 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_0003` supported 0.86

## 它能做什么

- **多宿主安装与分发**（需要安装后验证）：项目包含插件或 marketplace 配置，说明它面向一个或多个 AI 宿主的安装和分发。 证据：`.claude-plugin/marketplace.json`, `.claude-plugin/plugin.json` Claim：`clm_0001` supported 0.86
- **命令行启动或安装流程**（需要安装后验证）：项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 证据：`README.md` Claim：`clm_0002` supported 0.86

## 怎么开始

- `npm install -g @witness-ai/opencode` 证据：`README.md` Claim：`clm_0004` supported 0.86

## 继续前判断卡

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

### 30 秒判断

- **现在怎么做**：需要管理员/安全审批
- **最小安全下一步**：先跑 Prompt Preview；若涉及凭证或企业环境，先审批再试装
- **先别相信**：这套流程是否适合你的工作方式不能直接相信。
- **继续会触碰**：宿主行为改变、命令执行、宿主 AI 配置

### 现在可以相信

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

### 现在还不能相信

- **这套流程是否适合你的工作方式不能直接相信。**（unverified）：流程型 Skill 可能强约束 AI 行为；它能提升纪律，也可能拖慢你当前任务节奏。 证据：`.claude-plugin/marketplace.json`, `.claude-plugin/plugin.json`, `AGENTS.md`, `CLAUDE.md`
- **不会和你已有 Claude/Cursor/Codex 规则冲突，不能直接相信。**（inferred）：开发流程 Skill 会改变澄清、计划、测试、验证等默认行为，必须在临时宿主里试。 证据：`.claude-plugin/marketplace.json`, `.claude-plugin/plugin.json`, `AGENTS.md`, `CLAUDE.md`
- **真实输出质量不能在安装前相信。**（unverified）：Prompt Preview 只能展示引导方式，不能证明真实项目中的结果质量。
- **宿主 AI 版本兼容性不能在安装前相信。**（unverified）：Claude、Cursor、Codex、Gemini 等宿主加载规则和版本差异必须在真实环境验证。
- **不会污染现有宿主 AI 行为，不能直接相信。**（inferred）：Skill、plugin、AGENTS/CLAUDE/GEMINI 指令可能改变宿主 AI 的默认行为。 证据：`.claude-plugin/marketplace.json`, `.claude-plugin/plugin.json`, `AGENTS.md`, `CLAUDE.md`
- **可安全回滚不能默认相信。**（unverified）：除非项目明确提供卸载和恢复说明，否则必须先在隔离环境验证。
- **真实安装后是否与用户当前宿主 AI 版本兼容？**（unverified）：兼容性只能通过实际宿主环境验证。 证据：`.claude-plugin/marketplace.json`, `.claude-plugin/plugin.json`
- **项目输出质量是否满足用户具体任务？**（unverified）：安装前预览只能展示流程和边界，不能替代真实评测。

### 继续会触碰什么

- **宿主行为改变**：澄清、计划、TDD、验证、收尾等默认开发节奏。 原因：这类 Skill 的价值和风险都来自强约束流程；必须先确认你愿意被它改变工作方式。 证据：`.claude-plugin/marketplace.json`, `.claude-plugin/plugin.json`, `AGENTS.md`, `CLAUDE.md`
- **命令执行**：包管理器、网络下载、本地插件目录、项目配置或用户主目录。 原因：运行第一条命令就可能产生环境改动；必须先判断是否值得跑。 证据：`README.md`
- **宿主 AI 配置**：Claude/Codex/Cursor/Gemini/OpenCode 等宿主的 plugin、Skill 或规则加载配置。 原因：宿主配置会改变 AI 后续工作方式，可能和用户已有规则冲突。 证据：`.claude-plugin/marketplace.json`, `.claude-plugin/plugin.json`, `AGENTS.md`, `CLAUDE.md`
- **本地环境或项目文件**：安装结果、插件缓存、项目配置或本地依赖目录。 原因：安装前无法证明写入范围和回滚方式，需要隔离验证。 证据：`.claude-plugin/marketplace.json`, `.claude-plugin/plugin.json`, `README.md`
- **环境变量 / API Key**：项目入口文档明确出现 API key、token、secret 或账号凭证配置。 原因：如果真实安装需要凭证，应先使用测试凭证并经过权限/合规判断。 证据：`README.md`, `npm/opencode/README.md`
- **宿主 AI 上下文**：AI Context Pack、Prompt Preview、Skill 路由、风险规则和项目事实。 原因：导入上下文会影响宿主 AI 后续判断，必须避免把未验证项包装成事实。

### 最小安全下一步

- **先跑 Prompt Preview**：先感受它会怎样改变 AI 的开发节奏，再决定是否让它进入真实宿主。（适用：任何项目都适用，尤其是输出质量未知时。）
- **只在隔离目录或测试账号试装**：避免安装命令污染主力宿主 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
- **宿主 AI 插件或 Skill 规则冲突**：新规则可能改变用户现有宿主 AI 的工作方式。 处理方式：安装前先检查插件 manifest 和 Skill 文件，必要时隔离测试。 证据：`.claude-plugin/marketplace.json`, `.claude-plugin/plugin.json` Claim：`clm_0006` supported 0.86
- **命令执行会修改本地环境**：安装命令可能写入用户主目录、宿主插件目录或项目配置。 处理方式：先在隔离环境或测试账号中运行。 证据：`README.md` Claim：`clm_0007` 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。

### 任务路由

- **多宿主安装与分发**：先说明这是安装后验证能力，再给出安装前检查清单。 边界：必须真实安装或运行后验证。 证据：`.claude-plugin/marketplace.json`, `.claude-plugin/plugin.json` Claim：`clm_0001` supported 0.86
- **命令行启动或安装流程**：先说明这是安装后验证能力，再给出安装前检查清单。 边界：必须真实安装或运行后验证。 证据：`README.md` Claim：`clm_0002` supported 0.86

### 上下文规模

- 文件总数：196
- 重要文件覆盖：40/196
- 证据索引条目：77
- 角色 / Skill 条目：15

### 证据不足时的处理

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

## Prompt Recipes

### 适配判断

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

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

### 安装前体验

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

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

请严格输出四段：
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
请基于 witness 的 AI Context Pack，生成一段我可以粘贴给宿主 AI 的开工前指令。这段指令必须遵守 not_runtime=true，不能声称项目已经安装、运行或产生真实结果。
```

## 角色 / Skill 索引

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

- **AGENTS.md**（project_doc）：Guidance for AI coding agents and humans working in this repo. Claude Code reads this via @AGENTS.md in CLAUDE.md CLAUDE.md ; other tools may read it directly. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`AGENTS.md`
- **Claude**（project_doc）： 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`CLAUDE.md`
- **witness — Let Claude Code and OpenCode witness your growth.**（project_doc）：witness — Let Claude Code and OpenCode witness your growth. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`README.md`
- **@witness-ai/opencode**（project_doc）：OpenCode plugin for witness. It reconciles OpenCode's local session database on startup and when a session goes idle, and starts witness distillation only through the CLI's laptop-friendly auto-start gate. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`npm/opencode/README.md`
- **@witness-ai/opencode-darwin-arm64**（project_doc）：Platform binary used by @witness-ai/opencode on macOS Apple Silicon. Install the main package instead of using this package directly. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`npm/platform/darwin-arm64/README.md`
- **@witness-ai/opencode-linux-x64**（project_doc）：Platform binary used by @witness-ai/opencode on Linux x86-64. Install the main package instead of using this package directly. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`npm/platform/linux-x64/README.md`
- **Example lens — a "math learner" lens**（project_doc）：Example lens — a "math learner" lens 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`prompts/lens/example/README.md`
- **What to look for dimensions**（project_doc）：You are a careful observer reading one work session between a user and an AI assistant. Your job is to notice things about the person — how they think, work, decide, struggle, and change — not about the task or the code. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`prompts/default/extract.md`
- **How to synthesize**（project_doc）：You are the reviewer for a long-term, person-centric growth archive. You read the accumulated observations L1 about how a person thinks, works, and changes, plus the current profile L2 of facets already established, and you produce an updated set of facet assertions. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`prompts/default/review.md`
- **Extract**（project_doc）：You are observing one study/work session between a person and an AI, through a MATH-LEARNING lens. Notice things about the person as a mathematician — how they reason, where they get stuck, and how they climb out — not the math facts themselves. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`prompts/lens/example/extract.md`
- **Review**（project_doc）：You are the reviewer for the MATH lens of a long-term, person-centric growth archive. You read the accumulated observations plus the current facets, and you assert what is true NOW, flagging genuine, sustained CHANGE over time. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`prompts/lens/example/review.md`
- **Bugfix Report: 101 / 91 / 97**（project_doc）：Commit: 4233e03 on branch work-issues Gate: ✅ make fmt vet test + race detector — all green 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`.superpowers/bugfix-report.md`
- **witness schema**（project_doc）：The data model in one page. Four layers: one ground-truth, three derived and regenerable. Everything lives in a single embedded SQLite database, witness.db , under the data root $WITNESS HOME , else $XDG DATA HOME/witness , else ~/.local/share/witness . The one exception is the L4 profile, written as plain markdown files so you can read them directly. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`prompts/SCHEMA.md`
- **Lens**（project_doc）：You are writing a short, honest narrative profile of a person for ONE lens of a long-term growth archive. You are given that lens's FACETS — synthesized, evidence-backed attributes, each with a confidence from 0 to 1. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`prompts/summarize/lens.md`
- **Unified**（project_doc）：You are writing a single UNIFIED portrait of a person for a long-term growth archive. You are given per-lens narrative summaries — each lens covers a domain general working style, mathematics, and so on . 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`prompts/summarize/unified.md`

## 证据索引

- 共索引 77 条证据。

- **AGENTS.md**（documentation）：Guidance for AI coding agents and humans working in this repo. Claude Code reads this via @AGENTS.md in CLAUDE.md CLAUDE.md ; other tools may read it directly. 证据：`AGENTS.md`
- **Claude**（documentation）：@AGENTS.md 证据：`CLAUDE.md`
- **witness — Let Claude Code and OpenCode witness your growth.**（documentation）：witness — Let Claude Code and OpenCode witness your growth. 证据：`README.md`
- **@witness-ai/opencode**（documentation）：OpenCode plugin for witness. It reconciles OpenCode's local session database on startup and when a session goes idle, and starts witness distillation only through the CLI's laptop-friendly auto-start gate. 证据：`npm/opencode/README.md`
- **@witness-ai/opencode-darwin-arm64**（documentation）：Platform binary used by @witness-ai/opencode on macOS Apple Silicon. Install the main package instead of using this package directly. 证据：`npm/platform/darwin-arm64/README.md`
- **@witness-ai/opencode-linux-x64**（documentation）：Platform binary used by @witness-ai/opencode on Linux x86-64. Install the main package instead of using this package directly. 证据：`npm/platform/linux-x64/README.md`
- **Example lens — a "math learner" lens**（documentation）：Example lens — a "math learner" lens 证据：`prompts/lens/example/README.md`
- **Package**（package_manifest）：{ "name": "@witness-ai/opencode", "mcpName": "io.github.IngTian/witness", "version": "0.5.1", "description": "MCP memory / second brain for Claude Code & OpenCode — captures your coding sessions and distills how your knowledge and habits evolve over time, queryable by your agent.", "type": "module", "main": "./witness.js", "exports": "./witness.js", "bin": { "witness": "bin/witness.js" }, "scripts": { "check": "node --test ./ .test.js ./bin/ .test.js", "prepublishOnly": "../../scripts/stage-npm-opencode.sh --build" }, "files": "witness.js", "bin/", "!bin/ .test.js", "prompts/", "README.md" , "optionalDependencies": { "@witness-ai/opencode-darwin-arm64": "0.5.1", "@witness-ai/opencode-linux-… 证据：`npm/opencode/package.json`
- **Package**（package_manifest）：{ "name": "@witness-ai/opencode-darwin-arm64", "version": "0.5.1", "description": "witness binary for OpenCode on macOS Apple Silicon.", "os": "darwin" , "cpu": "arm64" , "files": "bin/witness", "README.md" , "license": "MIT", "repository": { "type": "git", "url": "git+https://github.com/IngTian/witness.git", "directory": "npm/platform/darwin-arm64" }, "publishConfig": { "access": "public" } } 证据：`npm/platform/darwin-arm64/package.json`
- **Package**（package_manifest）：{ "name": "@witness-ai/opencode-linux-x64", "version": "0.5.1", "description": "witness binary for OpenCode on Linux x86-64.", "os": "linux" , "cpu": "x64" , "files": "bin/witness", "README.md" , "license": "MIT", "repository": { "type": "git", "url": "git+https://github.com/IngTian/witness.git", "directory": "npm/platform/linux-x64" }, "publishConfig": { "access": "public" } } 证据：`npm/platform/linux-x64/package.json`
- **Marketplace**（structured_config）：{ "name": "witness", "owner": { "name": "Zeying Tian", "url": "https://github.com/IngTian" }, "plugins": { "name": "witness", "source": "./", "version": "0.5.1", "description": "Local memory & self-improvement engine: quietly captures your coding sessions — and ingests your own records notes, articles, any text — then distills how your habits and knowledge evolve over time. A person-centric growth archive with provenance, served over an MCP read API + plain files. Global shareable lenses." } } 证据：`.claude-plugin/marketplace.json`
- **Plugin**（structured_config）：{ "name": "witness", "description": "Local memory & self-improvement engine for Claude Code: quietly captures your coding sessions — and ingests your own records notes, articles, any text — then distills how your thinking, habits, and knowledge evolve over time. A person-centric growth archive with provenance. A pure capture-and-serve tool not a coach , served over MCP + plain files, with global shareable lenses.", "version": "0.5.1", "author": { "name": "Zeying Tian", "url": "https://github.com/IngTian" }, "homepage": "https://github.com/IngTian/witness", "repository": "https://github.com/IngTian/witness", "license": "MIT", "mcpServers": { "witness": { "command": "${CLAUDE PLUGIN ROOT}/hoo… 证据：`.claude-plugin/plugin.json`
- **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`
- **What to look for dimensions**（documentation）：You are a careful observer reading one work session between a user and an AI assistant. Your job is to notice things about the person — how they think, work, decide, struggle, and change — not about the task or the code. 证据：`prompts/default/extract.md`
- **How to synthesize**（documentation）：You are the reviewer for a long-term, person-centric growth archive. You read the accumulated observations L1 about how a person thinks, works, and changes, plus the current profile L2 of facets already established, and you produce an updated set of facet assertions. 证据：`prompts/default/review.md`
- **Extract**（documentation）：You are observing one study/work session between a person and an AI, through a MATH-LEARNING lens. Notice things about the person as a mathematician — how they reason, where they get stuck, and how they climb out — not the math facts themselves. 证据：`prompts/lens/example/extract.md`
- **Review**（documentation）：You are the reviewer for the MATH lens of a long-term, person-centric growth archive. You read the accumulated observations plus the current facets, and you assert what is true NOW, flagging genuine, sustained CHANGE over time. 证据：`prompts/lens/example/review.md`
- **Server**（structured_config）：{ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json", "name": "io.github.IngTian/witness", "title": "witness", "description": "Second brain for Claude Code & OpenCode: distills how your patterns and knowledge evolve over time.", "websiteUrl": "https://github.com/IngTian/witness readme", "version": "0.5.1", "repository": { "url": "https://github.com/IngTian/witness", "source": "github" }, "packages": { "registryType": "npm", "registryBaseUrl": "https://registry.npmjs.org", "identifier": "@witness-ai/opencode", "version": "0.5.1", "runtimeHint": "npx", "transport": { "type": "stdio" }, "packageArguments": { "type": "positional", "value": "mcp", "valueHin… 证据：`server.json`
- **Lens**（structured_config）：{ "name": "default", "dimensions": "thinking", "workstyle", "habits", "traits", "biases", "state", "goals", "feedback" } 证据：`prompts/default/lens.json`
- **Lens**（structured_config）：{ "name": "math", "dimensions": "speed", "independence", "proof rigor", "abstraction", "confusion tolerance" } 证据：`prompts/lens/example/lens.json`
- **Go**（source_file）：require github.com/gomlx/gomlx v0.27.3 github.com/gomlx/onnx-gomlx v0.4.2 github.com/mattn/go-isatty v0.0.20 github.com/modelcontextprotocol/go-sdk v1.6.1 github.com/spf13/cobra v1.10.2 github.com/sugarme/tokenizer v0.3.0 golang.org/x/sys v0.44.0 modernc.org/sqlite v1.53.0 证据：`go.mod`
- **Install**（source_file）：set -euo pipefail cd "$ dirname "${BASH SOURCE 0 }" " TARGET="${1:-}" if "$TARGET" != "claude" && "$TARGET" != "opencode" ; then echo "usage: ./install.sh " &2 exit 1 fi if -t 1 ; then B=$ printf '\033 1m' ; D=$ printf '\033 2m' ; G=$ printf '\033 32m' C=$ printf '\033 36m' ; Y=$ printf '\033 33m' ; R=$ printf '\033 31m' ; X=$ printf '\033 0m' else B=""; D=""; G=""; C=""; Y=""; R=""; X="" fi TOTAL=4 step { printf '\n%s%s %s/%s %s %s%s%s\n' "$C" "$B" "$1" "$TOTAL" "$X" "$B" "$2" "$X"; } ok { printf ' %s✓%s %s\n' "$G" "$X" "$1"; } info { printf ' %s%s%s\n' "$D" "$1" "$X"; } die { printf '\n%s✗ %s%s\n' "$R" "$1" "$X" &2; exit 1; } printf '\n%s╭───────────────────────────────────────────╮%s\n'… 证据：`install.sh`
- **Smithery**（source_file）：startCommand: type: stdio configSchema: type: object properties: {} commandFunction: - config = { command: 'npx', args: '-y', '@witness-ai/opencode', 'mcp' , env: {} } 证据：`smithery.yaml`
- **Autoworker**（source_file）：package commands ⋮---- import "log/slog" "github.com/IngTian/witness/internal/embed" "github.com/IngTian/witness/internal/store" ⋮---- "log/slog" ⋮---- "github.com/IngTian/witness/internal/embed" "github.com/IngTian/witness/internal/store" ⋮---- func maybeSpawnAutoWorker st store.Store bool ⋮---- func autoWorkerShouldStart st store.Store, cfg store.Config, pending string, modelReady bool bool 证据：`cmd/commands/autoworker.go`
- **Capture**（source_file）：package commands ⋮---- import "io" "log/slog" "os" "time" "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- "io" "log/slog" "os" "time" ⋮---- "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- func newInternalCaptureCmd cobra.Command ⋮---- var agent string ⋮---- func cmdCapture args string error 证据：`cmd/commands/capture.go`
- **Cleanup**（source_file）：package commands ⋮---- import "bufio" "fmt" "os" "strconv" "strings" "time" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- "bufio" "fmt" "os" "strconv" "strings" "time" ⋮---- "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- func newCleanupCmd cobra.Command ⋮---- func cmdCleanup error 证据：`cmd/commands/cleanup.go`
- **Cli**（source_file）：package commands ⋮---- import "encoding/json" "fmt" "log/slog" "os" "os/exec" "strings" "github.com/IngTian/witness/internal/proc" "github.com/IngTian/witness/internal/store" ⋮---- "encoding/json" "fmt" "log/slog" "os" "os/exec" "strings" ⋮---- "github.com/IngTian/witness/internal/proc" "github.com/IngTian/witness/internal/store" ⋮---- var procCtl proc.Control = proc.System ⋮---- func emitJSON v any error ⋮---- // valueOrNever renders an empty timestamp as "never" for human-facing output. func valueOrNever v string string ⋮---- func setupLogging st store.Store func ⋮---- func spawnDetached args ...string ⋮---- func reportError err error ⋮---- func jsonOutputMode bool ⋮---- func agentFlag ar… 证据：`cmd/commands/cli.go`
- **Config**（source_file）：package commands ⋮---- import "encoding/json" "fmt" "os" "path/filepath" "strings" "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- "encoding/json" "fmt" "os" "path/filepath" "strings" ⋮---- "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- func canonicalConfigKey k string string ⋮---- func newConfigCmd cobra.Command ⋮---- var lensName string ⋮---- func cmdConfigGet args string, lensName string error ⋮---- // No key: print all, aligned, with the default marker for empty fields. ⋮---- func cmdConfigSet key, value string, lensName string error ⋮---- // runne… 证据：`cmd/commands/config.go`
- **Distill**（source_file）：package commands ⋮---- import "context" "fmt" "strconv" "strings" "time" "github.com/IngTian/witness/internal/store" ⋮---- "context" "fmt" "strconv" "strings" "time" ⋮---- "github.com/IngTian/witness/internal/store" ⋮---- type sessionTimeRange struct { since time.Time until time.Time } ⋮---- func r sessionTimeRange empty bool ⋮---- func cmdDistillStart quiet bool, sinceValue, untilValue string error ⋮---- func cmdDistillBackfill quiet bool, sinceValue, untilValue string, waitBackoffs bool error ⋮---- const backfillMaxWait = 15 time.Minute ⋮---- type backfillRetryDeps struct { rerun func error waitForNextRetry func time.Duration, bool sleep func ctx context.Context, d time.Duration maxWait t… 证据：`cmd/commands/distill.go`
- **Facets**（source_file）：package commands ⋮---- import "fmt" "slices" "strings" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- "fmt" "slices" "strings" ⋮---- "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- func newFacetsCmd cobra.Command ⋮---- var asJSON bool ⋮---- func cmdFacets args string, asJSON bool error ⋮---- // Whether this lens is registered AND enabled decides the right empty-state message: // since 44 slice 1a "default" is an ordinary, DELETABLE lens, so an absent lens the ⋮---- type facetsJSON struct { Lens string json:"lens" Facets store.Facet json:"facets" } ⋮---- func renderCurrentFacets lensName string, facets store.Facet, registered, enabled bo… 证据：`cmd/commands/facets.go`
- **Ingest**（source_file）：package commands ⋮---- import "bufio" "crypto/sha256" "encoding/json" "fmt" "io" "log/slog" "os" "strings" "time" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- "bufio" "crypto/sha256" "encoding/json" "fmt" "io" "log/slog" "os" "strings" "time" ⋮---- "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- type ingestRecord struct { Text string json:"text" ID string json:"id" Session string json:"session" TS string json:"ts" Role string json:"role" } ⋮---- type ingestSession struct { Session string Records store.RawRecord Keys string IDs string } ⋮---- func parseNDJSON r io.Reader recs ingestRecord, skipped int ⋮---- var rec ingestRecord ⋮---- /… 证据：`cmd/commands/ingest.go`
- **Install**（source_file）：package commands ⋮---- import "encoding/json" "fmt" "os" "os/exec" "path/filepath" "strings" "github.com/IngTian/witness/internal/platform" opencodeplugin "github.com/IngTian/witness/internal/platform/opencode/plugin" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- "encoding/json" "fmt" "os" "os/exec" "path/filepath" "strings" ⋮---- "github.com/IngTian/witness/internal/platform" opencodeplugin "github.com/IngTian/witness/internal/platform/opencode/plugin" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- func newWireCmd cobra.Command ⋮---- func newUnwireCmd cobra.Command ⋮---- func newInstallCmd cobra.Command ⋮---- var path string ⋮---- //… 证据：`cmd/commands/install.go`
- **Installers**（source_file）：package commands ⋮---- import "github.com/IngTian/witness/internal/platform" ⋮---- func init ⋮---- type claudeInstaller struct{} ⋮---- func claudeInstaller Install error func claudeInstaller Uninstall error ⋮---- type openCodeInstaller struct{} 证据：`cmd/commands/installers.go`
- **Lens**（source_file）：package commands ⋮---- import "bufio" "fmt" "log/slog" "os" "slices" "strings" "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- "bufio" "fmt" "log/slog" "os" "slices" "strings" ⋮---- "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- func newLensCmd cobra.Command ⋮---- func newLensBackfillCmd cobra.Command ⋮---- var fresh, yes bool ⋮---- func cmdLens args string error ⋮---- func lensBackfill st store.Store, name string, fresh, assumeYes bool error ⋮---- func newLensShowCmd cobra.Command ⋮---- var prompts bool ⋮---- func lensShow name string, full bool error… 证据：`cmd/commands/lens.go`
- **Mcp**（source_file）：package commands ⋮---- import "context" "github.com/IngTian/witness/internal/embed" "github.com/IngTian/witness/internal/mcp" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- "context" ⋮---- "github.com/IngTian/witness/internal/embed" "github.com/IngTian/witness/internal/mcp" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- func newInternalMCPCmd cobra.Command ⋮---- func cmdMCP error 证据：`cmd/commands/mcp.go`
- **Profile**（source_file）：package commands ⋮---- import "fmt" "strings" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- "fmt" "strings" ⋮---- "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- func newProfileCmd cobra.Command ⋮---- var asJSON bool ⋮---- func cmdProfile args string, asJSON bool error ⋮---- type profileJSON struct { Lens string json:"lens" Markdown string json:"markdown" Freshness profileFreshness json:"freshness" } ⋮---- type profileFreshness struct { DistilledThrough string json:"distilled through" RawThrough string json:"raw through" Pending int json:"pending" } 证据：`cmd/commands/profile.go`
- **Worker**（source_file）：package commands ⋮---- import "context" "fmt" "log/slog" "os" "strconv" "time" "github.com/IngTian/witness/internal/distill" "github.com/IngTian/witness/internal/embed" "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- "context" "fmt" "log/slog" "os" "strconv" "time" ⋮---- "github.com/IngTian/witness/internal/distill" "github.com/IngTian/witness/internal/embed" "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" "github.com/spf13/cobra" ⋮---- func newInternalWorkerCmd cobra.Command ⋮---- var auto bool var since string var until string ⋮---- func cmdWorker args string error ⋮---- func worke… 证据：`cmd/commands/worker.go`
- **Main**（source_file）：package main ⋮---- import "os" "github.com/IngTian/witness/cmd/commands" ⋮---- "os" ⋮---- "github.com/IngTian/witness/cmd/commands" ⋮---- func main 证据：`cmd/witness/main.go`
- **Drain**（source_file）：package distill ⋮---- import "context" "fmt" "log/slog" "runtime" "strconv" "sync" "github.com/IngTian/witness/internal/store" ⋮---- "context" "fmt" "log/slog" "runtime" "strconv" "sync" ⋮---- "github.com/IngTian/witness/internal/store" ⋮---- const maxMineConcurrency = 16 ⋮---- const maxInFlightChars = 2 000 000 ⋮---- func EffectiveConcurrency want int, concurrentRunSafe bool int ⋮---- type DrainOpts struct { Conc int Pending func string Stop func bool Max int OnCommit func session string Attempted map string bool Sized func session string int MaxChars int } ⋮---- func w Worker attemptKey session string string ⋮---- func w Worker lensNames string ⋮---- func w Worker HasUnattempted sessions… 证据：`internal/distill/drain.go`
- **Model**（source_file）：package distill ⋮---- import "strings" "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" ⋮---- "strings" ⋮---- "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" ⋮---- type Phase int ⋮---- const PhaseExtract Phase = iota PhaseReview ⋮---- func RunnerFor cfg store.Config, ln lens.Lens string ⋮---- // ModelFor resolves the model for a phase on a given lens issue 75 . A lens's per-lens // model override always wins. Otherwise the fallback depends on WHICH RUNNER the lens // runs on: // - lens on the default runner no per-lens Runner, or one equal to cfg.Runner → the // default stage model TriageModel for extract, DistillM… 证据：`internal/distill/model.go`
- **Reviewer**（source_file）：package distill ⋮---- import "context" "fmt" "strings" "time" "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" ⋮---- "context" "fmt" "strings" "time" ⋮---- "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" ⋮---- type Reviewer struct { Store store.ReviewStore Lenses lens.Lens Config store.Config Runner MineFunc RunnerFor func ln lens.Lens MineFunc } ⋮---- func r Reviewer runnerFor ln lens.Lens MineFunc ⋮---- type reviewedFacet struct { Dimension string json:"dimension" Key string json:"key" Value string json:"value" Confidence float64 json:"confidence" BecauseOf string json:"because of" Contradicts bool json:"contradi… 证据：`internal/distill/reviewer.go`
- **Summarize**（source_file）：package distill ⋮---- import "context" "crypto/sha256" "encoding/hex" "fmt" "sort" "strings" "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" ⋮---- "context" "crypto/sha256" "encoding/hex" "fmt" "sort" "strings" ⋮---- "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/store" ⋮---- func profileSigKey lens string string ⋮---- func summarySignature model, prompt, renderedFacets string string ⋮---- type Summarizer struct { Store store.SummaryStore Config store.Config Lenses lens.Lens LensPrompt string UnifiedPrompt string Run SummarizeFunc RunFor func ln lens.Lens SummarizeFunc } ⋮---- func sm Summarizer runFor ln lens.Lens Summ… 证据：`internal/distill/summarize.go`
- **Worker**（source_file）：package distill ⋮---- import "context" "crypto/sha1" "encoding/json" "errors" "fmt" "log/slog" "strings" "time" "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/store" "github.com/IngTian/witness/internal/vector" ⋮---- "context" "crypto/sha1" "encoding/json" "errors" "fmt" "log/slog" "strings" "time" ⋮---- "github.com/IngTian/witness/internal/lens" "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/store" "github.com/IngTian/witness/internal/vector" ⋮---- var errNoArray = errors.New "mine: model reply contained no JSON observation array prose drift " ⋮---- const backoffBase = 5 tim… 证据：`internal/distill/worker.go`
- **Embed**（source_file）：package embed ⋮---- import "fmt" "math" "os" "path/filepath" "sync" "github.com/IngTian/witness/internal/bundle" "github.com/gomlx/gomlx/backends" "github.com/gomlx/gomlx/backends/simplego" "github.com/gomlx/gomlx/pkg/core/graph" "github.com/gomlx/gomlx/pkg/core/tensors" "github.com/gomlx/gomlx/pkg/ml/context" "github.com/gomlx/onnx-gomlx/onnx" "github.com/gomlx/onnx-gomlx/onnx/parser" "github.com/sugarme/tokenizer" "github.com/sugarme/tokenizer/pretrained" ⋮---- "fmt" "math" "os" "path/filepath" "sync" ⋮---- "github.com/IngTian/witness/internal/bundle" "github.com/gomlx/gomlx/backends" "github.com/gomlx/gomlx/backends/simplego" "github.com/gomlx/gomlx/pkg/core/graph" "github.com/gomlx/goml… 证据：`internal/embed/embed.go`
- **Lens**（source_file）：package lens ⋮---- import "encoding/json" "fmt" "os" "path/filepath" "strings" "github.com/IngTian/witness/internal/bundle" "github.com/IngTian/witness/internal/store" ⋮---- "encoding/json" "fmt" "os" "path/filepath" "strings" ⋮---- "github.com/IngTian/witness/internal/bundle" "github.com/IngTian/witness/internal/store" ⋮---- type Lens struct { Name string BuiltIn bool Dimensions string Extract string Review string Runner string ExtractModel string ReviewModel string } ⋮---- type LensConfig struct { Name string json:"name,omitempty" Dimensions string json:"dimensions,omitempty" Runner string json:"runner,omitempty" ExtractModel string json:"extract model,omitempty" ReviewModel string json:"… 证据：`internal/lens/lens.go`
- **Hash**（source_file）：package mcp ⋮---- import "crypto/sha1" "fmt" ⋮---- "crypto/sha1" "fmt" ⋮---- func sha1sum s string string 证据：`internal/mcp/hash.go`
- **Server**（source_file）：package mcp ⋮---- import "context" "fmt" "strings" "time" mcpsdk "github.com/modelcontextprotocol/go-sdk/mcp" "github.com/IngTian/witness/internal/store" "github.com/IngTian/witness/internal/vector" ⋮---- "context" "fmt" "strings" "time" ⋮---- mcpsdk "github.com/modelcontextprotocol/go-sdk/mcp" ⋮---- "github.com/IngTian/witness/internal/store" "github.com/IngTian/witness/internal/vector" ⋮---- type searchInput struct { Query string json:"query" jsonschema:"the growth/pattern question to search for" Lens string json:"lens,omitempty" jsonschema:"which lens to search; omit for the always-on 'default' lens cross-domain , or name a repo lens like 'math'" K int json:"k,omitempty" jsonschema:"max… 证据：`internal/mcp/server.go`
- **Capture**（source_file）：package claude ⋮---- import "time" "github.com/IngTian/witness/internal/store" ⋮---- "time" ⋮---- "github.com/IngTian/witness/internal/store" ⋮---- type HookEvent struct { HookEventName string json:"hook event name" SessionID string json:"session id" Prompt string json:"prompt" LastAssistantMessage string json:"last assistant message" Effort map string any json:"effort" Cwd string json:"cwd" } ⋮---- func Capture st store.RawWriter, e HookEvent, now time.Time error ⋮---- var rec store.RawRecord 证据：`internal/platform/claude/capture.go`
- **Platform**（source_file）：package claude ⋮---- import "context" "encoding/json" "time" "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/store" ⋮---- "context" "encoding/json" "time" ⋮---- "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/store" ⋮---- type Platform struct{} ⋮---- func init ⋮---- func Platform Name string ⋮---- func Platform SessionPrefix string ⋮---- // RenderInputs shapes the session by the shared, source-agnostic policy. Claude is // hook-fed flat text no structured parts and was ALWAYS sent whole; that is still // the default policy.MaxChars <= 0 , and the measured 57 conclusion says it should // be — whole-session mining is what… 证据：`internal/platform/claude/platform.go`
- **Platform**（source_file）：package file ⋮---- import "context" "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/store" ⋮---- "context" ⋮---- "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/store" ⋮---- type Platform struct{} ⋮---- func init ⋮---- func Platform Name string ⋮---- func Platform SessionPrefix string ⋮---- func Platform RenderInputs raw store.RawRecord, policy platform.ChunkPolicy string ⋮---- func Platform Import context.Context, store.ImportStore, string platform.ImportStats, error 证据：`internal/platform/file/platform.go`
- **Cleanup**（source_file）：package opencode ⋮---- import "context" "database/sql" "fmt" "net/url" "path/filepath" "strings" "time" ⋮---- "context" "database/sql" "fmt" "net/url" "path/filepath" "strings" "time" ⋮---- func CleanupWitnessDistillSessions ctx context.Context, dbPath string, before time.Time int64, error ⋮---- var err error ⋮---- func sqliteWriteURI path string string ⋮---- func hasSessionColumn ctx context.Context, tx sql.Tx, column string bool ⋮---- func hasTableColumn ctx context.Context, tx sql.Tx, table, column string bool ⋮---- var cid int var name, typ string var notNull int var dflt any var pk int 证据：`internal/platform/opencode/cleanup.go`
- **Import**（source_file）：package opencode ⋮---- import "context" "crypto/sha256" "database/sql" "encoding/json" "fmt" "net/url" "os" "path/filepath" "strconv" "strings" "time" "github.com/IngTian/witness/internal/store" ⋮---- "context" "crypto/sha256" "database/sql" "encoding/json" "fmt" "net/url" "os" "path/filepath" "strconv" "strings" "time" ⋮---- "github.com/IngTian/witness/internal/store" ⋮---- const SessionPrefix = "opencode:" syncMetaKey = "opencode sync time updated ms" importKeysMetaPrefix = "opencode import keys:" ⋮---- type Importer struct { Store store.ImportStore DBPath string } ⋮---- type ImportStats struct { Sessions int Records int MaxUpdated int64 } ⋮---- type sessionRow struct { ID string Director… 证据：`internal/platform/opencode/import.go`
- **Platform**（source_file）：package opencode ⋮---- import "context" "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/store" ⋮---- "context" ⋮---- "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/store" ⋮---- type Platform struct{} ⋮---- func init ⋮---- func Platform Name string ⋮---- func Platform SessionPrefix string ⋮---- func Platform RenderInputs raw store.RawRecord, policy platform.ChunkPolicy string ⋮---- func Platform Import ctx context.Context, st store.ImportStore, sessionIDs string platform.ImportStats, error 证据：`internal/platform/opencode/platform.go`
- **Server**（source_file）：package opencode ⋮---- import "bytes" "context" "crypto/rand" "encoding/hex" "encoding/json" "fmt" "io" "log/slog" "net" "net/http" "os" "os/exec" "path/filepath" "strings" "sync" "time" "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/proc" ⋮---- "bytes" "context" "crypto/rand" "encoding/hex" "encoding/json" "fmt" "io" "log/slog" "net" "net/http" "os" "os/exec" "path/filepath" "strings" "sync" "time" ⋮---- "github.com/IngTian/witness/internal/platform" "github.com/IngTian/witness/internal/proc" ⋮---- var procCtl proc.Control = proc.System ⋮---- var openCodeModelsCache sync.Map ⋮---- var openCodeAsyncPollInterval = time.Second ⋮---- type openCodeModelList… 证据：`internal/platform/opencode/server.go`
- **Platform**（source_file）：package platform ⋮---- const AgentClaude = "claude" AgentOpenCode = "opencode" ⋮---- type ImportStats struct { Agent string Sessions int Records int MaxUpdated int64 } 证据：`internal/platform/platform.go`
- **Proc**（source_file）：package proc ⋮---- import "context" "os" "os/exec" "os/signal" "strconv" "strings" "syscall" ⋮---- "context" "os" "os/exec" "os/signal" "strconv" "strings" "syscall" ⋮---- type Control interface { Detach cmd exec.Cmd BindToParent cmd exec.Cmd ReapOrphans want func cmdline string bool TerminateGroup pid int error NotifyStop parent context.Context context.Context, context.CancelFunc GracefulStop p os.Process error } ⋮---- func System Control ⋮---- type sys struct{} ⋮---- func sys NotifyStop parent context.Context context.Context, context.CancelFunc ⋮---- func sys GracefulStop p os.Process error ⋮---- func ensureSysProcAttr cmd exec.Cmd syscall.SysProcAttr ⋮---- func OrphanPIDs psOutput string… 证据：`internal/proc/proc.go`
- **Proc Linux**（source_file）：//go:build linux ⋮---- package proc ⋮---- import "os/exec" "syscall" ⋮---- "os/exec" "syscall" ⋮---- func sys BindToParent cmd exec.Cmd ⋮---- func sys ReapOrphans want func cmdline string bool 证据：`internal/proc/proc_linux.go`
- **Config**（source_file）：package store ⋮---- import "database/sql" "fmt" "os" "path/filepath" "slices" "strconv" "strings" "time" ⋮---- "database/sql" "fmt" "os" "path/filepath" "slices" "strconv" "strings" "time" ⋮---- const RunnerClaude = "claude" RunnerOpenCode = "opencode" ⋮---- type Config struct { Runner string TriageModel string DistillModel string ReviewEvery int ReviewPoignancy int AutoDistill bool MineConcurrency int ChunkMaxChars int EnabledLenses string } ⋮---- const DefaultMineConcurrency = 4 ⋮---- type configFile struct { db sql.DB root string } ⋮---- func configTomlPath root string string ⋮---- func c configFile configPath string ⋮---- func DefaultConfig Config ⋮---- TriageModel: "", // empty = let c… 证据：`internal/store/config.go`
- **Db**（source_file）：package store ⋮---- import "database/sql" "encoding/binary" "fmt" "math" "os" "path/filepath" "modernc.org/sqlite" ⋮---- "database/sql" "encoding/binary" "fmt" "math" "os" "path/filepath" ⋮---- "modernc.org/sqlite" ⋮---- const schemaVersion = 7 ⋮---- func s Store dbPath string ⋮---- func openDB path string sql.DB, error ⋮---- func s Store Export dst string, force bool error ⋮---- func migrate db sql.DB error ⋮---- var v int ⋮---- var hasL0, hasRaw int ⋮---- func addSessionPlatformColumn tx sql.Tx error ⋮---- var hasColumn int ⋮---- func migrateProgressPerLens tx sql.Tx error ⋮---- var hasLens int ⋮---- func addProgressIndexes tx sql.Tx error ⋮---- func addDriftColumn tx sql.Tx error ⋮---- c… 证据：`internal/store/db.go`
- **Facets**（source_file）：package store ⋮---- import "database/sql" "encoding/json" ⋮---- "database/sql" "encoding/json" ⋮---- type facetIO struct{ db sql.DB } ⋮---- func f facetIO ReadFacets Facet, error ⋮---- var out Facet var curID int64 = -1 ⋮---- var id int64 lens, dim, key, lastSeen string value, vFrom, vTo, recAt, because string confidence float64 ⋮---- func f facetIO WriteFacets facets Facet error ⋮---- func deref p string string func derefF p float64 float64 证据：`internal/store/facets.go`
- 其余 17 条证据见 `AI_CONTEXT_PACK.json` 或 `EVIDENCE_INDEX.json`。

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

- **把本资产当作开工前上下文，而不是运行环境。**：AI Context Pack 只包含证据化项目理解，不包含目标项目的可执行状态。 证据：`AGENTS.md`, `CLAUDE.md`, `README.md`
- **回答用户时区分可预览内容与必须安装后才能验证的内容。**：安装前体验的消费者价值来自降低误装和误判，而不是伪装成真实运行。 证据：`AGENTS.md`, `CLAUDE.md`, `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, AGENTS.md, CLAUDE.md
- **系统架构与四层蒸馏管线**：importance `high`
  - source_paths: internal/distill/drain.go, internal/distill/worker.go, internal/distill/reviewer.go, internal/distill/model.go, internal/distill/summarize.go
- **数据存储与档案结构**：importance `high`
  - source_paths: internal/store/store.go, internal/store/db.go, internal/store/facets.go, internal/store/raw.go, internal/store/profile.go
- **Lens 镜头系统与自定义领域**：importance `high`
  - source_paths: internal/lens/lens.go, internal/store/lensreg.go, internal/store/lensmigrate.go, prompts/lens/example/lens.json, prompts/lens/example/extract.md
- **MCP 服务与智能体集成**：importance `high`
  - source_paths: internal/mcp/server.go, internal/mcp/hash.go, cmd/commands/mcp.go, server.json, smithery.yaml
- **平台适配与 ingest 记录入口**：importance `high`
  - source_paths: internal/platform/claude/platform.go, internal/platform/claude/capture.go, internal/platform/opencode/platform.go, internal/platform/opencode/import.go, internal/platform/opencode/server.go
- **安装、发行版与 CLI 操作**：importance `high`
  - source_paths: install.sh, Makefile, cmd/witness/main.go, cmd/commands/cli.go, cmd/commands/install.go
- **配置、模型与故障排查**：importance `medium`
  - source_paths: internal/store/config.go, cmd/commands/config.go, cmd/commands/lens.go, internal/embed/embed.go, internal/proc/proc.go

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

- repo_clone_verified: true
- repo_inspection_verified: true
- repo_commit: `156103f4f8778897f7940f1b3207f28272202a69`
- inspected_files: `README.md`

宿主 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: 能力证据存在缺口

- Trigger: Sandbox install result is missing.
- Host AI rule: 优先补证或在页面明确标记为未验证。
- Why it matters: 缺口未补前，Doramagic 不能把该能力当作可靠推荐卖点。
- Evidence: evidence.evidence_gaps | https://github.com/IngTian/witness | Sandbox install result is missing.
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 2: 可能需要本地编译工具链

- Trigger: 安装入口或说明出现本地编译相关关键词：make install
- Host AI rule: 沙箱验证不同系统的安装失败模式。
- Why it matters: Windows/macOS 用户可能卡在编译依赖上。
- Evidence: identity.distribution | https://github.com/IngTian/witness | make install
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 3: 失败模式：installation: Make witness discoverable by agents doing tool-discovery (empty description/topics; name coll...

- Trigger: Developers should check this installation risk before relying on the project: Make witness discoverable by agents doing tool-discovery (empty description/topics; name collision)
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: Make witness discoverable by agents doing tool-discovery (empty description/topics; name collision). Context: Observed when using node
- Why it matters: Developers may fail before the first successful local run: Make witness discoverable by agents doing tool-discovery (empty description/topics; name collision)
- Evidence: failure_mode_cluster:github_issue | https://github.com/IngTian/witness/issues/45 | Make witness discoverable by agents doing tool-discovery (empty description/topics; name collision)
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 4: 失败模式：installation: cleanup: tighten install/lens/npm command surface — install=mechanism, seed+interactivity sep...

- Trigger: Developers should check this installation risk before relying on the project: cleanup: tighten install/lens/npm command surface — install=mechanism, seed+interactivity separate (post-#44-slice1a)
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: cleanup: tighten install/lens/npm command surface — install=mechanism, seed+interactivity separate (post-#44-slice1a). Context: Observed when using node
- Why it matters: Developers may fail before the first successful local run: cleanup: tighten install/lens/npm command surface — install=mechanism, seed+interactivity separate (post-#44-slice1a)
- Evidence: failure_mode_cluster:github_issue | https://github.com/IngTian/witness/issues/102 | cleanup: tighten install/lens/npm command surface — install=mechanism, seed+interactivity separate (post-#44-slice1a)
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 5: 失败模式：installation: v0.1.0 — Claude Code

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

### Constraint 6: 失败模式：installation: v0.2.0 — Windows (Claude Code) + hardening

- Trigger: Developers should check this installation risk before relying on the project: v0.2.0 — Windows (Claude Code) + hardening
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: v0.2.0 — Windows (Claude Code) + hardening. Context: Observed when using windows, macos, linux
- Why it matters: Upgrade or migration may change expected behavior: v0.2.0 — Windows (Claude Code) + hardening
- Evidence: failure_mode_cluster:github_release | https://github.com/IngTian/witness/releases/tag/v0.2.0 | v0.2.0 — Windows (Claude Code) + hardening
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 7: 失败模式：installation: v0.2.1 — module rename, export, npm auto-publish

- Trigger: Developers should check this installation risk before relying on the project: v0.2.1 — module rename, export, npm auto-publish
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: v0.2.1 — module rename, export, npm auto-publish. Context: Observed when using node, windows
- Why it matters: Upgrade or migration may change expected behavior: v0.2.1 — module rename, export, npm auto-publish
- Evidence: failure_mode_cluster:github_release | https://github.com/IngTian/witness/releases/tag/v0.2.1 | v0.2.1 — module rename, export, npm auto-publish
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 8: 失败模式：installation: v0.2.3 — parallel mining · opencode idle-reconcile · discovery

- Trigger: Developers should check this installation risk before relying on the project: v0.2.3 — parallel mining · opencode idle-reconcile · discovery
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: v0.2.3 — parallel mining · opencode idle-reconcile · discovery. Context: Observed when using node, windows, macos, linux
- Why it matters: Upgrade or migration may change expected behavior: v0.2.3 — parallel mining · opencode idle-reconcile · discovery
- Evidence: failure_mode_cluster:github_release | https://github.com/IngTian/witness/releases/tag/v0.2.3 | v0.2.3 — parallel mining · opencode idle-reconcile · discovery
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 9: 失败模式：installation: v0.2.4 — audit fixes: worker livelock, watermark CAS, hardening

- Trigger: Developers should check this installation risk before relying on the project: v0.2.4 — audit fixes: worker livelock, watermark CAS, hardening
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: v0.2.4 — audit fixes: worker livelock, watermark CAS, hardening. Context: Observed when using node, windows, macos, linux
- Why it matters: Upgrade or migration may change expected behavior: v0.2.4 — audit fixes: worker livelock, watermark CAS, hardening
- Evidence: failure_mode_cluster:github_release | https://github.com/IngTian/witness/releases/tag/v0.2.4 | v0.2.4 — audit fixes: worker livelock, watermark CAS, hardening
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 10: 失败模式：installation: v0.3.0 — per-lens tuning, cross-runtime distillation, architecture hardening

- Trigger: Developers should check this installation risk before relying on the project: v0.3.0 — per-lens tuning, cross-runtime distillation, architecture hardening
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: v0.3.0 — per-lens tuning, cross-runtime distillation, architecture hardening. Context: Observed when using node, python, windows
- Why it matters: Upgrade or migration may change expected behavior: v0.3.0 — per-lens tuning, cross-runtime distillation, architecture hardening
- Evidence: failure_mode_cluster:github_release | https://github.com/IngTian/witness/releases/tag/v0.3.0 | v0.3.0 — per-lens tuning, cross-runtime distillation, architecture hardening
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。
