全部技能 / 基础工具与工作流 / read-codex-history
基础工具与工作流 · daymade/claude-code-skills

read-codex-history

Reads, searches, and exports local OpenAI Codex history without continuing the old task. Lists recent Codex sessions, extracts exact prompt-ledger inputs by Session, locates a rollout by verified session_meta identity, reconstructs one chronological user/assistant timeline with fork and compaction lineage, and performs bounded keyword search across live and archived rollouts. Use whenever the user asks what they told Codex, wants recent original inputs, a Codex Session ID, full prior context, fork ancestry, or evidence of what a Codex run did. For Claude Code history use read-claude-code-history.

风险提醒:蓝色 · 知晓即可AI 侦查报告
作者 daymadeGitHub daymade/claude-code-skills ↗Stars 1385许可 MIT(仓库根 LICENSE;GitHub API spdx MIT)commit d5c4678cb5
agent 宿主通常会约束 skill 执行权限;风险提醒为 AI 侦查观点,不构成质量或安全保证。第三方 skill 仅作拆解与展示,安装使用风险自负,版权归原作者。

1实现原理 · 为什么它能做到

读的是 Codex 三种互不替代的历史面:history.jsonl(prompt ledger,用户提交原文)、state_*.sqlite(清单元数据)、sessions|archived_sessions 下的 rollout-*.jsonl(完整事件流);每类查询路由到专用脚本,禁止 ad-hoc 重造 join。

daymade-claude-code/read-codex-history/SKILL.md
| `<codex-home>/history.jsonl` | What the user submitted, keyed by Session ID and internal epoch timestamp | Exact recent user-input tables |
注:SKILL 声明 'Do not substitute one surface for another. A prompt-ledger row proves what was submitted, not what the Agent answered. A state DB path is only a candidate until the rollout's session_meta.id matches.'——这是该 skill 正确性模型的核心。

身份与血统门禁(Identity and lineage gate):每条行为结论前必须 (1) 核对 prompt-ledger Session ID、(2) 按内部 session_meta.id 而非文件名定位 rollout、(3) 解析后要求 session_meta.id == 请求 ID、(4) fork 边要声明的父 ID + 精确 history_base.end_byte_offset,拒绝缺失/歧义/循环/不匹配的祖先。

daymade-claude-code/read-codex-history/SKILL.md
Locate rollout candidates by their internal `session_meta.id`, not filename alone.
注:SKILL 明说这是针对两个真实事故的修正:'a prompt-ledger Session whose state DB pointed at another rollout, and a /fork input with no child rollout'。

sqlite 读取被强制只读:_core/codex.py 用 file: URI ?mode=ro 连接并 PRAGMA query_only=ON,schema 不兼容时降级为原生 rollout JSONL 扫描。

daymade-claude-code/read-codex-history/scripts/_core/codex.py
return "file:" + quote(path.resolve().as_posix(), safe="/:@") + "?mode=ro"
注:同一文件 inspect_codex_database/collect_codex_from_database 均 connection.execute("PRAGMA query_only = ON")——把『读工具不得写库』落到 sqlite 层。

writer-lock 观测为 positive-only:非阻塞读取 .coordination.lock 协调文件,持锁只证明快照时有进程占用 Codex 规范线程锁,不识别进程也不证明活性。

daymade-claude-code/read-codex-history/scripts/list_local_history.py
A held lock proves only that some process owns the advisory lock; it does not
注:list_local_history.py 251-283 区域先非阻塞取协调锁再看 admitted thread locks,避免与正在写入的 Codex 竞争;输出语义显式声明 'absence is not proof of inactivity'。

输入对账(reconcile_codex_inputs.py):用既有 ledger + 严格 lineage reader 组合出整会话原始输入计数与引文,保留 occurrence/原文/来源坐标;exit 2 或 complete:false 视为不完整,scope_input_count: null ≠ 0。

daymade-claude-code/read-codex-history/SKILL.md
Use the reconciler to compose the existing ledger and strict lineage readers. It preserves occurrences, original strings, and source coordinates.
注:SKILL 还约束 'Treat exit 2 or complete: false as an incomplete result',禁止把未核对记录当成完整总数。

超大 briefing 的上下文纪律:完整简报超模型上下文时先物化一次到私有临时文件并记录 SHA-256+行数,按标题/坐标读有界区间,未读区间一律报为 gap,禁止分片重跑拼出『完整』假象。

daymade-claude-code/read-codex-history/SKILL.md
materialize it once to a private temporary file and record its SHA-256 plus line count before reading
注:read_codex_session.py --full 输出可能达多 MB;这条是给 agent 的『一条 briefing 可以分多次读,但不能伪造完整性』的读法纪律。

2核心能力

01跨 live/archive rollout 的最近 Codex 会话清单(含 writer-lock 阳性证据、来源标签)
02prompt-ledger 逐字用户输入导出:全局窗口或按 Session 展开、JSON 保真存储串
03整会话原始输入对账(含继承历史计数与引文、hash-bound 排除复核)
04按内部身份定位精确 rollout(秒级,避免全语料扫描)
05单会话时间线重建:fork 血统、父字节边界、compaction、plan、工具调用、end reason
06有界全事件检索(--codex-only 限定 Codex 面,预算超时显式失败不装完整)

3外部依赖

类型依赖
cligit(工作区状态上下文,read_codex_session 中 subprocess)
clirg/grep(text.py 可选路径预过滤,与 claude 版共享 core)

4风险提醒 风险提醒:蓝色 · 知晓即可

风险提醒:蓝色 · 知晓即可
  • 数据面=Codex 全量历史(可能含凭据粘贴与私密上下文) — 无凭证主动读取,但 ledger/rollout 内容本身敏感;SKILL 用『不 share、只读、gap 诚实』约束,均非技术强制。
  • compaction/fork 记录的误导风险 — 压缩摘要与继承历史若被当逐字事实会错;依赖 agent 遵守身份/血统门禁流程。
  • 大 briefing 临时文件残留 — 物化 temp 后若 agent 未清理会留含摘要文件;路径为私有 temp 但依赖 agent 行为。
风险提醒:蓝色,知晓即可。只读本地 Codex 历史(history.jsonl / state_*.sqlite 以 mode=ro + PRAGMA query_only 打开 / rollout JSONL),无网络外发、无凭证读取、无常规文件写入;唯一本地执行是 git 与 rg/grep subprocess 及 agent 按指令物化的私有临时简报文件。数据敏感但设计自防御(身份门禁、显式 gap、不外传约束)。

5第二遍独立确认

  • [ok] sqlite 只读强制 — _core/codex.py: sqlite_uri 加 ?mode=ro;inspect/collect 均 PRAGMA query_only=ON。
  • [ok] 无任何网络外发 — 全 scripts 目录扫描无 requests/urllib/socket/curl/wget;本 skill 不含 history_index 类下载器。
  • [ok] 凭证读取检查 — 全目录无 auth.json/API key/.env/密钥 env 访问;只读 rollout 与 ledger。
  • [ok] SKILL 声明的 flag 与脚本存在性 — reconcile --through-record/--omit-first/--omit-last、list_codex_user_inputs --recent/--session-id/--per-session、analyze_sessions search --codex-only、read_codex_session --full 均核对到 argparse。
  • [unlocatable] rollout 格式跨版本声明(0.142.2–0.149.0) — codex_rollout_format.md 自述 'Verified against ~2,600 real rollouts';源码内无法复核该实测声明,未运行 Codex 验证。
  • [ok] writer-lock 观测语义 — list_local_history.py 251-283 非阻塞取协调锁 + 输出 positive-only 语义字符串,与 SKILL 描述一致。

6结论

  • 三表面分层 + 身份门禁:杜绝『state DB 指错 rollout / fork 无子 rollout』两类真实事故
  • 读库被 sqlite 层强制只读(mode=ro + query_only),比纯靠文档承诺更硬
  • prompt-ledger 与 rollout 双源对账保留 occurrence/原文/坐标,输入计数不冒充批评条数
  • 上下文预算纪律落地:超限 briefing 物化一次+SHA 记账+gap 报告,防分片拼凑
  • 适合:适合需要『Codex 会话证据』的场景:找回用户原始输入与 Session ID、fork 血统审计、压缩前后对照、上线前行为审计;适合与 continue-codex-work 配对做只读取证→执行接力,以及本地历史隐私敏感、要求零外发的用户。
    不适合:不适合需要继续/恢复 Codex 会话或改动其项目的人(那是 continue-codex-work);无本地 Codex rollout 的环境无用武之地;需要语义级模糊召回(措辞变了)的场景应找带索引的配套技能——本 skill 只有精确检索,不做混合召回。
    安装 agent 直装可复制
    ① 本站镜像 更新 2026-09-09
    方式 A · 人下载镜像包下载 read-codex-history.tar.gz
    sha256: c30dd57b4165452f…
    方式 B · JSON 格式安装指南,复制给 agent
    安装指南
    agent 读 JSON 指南后会自动从本站下载安装,无需更多说明。
    ② 上游 GitHub · 原始来源
    能访问 GitHub?直接去上游安装(实时版,可能已更新)GitHub 原始 ↗
    本页镜像锁定 commit d5c4678cb5;上游为实时仓库。
    来源信息 GitHub 原始
    作者 / 仓库daymade / daymade/claude-code-skills
    Stars1385
    最近推送2026-09-09
    本 skill commitd5c4678cb5
    许可MIT(仓库根 LICENSE;GitHub API spdx MIT)
    本站信息
    收录日期2026-09-06
    分类基础工具与工作流
    侦查报告AI 侦查 · 2 遍 · 2026-09-06
    本站镜像与 GitHub 原始是不同来源:本站锁定 commit 快照经 /r2 分发;GitHub 为实时上游,内容可能已更新。
    同分类邻近