codex-session-viewer
v1.0.0
Published
View, search, and export Codex AI chat sessions from the CLI
Readme
Codex Session Viewer
codex-session-viewer is a small CLI for reading local Codex session .jsonl files when you want to browse, search, or export chats outside the default UI.
Features
- List local Codex sessions with index numbers
- Open a session and print messages in a readable terminal format
- Export a session to Markdown, text, or JSON
- Search all sessions for a keyword
- Override the default sessions folder with
--path
Requirements
- Node.js 14 or newer
- npm 6 or newer
- Codex installed with at least one recorded session
Install
npm installFor local CLI testing:
npm linkInstall From npm
Once this package is published to npm, people will be able to install it in either of these ways.
Global install:
npm install -g codex-session-viewer
codex-view listProject-local install:
npm install codex-session-viewer
npx codex-view listIf the package name codex-session-viewer is already taken on npm, update the name field in package.json before publishing.
Quick Start
Windows (PowerShell or Command Prompt)
- Open a terminal in this project folder.
- Install dependencies:
npm install- Link the CLI on your machine:
npm link- Try the first commands:
codex-view list
codex-view open 0 --chat-only --compact
codex-view export 0 --format txt- If your sessions are not found automatically, pass the Codex sessions path explicitly:
codex-view --path "$HOME\.codex\sessions" listmacOS/Linux
- Open a terminal in this project folder.
- Install dependencies:
npm install- Link the CLI on your machine:
npm link- Try the first commands:
codex-view list
codex-view open 0 --chat-only --compact
codex-view export 0 --format txt- If your sessions are not found automatically, pass the Codex sessions path explicitly:
codex-view --path "$HOME/.codex/sessions" listWithout npm link
If you do not want to link the command globally, you can run it directly from this repository:
npm start -- listWindows example:
node .\bin\index.js listmacOS/Linux example:
node ./bin/index.js listUsage
By default the CLI reads from ~/.codex/sessions.
codex-view list
codex-view --plain list
codex-view list --recent 10
codex-view list --json
codex-view open 0
codex-view open 0 --compact
codex-view open 0 --chat-only
codex-view open 0 --chat-only --compact
codex-view open 0 --json
codex-view export 0
codex-view export 0 --chat-only
codex-view export 0 --format txt
codex-view export 0 --format json
codex-view export 0 --output exports/session-0.md
codex-view export 0 --output exports/session-0.md --force
codex-view search "keyword"
codex-view search "keyword" --recent 20
codex-view search "keyword" --chat-only
codex-view search "keyword" --json
codex-view search "keyword" --exact
codex-view search "Keyword" --case-sensitiveUse a custom sessions path:
codex-view --path /custom/path/to/sessions listYou can also run the CLI without linking:
npm start -- listProject Structure
bin/index.js
src/commands/list.js
src/commands/open.js
src/commands/export.js
src/commands/search.js
src/utils/fileReader.js
src/utils/parser.js
src/utils/formatter.js
src/constants/paths.jsNotes
- Invalid JSON lines are skipped with a warning
- Empty or missing session folders produce friendly errors
- Exported files are written to the current working directory by default
- Use
codex-view open <index> --compactfor a fast scan view - Use
codex-view open <index> --chat-onlyto keep just the main user prompts and final assistant replies - Use
codex-view open <index> --jsonfor full session extraction in scripts - Use
codex-view --plain ...orNO_COLOR=1for logs, CI, or simple terminals - Use
codex-view list --recent <n>to focus on the newest sessions first - Use
codex-view list --jsonfor automation and scripting - Use
codex-view search "keyword" --recent <n>to narrow search to recent sessions - Use
codex-view search "keyword" --chat-onlyto ignore commentary noise - Use
codex-view search "keyword" --jsonfor machine-readable search results - Use
codex-view search "keyword" --exactto require an exact full-message match - Use
codex-view search "Keyword" --case-sensitiveto preserve case in matching - Use
codex-view export <index> --chat-onlyfor a cleaner transcript - Use
codex-view export <index> --format txtfor a plain text transcript - Use
codex-view export <index> --format jsonfor machine-readable export data - Use
codex-view export <index> --output <file>to control where the export file goes - Use
--forcewithexportonly when you want to overwrite an existing file
Development
Run the local test suite:
npm testThis repository also includes a GitHub Actions workflow at .github/workflows/ci.yml that runs the tests on pushes and pull requests.
Publish To npm
- Make sure you are logged in to npm:
npm login- Verify exactly what will be published:
npm pack --dry-run- Publish the package publicly:
npm publishAfter publishing, anyone should be able to install it with:
npm install -g codex-session-viewer