For Claude Code and Codex · free & open source · local only支持 Claude Code 和 Codex · 免费开源 · 只在本地

Compaction forgets.
Afterimage remembers.
压缩会忘,
Afterimage 记得。

When a long conversation compacts, the details vanish into a summary: the exact error, the command, the decision you made an hour ago. Afterimage shows what was dropped, lets you search it, and brings the original turns back, word for word.长对话一压缩,细节就消失在摘要里:完整的报错、那条命令、一小时前定下的决定。Afterimage 让你看到丢了什么、能搜到,还能把原文一字不差地找回来。

Install in a minute一分钟安装 →★ Star on GitHub在 GitHub 上 Star
v0.2 · MIT · No network · No model calls · Reads only不联网 · 不调用模型 · 只读不写
Claude · Code
Set up the database. Postgres 16, not SQLite.配置数据库,用 Postgres 16,不要 SQLite。
Done: schema and a migrations folder.完成:建好了表结构和迁移目录。
Run the migration跑一下迁移
It failed: relation "users" already exists. Fixed the duplicate.失败了:relation "users" already exists,已修复重复的迁移。
Now the login page接着做登录页
⟲ Conversation compacted. Summary: set up a database, ran migrations, started the login page…⟲ 对话已压缩。摘要:配置了数据库,跑了迁移,开始做登录页……
Afterimage: compaction just summarized 5 turns. Their originals are kept; type /afterimage to see or restore them.Afterimage:刚才的压缩总结掉了 5 轮,原文还在。输入 /afterimage 查看和找回。
Restored turn #4 verbatim:已原样找回第 4 轮:
ERROR: relation "users" already exists
/afterimage
Waiting for a compaction…等待压缩发生……
Why为什么

Everyone has lost something to compaction.每个人都被压缩坑过。

These requests are open in the official trackers. Neither app gives a way to see or restore what compaction dropped, yet both keep the original turns on your disk.这些请求在官方仓库里都还开着。两个应用都不能让你看到或找回被压缩掉的内容,可原文其实都还留在你的电脑上。

129 👍
openai/codex #4106

Control over auto-compaction希望能控制自动压缩

93 👍
anthropics/claude-code #27242

No way to review previous context after compaction压缩后没有办法回看之前的内容

92 👍
anthropics/claude-code #17428

Enhanced /compact with selective restoration希望 /compact 能有选择地恢复

Features功能

A way back, built in.给对话加上一条回去的路。

◷

See every compaction看清每次压缩

When it happened, tokens before and after, and a numbered list of the turns it summarized.什么时候发生、压缩前后多少 token,以及被总结掉的每一轮(带编号)。

⌕

Search what was dropped搜索丢掉的内容

Original messages, replies, errors and tool calls, searchable by a few words.原始提问、回复、报错和工具调用,几个关键词就能搜到。

↺

Restore word for word一字不差地找回

Chosen turns come back into the conversation, so the model works from the real text, not the summary.选中的轮次回到当前对话,模型照着原文工作,而不是照着摘要猜。

📌

Pin what must survive钉住必须保留的

Pins go to the compactor as must-keep notes and come back after every compaction.钉住的内容作为"必须保留"交给压缩,每次压缩后还会重新加回来。

!

A heads-up after compacting压缩后主动提醒

You see how many turns were summarized; the model learns it can look them up instead of guessing.你会看到总结掉了几轮;模型也知道可以去查原文,而不是瞎猜。

⇆

Works from a new session新会话也能用

Realized too late? /afterimage in a fresh session shows your most recent compacted conversation.事后才发现?在新会话输入 /afterimage,会显示你最近一次被压缩的会话。

/afterimagesee what was dropped看看丢了什么
/afterimage 12-15restore those turns找回这几轮
/afterimage migration errorsearch搜索
"Pin: never commit .env""钉住:永远不要提交 .env"or just ask in plain words也可以直接用大白话
Install安装

Up and running in a minute.一分钟装好。

Needs Node.js 18 or newer.需要 Node.js 18 或更新版本。

Add the marketplace添加插件市场

In a terminal.在终端里运行。

claude plugin marketplace add LucasYanzy/afterimage

Install安装

For your user, in every project.按用户安装,所有项目通用。

claude plugin install afterimage@afterimage

Open a new session开一个新会话

Then type:然后输入:

/afterimage

Get Afterimage下载 Afterimage

Clone it somewhere you'll keep it.克隆到一个固定位置。

git clone https://github.com/LucasYanzy/afterimage.git

Register it登记插件

From the folder holding the clone.在克隆所在的文件夹运行。

codex plugin marketplace add "$PWD/afterimage"

Install and ask安装并提问

Codex → Plugins → Afterimage → Install, then ask:Codex → Plugins → Afterimage → 安装,然后问:

What did compaction drop?
压缩丢了什么?
FAQ

Questions常见问题

Where does it get the original text?原文从哪来?

From the transcripts your app already writes: ~/.claude/projects for Claude Code, ~/.codex/sessions for Codex. Both keep messages from before a compaction. Afterimage only reads them.来自应用本来就会写的会话记录:Claude Code 在 ~/.claude/projects,Codex 在 ~/.codex/sessions。两者都保留了压缩前的消息,Afterimage 只读取,不修改。

Does it send my conversations anywhere?会把对话发到别处吗?

No. No network requests, no model calls, no API keys. Restored text goes only into the conversation you're in.不会。不联网、不调用模型、不需要密钥。找回的原文只会放进你当前的对话。

I don't see a card, only text.只看到文字,没有卡片?

Cards appear in the Claude desktop app in a session started after installing. Everything also works as plain text: /afterimage lists the dropped turns and /afterimage 3-5 restores them.卡片需要在安装之后新开的 Claude 桌面版会话里才会出现。所有功能也都能用纯文字完成:/afterimage 列出丢掉的轮次,/afterimage 3-5 就能找回。

What if I deleted the session?如果我删了会话呢?

Then its turns are gone. Afterimage can only bring back what the app kept on disk.那部分就没了。Afterimage 只能找回应用留在本地的内容。

Never lose a decision to a summary again.别再让决定消失在摘要里。

Install Afterimage安装 Afterimage →★ GitHub