npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

codex-ai-replies-cli

v0.11.0

Published

CLI for reading local Codex session rollouts and extracting assistant replies, tool calls, and MCP activity

Readme

English

codex-ai-replies-cli

中文简介:从 Codex 会话记录中提取助手、工具和 MCP 事件的 CLI

English summary: A CLI for extracting assistant, tool, and MCP events from Codex session rollouts


用于读取本机 Codex 会话 rollout 的命令行工具。默认扫描 ~/.codex/sessions 中最近更新的主会话,将 JSONL 历史转换为可读输出,便于查看助手回复、工具调用序列和 MCP 活动,无需手动翻找原始会话文件。

当前版本

当前版本:0.11.0

本版本统一了 -l 与 -wN 的主会话排名,监控模式支持关闭剪贴板和输出 NDJSON,并忽略 Codex 注入的 AGENTS.md instructions 上下文消息。

安装

npm install -g codex-ai-replies-cli

安装后推荐使用短命令:

cxr

也可在仓库中直接运行:

node bin/codex-ai-replies.js --help

常用命令

# 读取最近主会话的助手回复
cxr

# 跟随同一会话的新事件
cxr --watch

# 跟随列表第 2 项;-wN 与 --list-sessions 使用同一排名
cxr -w2

# 跟随时不复制初始输出,并按行输出 JSON 事件
cxr --watch --no-clipboard --all-events --ndjson

# 读取最近第 2、3 或第 N 个主会话
cxr --watch2
cxr --watch3
cxr --watch 4

# 列出最近的主会话,再按会话 ID 读取
cxr --list-sessions
cxr --id <session-id>

# 显示助手、工具和 MCP 混合时间线
cxr --include-tools --include-mcp

# 只读取 MCP 活动
cxr --include-mcp

# 导出内容并打开结果文件
cxr --count 20 --save --output ./messages.txt

默认输出助手回复;包含工具、MCP 或 RequestUserInput 的选项会进入事件选择模式。文本模式时间戳使用本机时区;需要保留原始时间戳或处理结构化数据时使用 --json。

会话与子代理

未指定选择器时,工具从 ~/.codex/sessions 选择最近更新的主会话并排除子代理。可使用 --id 选择特定会话,使用 --raw-file 读取一个 rollout JSONL 文件。

# 列出所选主会话的子代理
cxr --id <session-id> --agents

# 读取或跟随一条子代理会话
cxr --id <session-id> --agent2
cxr --id <session-id> --agent /root/example --watch

--agents2 选择按更新时间排名第二的主会话;--agent2 选择子代理列表中的第二项。工具按 agent_path 选择子代理,避免依赖可能和父会话相同的 session id。

输出选项

| 选项 | 用途 | | --- | --- | | --list-sessions | 列出最近更新的主会话 | | --count | 限制提取条数或会话列表条数 | | --watch [n] / --watchN | 先输出,再跟随第 N 个最近主会话 | | --no-clipboard | 监控时不复制初始输出 | | --agents [n] / --agentsN | 列出某个主会话的子代理 | | --agent <n|agentPath> / --agentN | 读取一个子代理 | | --save / --open | 写入并打开文本输出 | | --output | 指定输出路径 | | --raw-file | 直接读取 rollout JSONL | | --id | 指定会话 | | --json | 输出 JSON | | --ndjson | 每行输出一个 JSON 值,并自动启用 --json | | --include-tools / --include-mcp | 包含工具或 MCP 事件 | | --include-user-input | 包含 RequestUserInput 事件 | | --timeline | 按时间顺序渲染选中的事件 | | --only | 只选择 assistant、tools、mcp 或 user-input | | --all-events | 输出全部原始 rollout 事件 | | --mcp-server / --mcp-tool | 按 MCP 服务或工具筛选 | | --compact-arguments | 将 MCP 参数渲染为单行 JSON | | --sessions-root | 覆盖默认会话目录 |

可靠性与发布

  • 损坏的 rollout JSONL 会明确报告文件和行号。
  • 助手回复优先读取 event_msg.agent_message,必要时回退到 assistant response_item 文本。
  • --count 在事件类别筛选后应用。
  • --watch 只跟随启动时选中的同一 rollout,不会自动切换到更新的会话。
  • -wN 与 --list-sessions 使用相同的更新时间排序和主会话过滤结果。
  • 会话列表会忽略 Codex 注入的 AGENTS.md instructions 消息,不将其作为首条用户请求。

发布前运行:

npm test
npm run test:release
npm run release:final

npm run release:final 会检查工作区、重新运行测试门禁,并打印后续 push、tag 和 publish 命令,但不会自动执行它们。