1实现原理 · 为什么它能做到
功能载体是 6 个本地 Python CLI(list_local_history / read_claude_session / extract_user_messages / analyze_sessions / history_index / recover_content),各自对应 inventory、精确会话重建、人工输入导出、关键词检索、混合召回、triage、文件恢复;agent 按 SKILL 路由表调用,明确禁止恢复旧进程。
| Recent Claude Code sessions, titles, dates, or IDs | `scripts/list_local_history.py --source claude` |
『找不到』是昂贵答案:跨多 home 全量发现是正确性根基。homes.py 枚举 CLAUDE_CONFIG_DIR、~/.claude、~/.claude-profiles/* 与 ~/.claude-* 兄弟 home;sources.py 再并入 ~/.claude/history-sources.json 注册的归档;按 Session ID 去重、以记录内时间戳而非 mtime 排序。
# CLAUDE_CONFIG_DIR wins first when set, then the default home.
对 Claude 记录做语义而非字面处理:storage label(type: user)不等于作者;忙碌期间的排队指令藏在 attachment.queued_command.prompt(origin.kind: human),只读 user 记录会丢修正。
Treat Claude's record labels as storage metadata, not authorship proof.
可选『混合召回』路径(history_index.py recall):中文分词 FTS5(wangfenjin/simple libsimple,固定版本 v0.7.1 + SHA256 校验下载)+ Qwen3 嵌入向量(Apple Silicon MLX),BM25/向量融合,解决『措辞变了』的语义召回;不属于默认只读路径。
EMBEDDING_MODEL_ID = "Qwen/Qwen3-Embedding-0.6B"
文件恢复(recover_content.py)走『报告-批准-写入』三段门禁:先对精确 Session 文件出恢复报告,人工审阅每个目标路径后才写;且禁止直接覆盖当前项目树。
First run the recovery report against the exact Session file, review every proposed destination, then write only after the user asked to recover content. Never restore directly over the current project tree.
Kimi CLI 历史是该 skill 的活表面:inventory 走 list_local_history.py --source kimi,全文检索走 analyze_sessions.py search --kimi,解析 ~/.kimi-code 下的 state.json/wire JSONL(home 优先级 --kimi-home > KIMI_HOME > ~/.kimi-code)。
Kimi CLI (kimi-code) stores conversations under ``~/.kimi-code/`` (override with ``KIMI_HOME``).
2核心能力
3外部依赖
| Kind | Dependency / Endpoint |
|---|---|
| cli | git |
| cli | rg/grep(可选路径预过滤) |
| network | github.com 发布物下载(wangfenjin/simple libsimple,固定版本+SHA256 校验,仅混合索引 setup) |
| network | Hugging Face 模型(Qwen/Qwen3-Embedding-0.6B,仅 --download-model 经 mlx_embeddings.load) |
| package | 可选 Python 依赖 chonkie/transformers(分块)与 mlx-embeddings/mlx(Apple Silicon 向量) |
4管控建议与判定依据
- scripts/: 执行本地脚本或命令: python3 运行 6 个自带脚本(默认纯 stdlib)
- 网络端点: 声明外部网络访问: urllib.urlopen 下载 https://github.com/wangfenjin/simple/releases/download/v0
- 本地工作目录: 文件读写与工件输出: extract_user_messages.py 向用户给定输出基址写 Markdown/HTML
5第二遍独立确认
- [ok] libsimple 下载(github.com/wangfenjin/simple)调用点 — history_index.py url 构造 + urlopen;sha256 校验与 _safe_extract_zip 穿越防护真实存在。
- [ok] 无其他网络调用(排除 requests/curl/wget/其他 urlopen) — 全目录扫描仅 history_index.py 引入 urllib.request;其余脚本零网络 import。
- [ok] Kimi 表面真实存在且只读 — list_local_history.py argparse choices 含 kimi;analyze_sessions.py search 有 --kimi/--kimi-home;_core/kimi.py 只解析 state.json/wire.jsonl,无 kimi CLI 调用。
- [ok] read-only 承诺与写盘面核对 — SKILL guardrails 禁止 resume/continue;写盘仅 extract_user_messages(用户给输出基址)、recover_content(报告后批准)、history_index(可选索引库)。
- [unlocatable] Qwen 嵌入模型网络端点 — 静态证据止于 EMBEDDING_MODEL_ID + mlx_embeddings.load(...) 与 ~/.cache/huggingface 路径;HF 实际网络端点由 mlx-embeddings 库行为决定,源码未直写,未运行验证。
- [ok] 能力声明夸大检查(exact timelines/verbatim input/full-event search) — read_claude_session.py 严格解析含 compaction 前记录、extract_user_messages 去噪逻辑(NOISE_USER_PATTERNS/IMG_TOKEN_RE)、analyze_sessions 预算超时显式失败——均有代码与测试佐证。
6结论
646d5ca94bdfe86a…