A local plugin for image-heavy chats in Codex, Claude Code and other agents: earlier images stop going out with every message, and the model fetches the one it needs by its ID, also after compaction.
TypeScript ai-agentsclaude-codeclaude-code-plugincodexcodex-plugincontext-managementdeveloper-toolsimage-generationmcpmultimodal
docs(v0.6): 规格、技术方案、README、CHANGELOG 写进默认开启自动选图和自动打开面板
chipfighter75b4faaf0eb2
diff --git a/AGENTS.md b/AGENTS.mdindex 6372c34..3818b96 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -8,6 +8,7 @@ Context Attachment Manager(上下文素材管理器,2026-10-11 前叫 Codex- [docs/design.md](docs/design.md):技术方案,讲现在是怎么实现的。- [docs/v0.4/plan.md](docs/v0.4/plan.md):Claude 桌面 Code 接入的 v0.4 变更方案;任务和验收分别见同目录的 `tasks.md`、`acceptance.md`。当前正式规格仍以 `docs/spec.md` 为准,未通过的迁移关卡不算已实现。- [docs/v0.5/plan.md](docs/v0.5/plan.md):v0.5 方案,Claude Code 压缩后保留图片(已发布 0.5.0)。+- [docs/v0.6/plan.md](docs/v0.6/plan.md):v0.6 方案,默认开启自动选图、Claude 桌面版自动打开面板(开发中)。- [docs/history/v0.1/](docs/history/v0.1/):v0.1 的开发记录(原方案、任务记录、各阶段报告、最初的构想),只作参考,不作依据。- [CHANGELOG.md](CHANGELOG.md):每个版本的更新记录,发布时就是 Release 说明。diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5a8cce8..efa62c0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,22 @@When a version is released, its section here becomes the GitHub release notes.+## [0.6.0] - Unreleased++Auto-select on by default, and the panel opens by itself in Claude Desktop.++### Features++- New tasks in Codex and new sessions in Claude Code start with Auto-select on: images from earlier turns are left out, and the model fetches the ones it needs by ID, so long conversations stay small even if you never open the panel. Tasks and sessions you had before keep their setting, and switching Auto-select off in the panel sticks.+- In Claude Desktop the panel opens by itself in the built-in browser once a session has images: when the model read an image, as that turn ends; when you paste one, as your message goes out. You no longer need to type `/cam`.+- Claude Desktop closes a session's built-in browser after about 30 minutes without a turn; the panel then opens again with your next message. If you close it yourself, it stays closed in that session until you type `/cam`, which also leaves just one panel tab.+- In Codex, tasks you had before work as in 0.5.0.++### Notes++- With Auto-select on, the model can fetch several images at once. Asked about two images it had not described, GPT-6 Sol, Luna and Astra in Codex and Claude Haiku 5.5 in Claude Desktop each fetched both in one call. GPT-6 Luna then misread a small digit in one of them, as in 0.3; pin images whose details matter, or use a larger model.+- The plugin tells your close from Claude Desktop's by time: a panel gone within 30 minutes of the session's last turn was closed by you. If you close it more than 25 minutes into a pause, it may open again with your next message.+## [0.5.0] - 2026-10-13Your choice survives compaction in Claude Code.diff --git a/README.md b/README.mdindex 61f1b32..4113cb6 100644--- a/README.md+++ b/README.md@@ -17,7 +17,7 @@<p align="center"><b>English</b> · <a href="README_CN.md">简体中文</a></p>-> **New in 0.5: your choice survives compaction in Claude Code.** When Claude Code compacts a conversation, it stops sending the images from before; the plugin keeps sending the ones you checked, right after the summary. **Since 0.4** it works in Claude Desktop: in the Code tab, install the plugin and type `/cam` in a session, and the same panel opens in the built-in browser, next to the conversation. Formerly *Codex Attachment Manager*; the project was renamed because it no longer works with Codex alone.+> **New in 0.6: Auto-select is on by default, and in Claude Desktop the panel opens by itself.** New tasks and sessions start with Auto-select on, so images from earlier turns stay out unless the model needs them, even if you never open the panel; tasks and sessions you already have keep their setting. In Claude Desktop the panel opens next to the conversation once a session has images. **Earlier:** since 0.5 your selection survives compaction in Claude Code, and since 0.4 it works in Claude Desktop. Formerly *Codex Attachment Manager*; the project was renamed because it no longer works with Codex alone.<p align="center"><img src="docs/images/demo.gif" alt="The panel's filter shows only the PDF page, then every image again, and the uploads are unchecked a turn at a time. Asked about the chat button in the v1 desktop mockup, the model replies need IMG-001; the panel points to IMG-001, the user checks it, and the model answers from the image: orange." width="100%">@@ -37,7 +37,7 @@ So I wanted to keep the long conversation going and decide, turn by turn, which- **Duplicates handled**: when an identical image is still being sent, the placeholder points to it.- **The model knows why**: a note tells the model the images were left out by you to save context, so its earlier answers still stand and it doesn't make up details it can't see.- **The model asks, you decide**: when it needs an image, it replies `need IMG-xxx`. The panel lists what it asked for and jumps to it in one click. A checked image goes back to its place in the conversation, marked with its ID.-- **Or let the model pick** (new in 0.3): switch on *Auto-select* at the bottom of the panel, per task or session. Images from earlier turns are then left out by default, and the model fetches the ones it needs by ID, for that turn only. Images you check are pinned and go every turn. The panel shows what the model fetched in the latest turn.+- **Or let the model pick** (new in 0.3, on by default since 0.6): *Auto-select* at the bottom of the panel, per task or session. Images from earlier turns are then left out by default, and the model fetches the ones it needs by ID, for that turn only, several at once if it needs several. Images you check are pinned and go every turn. New tasks and sessions start with it on; switch it off to choose yourself. The panel shows what the model fetched in the latest turn.- **Keeps your choice through compaction** (new in 0.5, Claude Code): when Claude Code compacts a conversation, it stops sending the images from before it. The plugin keeps sending the ones you checked, right after the summary and marked with their IDs, and tells the model about the others, so it can still ask for them or fetch them. The panel marks these images *Before compaction*.- **See the savings**: the panel estimates the size of the next request and how much you save compared with sending every image, and warns you when a request could not be rewritten.- **English and Simplified Chinese**: the panel, the tab name and the note for the model follow Codex's language, or your system's language when Codex isn't installed.@@ -110,15 +110,15 @@ Then start a new session in the Code tab. There is nothing to set up: the plugin### In Codex1. Open **Context Assets** in the side panel of a task. On a new chat you can open it before the first message; it switches to the task once you send.-2. Uncheck the images you don't want to send anymore. Each change is saved at once and applies from the next message.-3. When the model replies `need IMG-xxx` for an unchecked image, a bar at the top of the panel lists it. Click the ID to jump to the image and check it.+2. New tasks start with **Auto-select** on (at the bottom of the panel): images from earlier turns are left out, and the model fetches the ones it needs. Check the images that should go every turn, such as a reference image. Each change is saved at once and applies from the next message.+3. To choose yourself, switch Auto-select off: every image then goes unless you uncheck it. When the model replies `need IMG-xxx` for an unchecked image, a bar at the top of the panel lists it; click the ID to jump to the image and check it. Switching Auto-select on again brings your pins back, and off again your own checks.4. With many images, click the filter button next to refresh and pick the sources to show. A turn's checkbox then covers only the images shown.-5. To let the model pick, switch on **Auto-select** at the bottom of the panel. Check the images that should go every turn, such as a reference image; the model fetches the others when it needs them. Switch it off to get your own checks back.+5. Tasks you had before installing 0.6 keep their setting.### In Claude Desktop-1. In a session in the Code tab, type `/cam` and send it. The panel opens in Claude Desktop's built-in browser, next to the conversation. If `/cam` is your first message in a new session, the prompt box may say the command doesn't exist: send it anyway. Claude Desktop starts the session when you send your first message, and the plugin adds `/cam` then.-2. From there it works as in Codex: uncheck, check again, answer `need IMG-xxx`, filter, or switch on **Auto-select**. Changes apply from the next message.+1. Once a session in the Code tab has images, the panel opens by itself in Claude Desktop's built-in browser, next to the conversation. Claude Desktop closes a session's built-in browser after about 30 minutes without a message; the panel opens again with your next one. If you close it yourself, it stays closed in that session until you type `/cam` and send it, which opens it any time. If `/cam` is your first message in a new session, the prompt box may say the command doesn't exist: send it anyway. Claude Desktop starts the session when you send your first message, and the plugin adds `/cam` then.+2. From there it works as in Codex: new sessions start with **Auto-select** on; pin, filter, or switch it off to uncheck images yourself and answer `need IMG-xxx`. Changes apply from the next message.3. With Auto-select on, the model's `cam_view_image` calls don't ask for your permission, unless your own Claude Code settings or hooks say otherwise.If the built-in browser can't be used (in the terminal, for example), `/cam` shows a small pane with a link to the panel instead.diff --git a/README_CN.md b/README_CN.mdindex 30896fd..e44d9d3 100644--- a/README_CN.md+++ b/README_CN.md@@ -17,7 +17,7 @@<p align="center"><a href="README.md">English</a> · <b>简体中文</b></p>-> **0.5 新增:Claude Code 压缩对话后,勾选照样有效。** Claude Code 压缩对话后不再发送之前的图;插件把你勾着的那些接着发出去,就放在摘要后面。**0.4 起**Claude 桌面版也能用:在 Code 标签页装上插件,在会话里输入 `/cam`,同一个面板就在自带的浏览器里打开,就在对话旁边。项目原名 *Codex Attachment Manager*,因为不再只给 Codex 用,改了名。+> **0.6 新增:默认开启自动选图;Claude 桌面版里面板自己打开。** 新任务和新会话一开始就开着自动选图,之前各轮的图只在模型需要时才发,不打开面板也一样;你已有的任务和会话保持原来的设置。Claude 桌面版里,会话有了图,面板就在对话旁边自己打开。**之前的版本:** 0.5 起 Claude Code 压缩对话后勾选照样有效,0.4 起 Claude 桌面版也能用。项目原名 *Codex Attachment Manager*,因为不再只给 Codex 用,改了名。<p align="center"><img src="docs/images/demo.gif" alt="面板的筛选先只显示 PDF 页面,再恢复显示全部,上传的图按整轮取消勾选。问起 v1 桌面版的聊天按钮,模型回复 need IMG-001;面板指出 IMG-001,用户勾上它,模型看图答出橙色。" width="100%">@@ -37,7 +37,7 @@- **重复的图自动处理**:有内容相同的图还在发送时,占位文字指向那一张。- **模型知道原因**:一段说明告诉模型,这些图是你为了节省上下文省略的。它之前看着原图给出的回答仍然算数,也不会编造看不到的细节。- **模型要图,你来决定**:模型需要某张图时,会回复“需要 IMG-xxx”。面板列出它要的图,点一下就跳过去。重新勾上的图回到对话里原来的位置,并标着编号。-- **也可以交给模型选**(0.3 新增):在面板底栏打开“自动选图”,每个任务或会话各开各的。之前各轮的图默认不发,模型需要哪张,就按编号取回,只在那一轮提供;勾上的图固定发送,每轮都发。面板会标出模型最近一轮取回了哪几张。+- **也可以交给模型选**(0.3 新增,0.6 起默认开启):面板底栏的“自动选图”,每个任务或会话各开各的。之前各轮的图默认不发,模型需要哪张,就按编号取回,只在那一轮提供,要几张就一次取几张;勾上的图固定发送,每轮都发。新任务和新会话一开始就开着,想自己选就关掉。面板会标出模型最近一轮取回了哪几张。- **压缩对话后勾选照样有效**(0.5 新增,Claude Code):Claude Code 压缩对话后,不再发送之前的图。插件把你勾着的那些接着发出去,放在摘要后面、标着编号,并告诉模型还有哪些没发,它照样可以要图或取图。面板里这些图标着“压缩前”。- **看得见省了多少**:面板预估下一条请求的大小,以及比全部发送省了多少;请求没能改写时会提示。- **中英文界面**:面板、标签页名字和给模型的说明,都跟随 Codex 的界面语言(简体中文、英文);没装 Codex 时跟随系统语言。@@ -110,15 +110,15 @@ claude plugin install codex-attachment-manager@codex-attachment-manager### 在 Codex 里1. 在任务的侧边面板里打开**上下文素材**。新任务也可以在发第一条消息之前打开:发出消息后,面板会自动切到这个任务。-2. 取消勾选不想再发送的图。每次改动立刻保存,从下一条消息起生效。-3. 模型回复“需要 IMG-xxx”、而那张图没有勾上时,面板顶部会列出它。点编号跳到那张图,勾上即可。+2. 新任务一开始就开着**自动选图**(在面板底栏):之前各轮的图默认不发,模型需要时自己取回。勾上每轮都要发的图,比如一直要对照的参考图。每次改动立刻保存,从下一条消息起生效。+3. 想自己选,就关掉自动选图:所有图照常发送,取消勾选的才不发。模型回复“需要 IMG-xxx”、而那张图没有勾上时,面板顶部会列出它;点编号跳到那张图,勾上即可。再打开自动选图,固定发送的勾选原样回来;再关掉,你自己的勾选也原样回来。4. 图多的时候,点刷新旁边的筛选按钮,选要看的来源。这时整轮勾选只管显示出来的图。-5. 想交给模型选,就打开面板底栏的**自动选图**。勾上每轮都要发的图,比如一直要对照的参考图;其余的由模型需要时自己取回。关掉开关,你原来的勾选原样回来。+5. 装 0.6 之前就有的任务,保持原来的设置。### 在 Claude 桌面版里-1. 在 Code 标签页的会话里输入 `/cam` 并发送,面板就在 Claude 桌面版自带的浏览器里打开,就在对话旁边。如果 `/cam` 是新会话的第一条消息,输入框可能提示命令不存在:照样发出去就行。Claude 桌面版在你发出第一条消息时才启动会话,插件这时才加上 `/cam`。-2. 之后的用法和 Codex 一样:取消勾选、重新勾上、按“需要 IMG-xxx”找图、筛选,或者打开**自动选图**。改动从下一条消息起生效。+1. Code 标签页的会话里有了图,面板就自己在 Claude 桌面版自带的浏览器里打开,就在对话旁边。Claude 桌面版在会话约 30 分钟没有新消息后,会关掉它的自带浏览器;你再发消息时,面板会重新打开。你自己关掉的,这个会话里不再自动打开,直到你输入 `/cam` 并发送(随时都可以用它打开)。如果 `/cam` 是新会话的第一条消息,输入框可能提示命令不存在:照样发出去就行。Claude 桌面版在你发出第一条消息时才启动会话,插件这时才加上 `/cam`。+2. 之后的用法和 Codex 一样:新会话一开始就开着**自动选图**;可以固定发送、筛选,或者关掉自动选图,自己取消勾选、按“需要 IMG-xxx”找图。改动从下一条消息起生效。3. 开着自动选图时,模型调用 `cam_view_image` 不会弹权限确认;你自己的 Claude Code 设置或钩子另有规定时,照它们的来。用不了自带浏览器时(比如在终端里),`/cam` 会弹出一个小面板,给出面板的链接。diff --git a/docs/design.md b/docs/design.mdindex a9ab200..fa74712 100644--- a/docs/design.md+++ b/docs/design.md@@ -25,7 +25,7 @@| 改写 | `rewrite.ts`、`selection.ts`、`request-stats.ts` | 占位符、说明和标签;勾选状态;请求统计 || 接入和安装 | `codexconfig.ts`、`setup.ts`、`install.ts`、`codexcli.ts`、`cam.ts` | 管理 Codex 配置里带标记的块;用 Codex 的命令行装卸插件;`cam` 命令行 || 其他 | `language.ts`、`messages.ts`、`paths.ts`、`migrate-data.ts`、`binding.ts`、`entry.ts` | 语言、文字表、数据目录、旧数据迁移、新任务绑定 |-| Claude 接入(v0.4) | `hooks/register.js`(Mod,不在 `plugin/src`) | 把会话的请求地址指向引擎;`/cam` 打开面板;取图工具免确认 |+| Claude 接入(v0.4) | `hooks/register.js`(Mod,不在 `plugin/src`) | 把会话的请求地址指向引擎;`/cam` 打开面板(v0.6 起有图时自动打开);取图工具免确认 || Claude 会话索引和改写(v0.4) | `claude-index.ts`、`claude-rewrite.ts` | 从 Claude Code 的会话记录找图、编号;改写 Anthropic Messages 请求 || Claude 思考记录(v0.4) | `claude-thinking.ts` | 账号校验思考记录时,去掉和实际发出的历史对不上的思考 || 面板页(v0.4) | `panel-web.js` | 引擎把 `panel.html` 作为网页提供时,代替 MCP 应用的宿主 |@@ -88,6 +88,7 @@- “重复”占位符只指向之前各轮仍在发送的图,也就是固定发送的;“已提供”标签也只加在这些图前面。这一轮的新图和取回的副本都不算:它们是这一轮中途才出现的,算进去的话,前面的占位符会在取图前后变样,缓存就断了。这样取图前后,这一轮前面的历史逐字节不变(有单元测试)。- 副本只在取回的那一轮发送;之后换成一句说明(“IMG-xxx 的原图:模型当时用 cam_view_image 取回,只在那一轮提供,现在已省略”)。关掉自动以后也这样,因为面板不单列副本,用户没法取消它。- 关着时,传给改写的参数和 v0.2 一样,输出逐字节相同:对照 v0.2 的改写代码,所有勾选组合(中英文、像素相同与否)都比过。+ - v0.6 起新任务默认开着(`selection.ts`):引擎和插件服务启动时,在勾选目录里写下这个版本第一次运行的时间(`auto-default.json`,只写一次,Codex 和 Claude 各一份)。任务没有自己的开关时,开始时间(会话记录第一条 `session_meta` 的时间,分叉的按来源任务算,`threadStartedAt`)不早于它,就当作开着,从开始时算起;还没有会话记录的算新的。默认值不写进勾选文件,面板里一改就写下来。读勾选的地方都经过它:改写、是否需要改写(所以新任务从一开始就走 HTTP)、面板、取图工具。- **切到 HTTP**:WebSocket 连接上 Codex 只发新增的条目,靠 `previous_response_id` 接上服务端保存的历史,已经发过的图去不掉。所以:- 任务一需要改写(有取消项,或者用过自动选图),引擎就对它的 WebSocket 握手回 426,Codex 在这个会话里改走 HTTP,每次都发完整历史;- 它已有的 WebSocket 连接,空闲 1.5 秒后由引擎关掉;@@ -157,7 +158,7 @@- Windows 是 `%USERPROFILE%\.codex-attachment-manager`,macOS 是 `~/Library/Application Support/codex-attachment-manager`,Linux 按 XDG 是 `~/.local/share/codex-attachment-manager`;`CAM_DATA_DIR` 可以改(测试、开发用)。- Windows 上不放在 AppData 下:Codex 是微软商店应用,它启动的程序在 AppData 里新建的文件会被转存到应用的私有目录,Codex 外面的命令行和引擎就看不到了。-- 里面有:`selection/`(勾选状态,每个任务一个文件,只记取消的识别键;v0.3 起还记自动选图的开关 `auto`、最近一次切换的时间 `autoAt`、第一次打开的时间 `autoSince` 和固定发送的识别键 `pinned`)、`bindings/`、`state/requests/`(请求统计)、`cache/pixels/`、`proxy/`(引擎日志)、`plugin-server.jsonl`、`language.json`、`config-backup/`。+- 里面有:`selection/`(勾选状态,每个任务一个文件,只记取消的识别键;v0.3 起还记自动选图的开关 `auto`、最近一次切换的时间 `autoAt`、第一次打开的时间 `autoSince` 和固定发送的识别键 `pinned`;v0.6 起还有 `auto-default.json`,新任务默认开着自动选图的起始时间)、`bindings/`、`state/requests/`(请求统计)、`cache/pixels/`、`proxy/`(引擎日志)、`plugin-server.jsonl`、`language.json`、`config-backup/`。- 分叉任务沿用原任务在分叉那一刻的勾选,之后各管各的。v0.3:固定发送一样按时间继承;开关在分叉前打开、之后没再切换过才继承;分叉前用过自动选图的,分叉也记下 `autoSince`,以便省略历史里的副本。- `migrate-data.ts` 在第一次使用时,把旧位置(旧的 AppData 目录和各应用私有目录里的副本)的数据复制过来,用锁文件保证只有一个进程在复制。@@ -184,6 +185,7 @@- **自动选图自测**(v0.3,`v03-auto-selftest.ts`):同样起自己的引擎和 app-server,另把本仓库的插件服务挂成一个单独的 MCP 服务,提供 `cam_view_image`;开关写在测试自己的勾选文件里。测试图角落各藏一个数字,描述时不提:- A 组明确要求取图,检查取到、副本不另编号、下一轮被省略;- B 组问需要看图的(角落数字、按颜色找图、两个数字相加)和不需要看图的(复述、翻译);+ - D 组(v0.6)不设开关,检查新任务默认开着;一个问题同时要两张没取过的图,检查都取回、答对;- C 组只有一张图,排除上下文的干扰。- 2026-10-06 的结果:sol、astra 中英文全部通过;luna 取不取的判断基本都对(英文 C 组漏取一次),读取回的图偶尔读错数字(见第 11 节“模型的差别”)。@@ -209,7 +211,7 @@- v0.3 查证:GPT-6 Luna(low)读工具结果里的图,比读用户消息里的图差。同一张图放在消息里问,四次都读对;经 `cam_view_image` 或 Codex 自带的 `view_image` 送来,常把角落的小数字读错(5 读成 3,7 读成 2),有时说看不到数字。把取回的图挪进紧跟着的一条用户消息也没改善,问题在“先调用工具再看图”这个过程,不在图放在哪里。Sol、Astra 没有这个问题。README 和发布说明写明了这一点。- **桌面版的上下文比自测多**:桌面版每轮还带着电脑操作、浏览器等插件的工具说明(约 1 万 token)。自测为了不让测试模型操作用户的电脑,没开这些插件,所以个别只在桌面版出现的模型行为,自测复现不出来。-## 12. Claude Code 接入(v0.4、v0.5)+## 12. Claude Code 接入(v0.4–v0.6)方案、关卡和任务见 [v0.4/plan.md](v0.4/plan.md)。做法是把上面的机制逐块移植,这里写对应的做法和平台逼迫的改动。@@ -248,6 +250,8 @@- 页面和接口只接受用本机名字(`localhost`、`127.0.0.1`、`[::1]`)访问、不带其他网站 Origin 的请求;接口还要带 `x-cam-panel` 请求头;页面带严格的 CSP。- `/cam` 用桌面版给每个 Code 会话的浏览器工具(`Claude_Browser` 的 `preview_start`),在自带的浏览器里打开页面。这个工具不是公开给插件的接口,调用失败或者没有时,Mod 弹出小面板给链接。Mod 面板里的链接,点开会交给系统浏览器。- 小面板上的图片数,在打开时、每轮结束后,以及 `/clear`、`/resume` 之后重新读取。+ - v0.6 自动打开(Mod):桌面版的浏览器工具能用(终端和 VS Code 里没有)、请求经过引擎时,在进程启动、每轮开始和结束时检查:会话有图(引擎的面板接口)、面板没开(`tabs_context` 里没有引擎来源的标签页)、用户没在这个会话里关过,就 `preview_start` 打开。检查一次只做一个,免得开出两个标签页。+ - 谁关的按时间分:桌面版只在一轮结束 30 分钟后关会话的自带浏览器,Claude Code 进程不停。这个进程开过的面板在那之前没了,是用户关的,记在插件自己的存储里(`closedPanels`,按会话,留最近 200 个),之后不再自动打开;停了 30 分钟以上,下一轮开始时不在,就重新打开。一轮结束 25 分钟后再看一次,认出停顿里被用户关掉的。`/cam` 清掉这个记录,打开新标签页并关掉旧的;`/clear`、`/resume` 后,开着的面板换到新会话。- 页面语言跟着引擎(`CAM_LANG` 或系统语言),不看浏览器。- **取图工具**:插件服务以 `CAM_HOST=claude` 运行,只给模型 `cam_view_image`。Mod 把调用它的会话 id 补进参数(插件服务可能比 `/clear`、`/resume` 活得久),并在 `classic.PreToolUse` 里放行这一个工具:先让下面的钩子和设置判断,它们拒绝或要求询问时照旧。- **数据目录**:Claude 会话的勾选在 `claude/selection/`,请求统计在 `claude/requests/`,思考记录的哈希在 `claude/thinking/`,和 Codex 的分开。@@ -259,5 +263,6 @@- **依赖的 Claude 行为**(都不是公开接口,Claude 更新后要重新验证):- 会话记录的格式:`parentUuid`、`turnPosition`、压缩分界、并行工具结果的挂法;请求头 `x-claude-code-session-id`。v0.5:压缩后的请求以摘要开头,摘要文字和记录里 `isCompactSummary` 那条相同;会话记录只追加,压缩前的图一直在里面。- 桌面版启动会话的方式:启动时传入 `ANTHROPIC_BASE_URL`;新会话要到第一条输入才启动进程,所以 `/cam` 在那之前不在输入框的命令列表里。- - `Claude_Browser` 浏览器工具;Mod 面板里的链接交给系统浏览器;桌面版在会话里发的附带请求。+ - `Claude_Browser` 浏览器工具(v0.6 还用 `tabs_context`、`tabs_close`、`navigate`);Mod 面板里的链接交给系统浏览器;桌面版在会话里发的附带请求。+ - v0.6:桌面版在一轮结束 30 分钟后断开会话的自带浏览器、关掉它的标签页,Claude Code 进程照常运行(日志里的 `[WarmLifecycle:preview] … Idle timeout reached`);内存紧张时停掉闲置很久的进程,用到时再启动(`[CliGovernor] pressure evicting`)。时间变了,自动打开分不清谁关的。- 思考记录的前缀校验:替换历史里的一张图,之后的思考块就对不上了;2026-08-31 以后注册的账号直接拒绝。比较时不看 JSON 写法和键的顺序;去掉开头或末尾的思考可以,去掉中间的会让后面的失效,把去掉过的放回去,会让它不在期间产生的失效。diff --git a/docs/spec.md b/docs/spec.mdindex 04401d2..69204cf 100644--- a/docs/spec.md+++ b/docs/spec.md@@ -1,6 +1,6 @@# 规格:Context Attachment Manager(上下文素材管理器)-> 本文件是目标、范围、约束和验收标准的唯一事实来源(2026-09-24 经用户、Claude、Codex 三方确认),描述当前版本 v0.5.0,以后随版本更新。v0.4 加的 Claude 桌面 Code 接入,相关内容都标着“v0.4”;它的关卡、任务和验收步骤见 [v0.4/](v0.4/)。v0.5 加的 Claude Code 压缩后保留图片标着“v0.5”,方案和实测见 [v0.5/plan.md](v0.5/plan.md)。项目 2026-10-11 由 Codex Attachment Manager 改名,因为不再只给 Codex 用(用户定);安装用的标识(`codex-attachment-manager`)和数据目录不变,已装的用户照常升级。+> 本文件是目标、范围、约束和验收标准的唯一事实来源(2026-09-24 经用户、Claude、Codex 三方确认),描述当前版本 v0.5.0,以后随版本更新。v0.4 加的 Claude 桌面 Code 接入,相关内容都标着“v0.4”;它的关卡、任务和验收步骤见 [v0.4/](v0.4/)。v0.5 加的 Claude Code 压缩后保留图片标着“v0.5”,方案和实测见 [v0.5/plan.md](v0.5/plan.md)。v0.6 的默认开启自动选图和 Claude 桌面版自动打开面板标着“v0.6”,见 [v0.6/plan.md](v0.6/plan.md)。项目 2026-10-11 由 Codex Attachment Manager 改名,因为不再只给 Codex 用(用户定);安装用的标识(`codex-attachment-manager`)和数据目录不变,已装的用户照常升级。> 技术方案见 [design.md](design.md)。v0.1 的开发记录(原方案、任务记录、各阶段报告、最初的构想)归档在 [history/v0.1/](history/v0.1/),只作参考。## 1. 目标@@ -18,7 +18,7 @@ v0.4:同样的管理也用在 Claude 桌面应用的 Code 标签页里(本- **出现记录**:一张图在任务历史里出现的一次,例如用户上传、工具查看、生成结果。每条都有稳定编号(例如 `IMG-004`),按在任务里第一次出现的顺序编号,之后不变。记录名称、来源、所在轮次、尺寸和内容指纹。- **内容相同**:两条出现记录的字节完全相同,或者解码后的像素完全相同,就算内容相同,与文件名无关。缩放或重新压缩过的图不算。- **勾选状态**:每个任务各有一套。勾选的图照常发送;取消的图在发出的请求里换成占位符。-- **自动选图**:每个任务各有一个开关,默认关。打开后,之前各轮的图默认不发,模型需要看哪张,就用取图工具按编号取回原图,只在这一轮提供;勾选的意思变成“固定发送”,默认都不勾,勾上的图每轮都发(v0.3,用户 2026-10-06 定:不在模型开口之前替它准备可能要的图,由它自己按编号要)。+- **自动选图**:每个任务各有一个开关。v0.6 起,新任务和新会话默认开着,升级之前就有的任务和会话保持原样,用户改过的以用户的为准(用户 2026-10-13 定:有些用户连面板都不会打开);之前默认关。打开后,之前各轮的图默认不发,模型需要看哪张,就用取图工具按编号取回原图,只在这一轮提供;勾选的意思变成“固定发送”,默认都不勾,勾上的图每轮都发(v0.3,用户 2026-10-06 定:不在模型开口之前替它准备可能要的图,由它自己按编号要)。- **来源**:每条出现记录属于一类来源:用户上传、PDF 页面、网页截图、查看的图片、工具返回、生成的图片。PDF 页面和网页截图是用户在 Codex 桌面版里给 PDF 或网页加评论时,Codex 随消息附上的截图,靠 Codex 写在图前面的固定说明认出(例如 “The next image shows PDF page 3 at the time of Comment 1.”)。PDF 页面记下页码;同一条消息只提到一个 PDF 时,再记下文件名。认不出的仍算用户上传(v0.2,用户 2026-09-29 定:只做认得准的来源)。### 免配置@@ -87,7 +87,7 @@ v0.4:同样的管理也用在 Claude 桌面应用的 Code 标签页里(本- “模型需要”提示条照旧列出全部;点到没显示的图时,自动选上它的类别,再定位到那一行。- 展开状态和选中的类别在面板开着时保留,关掉再打开回到默认;不写磁盘。- 自动选图(v0.3,用户 2026-10-06 看过标注截图后定):- - 底栏右侧有“自动选图”开关,每个任务各开各的,默认关,点一下就保存。底栏那句说明跟着变:关着时是“勾选的图片会随下一条消息发给模型”,开着时是“勾选的图每轮都发,其余由模型按需取回”。+ - 底栏右侧有“自动选图”开关,每个任务各开各的,点一下就保存;v0.6 起新任务和新会话默认开着(见上面“核心概念”)。底栏那句说明跟着变:关着时是“勾选的图片会随下一条消息发给模型”,开着时是“勾选的图每轮都发,其余由模型按需取回”。- 开着时,勾选框的意思是“固定发送”,默认都不勾,和手动时的勾选分开记:关掉自动,手动时的勾选原样回来。整轮勾选就是把这一轮的图全部固定发送。模型取图不改勾选。没勾的图本来就默认不发,不再逐张标“不发送”。- 页头的“模型需要”提示条换成“最近一轮模型取回 N 张”,列出编号,点编号定位到那一行,用法和“模型需要”一样;模型取过的图在它那一行标“模型取回”。- 发送预览写“固定发送几张、占位几张”;预计请求大小只算固定发送的图,不含模型这一轮要取的(事先不知道)。@@ -128,6 +128,7 @@ v0.4:同样的管理也用在 Claude 桌面应用的 Code 标签页里(本- 还不行时才改发原始请求,面板提示这次没能按勾选改写,这一次也不算取消成功。对话不中断,也不会因为记录不全而卡住:记录不全时宁可多去掉思考。- **面板**:和 Codex 是同一个面板页面(用户 2026-10-10 要求两边一致)。Claude Code 不给用户打开插件的 MCP 应用,插件自己的小面板(Mod 面板)也放不进网页,所以面板由本机引擎作为网页提供:- 用户输入 `/cam`,面板在 Claude 桌面自带的浏览器里打开,就在对话旁边(用户 2026-10-10 选定)。+ - v0.6(用户 2026-10-13 定):不用输入 `/cam`,会话里有了图,面板就自己在自带的浏览器里打开(模型读了图,那一轮结束时;用户贴了图,那一轮开始时)。Claude 桌面在一轮结束 30 分钟后会关掉会话的自带浏览器,面板跟着关掉,下一轮开始时重新打开。用户自己关掉的,这个会话里不再自动打开,直到用户输入 `/cam`。只在 Claude 桌面版里,终端和 VS Code 照旧用 `/cam`。- 只有两种情况才弹出插件的小面板:自带浏览器打不开时(终端、VS Code,或调用失败),给出面板链接和“复制链接”按钮;这个会话的请求没经过引擎、勾选不会生效时,提醒用户。- 新会话的第一条输入就是 `/cam` 时,输入框会提示命令不存在,但发出后照常打开:Claude 桌面要等第一条输入才启动会话的进程,插件这时才注册 `/cam`。保持现状,在用户文档里写明(用户 2026-10-10 定)。- 没有 Codex 特有的“启用插件 / 停用插件”按钮和新任务绑定。@@ -173,7 +174,7 @@ v0.1 到 v0.3 都不做下面这些。其中音频和其他语言已确认是后- 仓库里的文档和代码不写用户本机的具体路径(例如个人项目文件夹)。`~/.codex`、`%LOCALAPPDATA%` 这类通用位置可以写。本项目以后会开源。- 不改写原生任务的历史记录。- 代理只替换用户取消的图片,连同 Codex 附在它前后的路径标签;自动选图开着时,还替换之前各轮没有固定发送的图(v0.3)。有图片被省略时,另外插入一条“上下文管理说明”开发者消息(用户 2026-09-25 要求告诉模型原因,见第 1 节“占位符”),并在仍发送的图前面加“已提供”标签(v0.1-25)。请求里的其他内容原样转发。v0.4:Claude 的请求里,说明是系统消息(位置见第 1 节“Claude Code(v0.4)”);思考块原样转发,只在账号拒绝时去掉对不上的那些,不关掉思考(用户 2026-10-11 定)。v0.5:Claude Code 压缩之后,引擎还把压缩前的图从本地会话记录里取出来,补在摘要后面(用户勾选或固定发送的发原图,其余放占位文字),并跟一条说明(用户 2026-10-12 定,见第 1 节“压缩之后”)。这是唯一往请求里加图的地方,其余内容仍原样转发。-- 选择权在用户:默认只由用户在面板里勾选决定,工具和模型都不能自动勾选或取消;模型只能按约定索要(例如回复“需要 IMG-004”),给不给由用户决定。用户给某个任务打开“自动选图”后,之前各轮的图默认不发,由模型用取图工具按编号取回需要的图,只在这一轮有效;模型不能改用户的勾选,也不能替用户开关自动选图(v0.3,用户 2026-10-06 定,取代原来的“选择权永远在用户”)。+- 选择权在用户:默认只由用户在面板里勾选决定,工具和模型都不能自动勾选或取消;模型只能按约定索要(例如回复“需要 IMG-004”),给不给由用户决定。用户给某个任务打开“自动选图”后,之前各轮的图默认不发,由模型用取图工具按编号取回需要的图,只在这一轮有效;模型不能改用户的勾选,也不能替用户开关自动选图(v0.3,用户 2026-10-06 定,取代原来的“选择权永远在用户”)。v0.6 起新任务和新会话默认开着自动选图,用户随时可以关(用户 2026-10-13 定)。- 先在 Windows 上开发和测试。技术栈:TypeScript/Node。macOS、Linux 由 CI 验证能装上、能启动;这两个平台桌面版上的实测,等用户在 GitHub 上反馈(用户 2026-09-25 定)。- 交付形态:Codex 插件。插件带一个本地 MCP 服务,负责拉起引擎、提供面板;仓库根目录就是插件市场。面板位置见第 1 节“界面”。- 用户在 Codex 的插件页面添加插件市场 `chipfighter/context-attachment-manager`、装上插件,再在面板里点“启用”;卸载前在面板里点“停用”。@@ -243,6 +244,15 @@ v0.1 之前的阶段验收(阶段 0 的重建路线、代理路线 P2)都已6. Codex 的功能和请求不变。7. 中英文都实测,真实桌面会话,Haiku 5.5。+### v0.6++> 用户 2026-10-13 定,方案和实测见 [v0.6/plan.md](v0.6/plan.md)。++1. 升级之后新开的 Codex 任务和 Claude 会话默认开着自动选图;之前就有的保持原样;面板里改过的以用户的为准。+2. 模型需要多张图时都取回(Codex 和 Claude 都测)。+3. Claude 桌面版里有图的会话自动打开面板;被桌面版关掉的,下一轮重新打开;用户关掉的不再自动打开,`/cam` 能再打开;只留一个面板标签页。+4. 原有测试和 Codex 自测不退化。+## 5. 待定问题- 在插件页面移除或关掉插件、没先在面板里停用时,代理设置还在:diff --git a/docs/v0.6/plan.md b/docs/v0.6/plan.mdindex 4b8861c..f86f76f 100644--- a/docs/v0.6/plan.md+++ b/docs/v0.6/plan.md@@ -41,6 +41,13 @@- Codex 自测(`v03-auto-selftest.ts` 新加任务 D):不设开关,看新任务是否默认开着;一个问题同时需要两张没取过的图,看模型是否都取回、答对。- Claude 桌面版实测:新会话默认开着、多张图一起取回、面板自动打开和关掉后不再打开。+结果(2026-10-13,开发引擎):++1. 单元测试 196 个、Mod 测试 16 个全部通过;Mod 测试在上一版代码上跑,新加的 6 个都失败,确认测得到改动。Claude Code 的插件检查(`claude plugin validate`)通过。+2. Codex 任务 D(不设开关):gpt-6-sol 中英文、gpt-6-luna 和 gpt-6-astra 中文,新任务都默认开着(之前各轮的三张图都换成了占位文字),都一次取回了两张图。sol 和 astra 答对(7 + 5 = 12);luna 把紫色图的 5 读成了 3,和 v0.3 记下的一样(小模型读取回的图会读错小细节)。+3. Claude 桌面版(Haiku 5.5,推理强度 low):新会话的面板接口返回自动选图开着。三张图只描述了背景和形状之后,问 a-red.png 和 c-tri.png 角落小方块的位置和颜色,模型一次 `cam_view_image` 取回 IMG-001 和 IMG-003,答对(右下角黑色、右上角橙色)。这个会话的插件服务是旧的测试副本,所以开关是在面板接口里写下的,默认值由引擎给出。+4. 面板自动打开还没在桌面版里实测:测试副本按版本缓存,改完要重新安装才会被新会话用上(之前的测试会话一直用着 v0.4 时的副本,早上看到的“没打开”就是这个原因)。重新安装后要开一个新的测试会话,按“有图打开、停顿 30 分钟后重开、用户关掉后不再开”走一遍。+## 6. 验收1. 升级之后新开的 Codex 任务和 Claude 会话默认开着自动选图;之前的保持原样;面板里改过的以用户的为准。