SuperAPI AI 工具集

jsonl-core

通用与其它

查看项目

更新于 10-16 07:18

技能介绍

用途:解析与检索 Claude 会话历史。JSONL 解析逻辑集中在 ${CLAUDE_PLUGIN_ROOT}/scripts/echolib.py(仅用 Python 标准库,Python 3.6+),shell 脚本为其薄封装。

数据位置:会话索引 ~/.claude/projects/<encoded-path>/sessions-index.json;回退索引 .echo-sleuth-index.json;完整对话 <uuid>.jsonl;子代理对话 <uuid>/subagents/agent-<id>.jsonl;全局提示历史 ~/.claude/history.jsonl。仅约 10% 项目有 sessions-index.json,其余自动构建回退索引并缓存。

主要能力:先用索引再打开 JSONL,列表命令如 bash ${CLAUDE_PLUGIN_ROOT}/scripts/list-sessions.sh "current" --limit 20;解析命令 bash ${CLAUDE_PLUGIN_ROOT}/scripts/parse-jsonl.sh <file.jsonl> [--detect-schema|--types user,assistant --skip-noise --limit 20|--fields ... --format tsv];便捷脚本 extract-messages.sh、extract-tools.sh、extract-files-changed.sh、session-stats.sh、build-index.sh。

用法要点:FULL_PATH 为 JSONL 绝对路径,供其他脚本使用;--thinking 隐藏时可截断;大文件反向读取;噪声类型 progress、queue-operation、isMeta、isCompactSummary、synthetic 应跳过;脚本不足时可用 Grep 定向搜索。

限制:仅适用于该 JSONL 格式;Python 启动开销主导小文件;大文件 json.loads 为瓶颈;格式随版本演变,字段可能缺失;Unicode 路径编码有损,需以 originalPath 为准。