ce-session-extract
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSession extract
会话提取
Agent-facing primitive. Extract filtered content from a single Claude Code, Codex, or Cursor session file — either a conversation skeleton or error signals.
This skill exists so that agents do not read multi-megabyte session files into context. The scripts under own the JSONL shape knowledge and emit a narrative-readable digest.
scripts/面向Agent的基础工具。从单个Claude Code、Codex或Cursor会话文件中提取过滤后的内容——可以是对话框架或错误信号。
该技能的存在是为了避免Agent将数兆字节的会话文件读入上下文。目录下的脚本掌握JSONL格式相关知识,并生成便于阅读的摘要内容。
scripts/Arguments
参数
Space-separated positional args:
- — absolute path to a session JSONL file (typically a
<file>value returned byfile).ce-session-inventory - —
<mode>orskeleton.errors - (optional) —
<limit>orhead:Nto cap output at N lines (e.g.,tail:N). Omit to return full extraction.head:200
空格分隔的位置参数:
- — 会话JSONL文件的绝对路径(通常是
<file>返回的ce-session-inventory值)。file - —
<mode>(框架)或skeleton(错误)。errors - (可选)——
<limit>或head:N,用于将输出限制为N行(例如tail:N)。省略则返回完整提取结果。head:200
Execution
执行
Skeleton mode — narrative of user messages, assistant text, and collapsed tool-call summaries:
bash
cat <file> | python3 scripts/extract-skeleton.pyErrors mode — just error signals:
bash
cat <file> | python3 scripts/extract-errors.pyIf is , pipe through . If , pipe through . Apply the limit after the Python script, never before — the line is emitted last and a head cap may drop it; that is acceptable when the caller asks for a head cap.
<limit>head:Nhead -n Ntail:Ntail -n N_metaReturn the raw stdout verbatim. Do not paraphrase, annotate, or synthesize — the caller does synthesis across multiple sessions.
框架模式 — 用户消息、助手文本和折叠后的工具调用摘要的叙述性内容:
bash
cat <file> | python3 scripts/extract-skeleton.py错误模式 — 仅返回错误信号:
bash
cat <file> | python3 scripts/extract-errors.py如果为,则通过管道传递给;如果是,则传递给。限制操作应在Python脚本之后执行,绝不能在之前——行最后输出,头部限制可能会丢弃该行;当调用方要求头部限制时,这种情况是可接受的。
<limit>head:Nhead -n Ntail:Ntail -n N_meta原样返回原始标准输出。不要进行转述、注释或合成——调用方会在多个会话间进行合成操作。
What each mode returns
各模式返回内容
Skeleton
框架模式
Narrative output with one logical event per block, separated by :
---- User messages (text only, no tool results, framework wrapper tags stripped)
- Assistant text (no thinking/reasoning blocks — those are internal or encrypted)
- Tool call summaries; 3+ consecutive same-name calls are collapsed (e.g., )
[tools] 5x Read (file1, file2, +3 more) -> all ok
Ends with a line: .
_meta{"_meta": true, "lines": N, "parse_errors": N, "user": N, "assistant": N, "tool": N}叙述性输出,每个逻辑事件为一个块,用分隔:
---- 用户消息(仅文本,无工具结果,已去除框架包装标签)
- 助手文本(无思考/推理块——这些是内部内容或已加密)
- 工具调用摘要;连续3次及以上同名调用会被折叠(例如)
[tools] 5x Read (file1, file2, +3 more) -> all ok
结尾包含行:。
_meta{"_meta": true, "lines": N, "parse_errors": N, "user": N, "assistant": N, "tool": N}Errors
错误模式
One line per error, separated by :
---- Claude Code: tool results with
is_error: true - Codex: events with non-zero exit or non-empty stderr
exec_command_end - Cursor: always empty — Cursor agent transcripts do not log tool results
Ends with a line: .
_meta{"_meta": true, "lines": N, "parse_errors": N, "errors_found": N}每个错误占一行,用分隔:
---- Claude Code:的工具结果
is_error: true - Codex:事件中退出码非零或stderr非空的情况
exec_command_end - Cursor:始终为空——Cursor Agent的会话记录不记录工具结果
结尾包含行:。
_meta{"_meta": true, "lines": N, "parse_errors": N, "errors_found": N}Error handling
错误处理
If the file cannot be read, let the error surface to the caller. If reports , return the output as-is — partial extraction is still useful and the caller decides whether to widen the search or deep-dive further.
_metaparse_errors > 0如果无法读取文件,让错误直接暴露给调用方。如果报告,则原样返回输出——部分提取结果仍然有用,调用方可决定是否扩大搜索范围或进一步深入研究。
_metaparse_errors > 0