Skip to content

WaryaWayne/codex-relink

Repository files navigation

codex-relink

codex-relink CLI hero image

codex-relink is a small read-only helper for finding missing or hard-to-locate Codex CLI chats that match the current working directory and printing the command needed to resume them.

Use it when a Codex chat looks lost, missing from the picker, or disconnected from the project you were working in, but the local Codex storage still has enough data to find the thread id.

This is especially for chats that do not appear in the Codex CLI resume picker or the Codex Desktop sidebar. Run codex-relink latest or codex-relink list from the project directory, and it searches local Codex storage directly so you can resume chats that are still in the database.

It reads local Codex storage:

  • ~/.codex/state_5.sqlite
  • ~/.codex/sessions/**/*.jsonl

It does not edit Codex SQLite, global state, session_index.jsonl, titles, previews, cwd values, or user data.

Install

Install it globally from npm if you want the codex-relink command available everywhere:

npm install --global codex-relink

Then run it from the project directory whose Codex chats you want to find:

codex-relink latest
codex-relink list

You can also run it without installing anything globally:

npx codex-relink latest
npx codex-relink list

Or with Bun:

bunx codex-relink latest
bunx codex-relink list

All three forms use the current working directory as the project to match against local Codex storage.

Build

pnpm install
pnpm build

Latest Chat

From any project directory:

codex-relink latest

Or from this checkout without installing:

node dist/cli.js latest

The command finds Codex chats matching process.cwd(), selects the newest chat by updated_at_ms, updated_at, created_at_ms, then created_at, and prints:

  Copy the command below to resume your chat:

  codex resume <thread-id>

If there are no matching chats, it prints a short message for the current directory.

Pick A Chat

From any project directory:

codex-relink list

Or from this checkout without installing:

node dist/cli.js list

list shows an interactive picker, newest first. Rows are numbered so 1 is always the latest matching chat, and the picker stops at the oldest chat instead of wrapping around. Each row includes the number, updated time, short thread id, and title or fallback. Press enter to select the highlighted chat. After selection, the accepted prompt line shows Chosen ID: <short-id> before it prints:

  Copy the command below to resume your chat:

  codex resume <thread-id>

Options

Show CLI help:

codex-relink -h
codex-relink --help

Use --codex-home when testing against another Codex home directory:

codex-relink --codex-home /tmp/codex-home latest

Normal use does not require --project; the current working directory is used automatically.

Author

Built by Warya Wayne, @waryawayne.

About

Find Codex chats for the current directory and print resume commands.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors