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: 写回新账号思考记录的处理;README 写明 Claude 桌面版的安装和用法
chipfighter6260715414a8
diff --git a/README.md b/README.mdindex 94fc516..780c77e 100644--- a/README.md+++ b/README.md@@ -2,20 +2,23 @@<img src="plugin/assets/logo.png" width="96" height="96" alt=""></p>-<h1 align="center">Codex Attachment Manager</h1>+<h1 align="center">Context Attachment Manager</h1>-<p align="center">Choose which past images go to the model with your next message, without leaving the task.</p>+<p align="center">Choose which past images go to the model with your next message, in Codex and in Claude Desktop, without leaving the conversation.</p><p align="center">- <a href="https://github.com/chipfighter/codex-attachment-manager/actions/workflows/ci.yml"><img src="https://github.com/chipfighter/codex-attachment-manager/actions/workflows/ci.yml/badge.svg" alt="CI"></a>- <a href="https://github.com/chipfighter/codex-attachment-manager/releases"><img src="https://img.shields.io/github/v/release/chipfighter/codex-attachment-manager?include_prereleases" alt="Release"></a>+ <a href="https://github.com/chipfighter/context-attachment-manager/actions/workflows/ci.yml"><img src="https://github.com/chipfighter/context-attachment-manager/actions/workflows/ci.yml/badge.svg" alt="CI"></a>+ <a href="https://github.com/chipfighter/context-attachment-manager/releases"><img src="https://img.shields.io/github/v/release/chipfighter/context-attachment-manager?include_prereleases" alt="Release"></a><img src="https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey" alt="Platform: Windows, macOS, Linux"><img src="https://img.shields.io/badge/Codex%20desktop-26.924-339CFF" alt="Tested on Codex desktop 26.924">+ <img src="https://img.shields.io/badge/Claude%20Desktop-Claude%20Code%202.1.295-D97757" alt="Tested in Claude Desktop with Claude Code 2.1.295"><a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="License: MIT"></a></p><p align="center"><b>English</b> · <a href="README_CN.md">简体中文</a></p>+> **New in 0.4: it works in Claude Desktop too.** In the Code tab of Claude Desktop, install the plugin and type `/cam` in a session: the same panel opens in Claude Desktop's built-in browser, next to the conversation. 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%"></p>@@ -24,75 +27,105 @@I was iterating on image generation with GPT in Codex. After a dozen or so images, the task started failing: the connection kept dropping, and the retries every few minutes never went through. Digging into it, I found that Codex sends every image in the task's history again with every request, and each request had grown to about 44 MB. The only way out was a new task, which meant losing the conversation.-So I wanted to keep the long conversation going and decide, turn by turn, which images the model still gets. Uncheck the ones you no longer need: from the next message on they become short placeholders, and the task and the conversation stay the same.+So I wanted to keep the long conversation going and decide, turn by turn, which images the model still gets. Uncheck the ones you no longer need: from the next message on they become short placeholders, and the task and the conversation stay the same. Claude Code also sends the whole history with every request, so 0.4 brings the same panel to Claude Desktop.## Features-- **Every image in one list**: a *Context Assets* tab in Codex's side panel lists every image in the task, turn by turn: the ones you uploaded and the ones the model viewed or generated, with thumbnails, IDs and sizes. Click one to preview it.+- **Every image in one list**: the panel lists every image in the task (in Codex) or session (in Claude Code), turn by turn: the ones you uploaded and the ones the model viewed or generated, with thumbnails, IDs and sizes. Click one to preview it. In Codex it's a *Context Assets* tab in the side panel; in Claude Desktop, `/cam` opens it in the built-in browser.- **Filter by source**: with many images, show only some sources: your uploads, PDF pages you commented on in Codex (with the page number and the PDF's name), web page screenshots, and images the model viewed, got from a tool or generated. Filtering changes what you see, never what is sent.- **One click to leave an image out**: unchecked images become a short placeholder from the next message on. Toggle single images or a whole turn.- **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. 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): 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.- **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.-- **Stays on your machine**: the plugin sends nothing anywhere besides the requests Codex already makes to OpenAI.+- **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.+- **Stays on your machine**: the plugin sends nothing anywhere besides the requests Codex and Claude Code already make to OpenAI and Anthropic.## How it works-- The plugin runs a small local proxy, the engine, between Codex and OpenAI. Before a request goes out, the engine swaps unchecked images for placeholders and adds the note; everything else is forwarded as is.+- The plugin runs a small local proxy, the engine, between Codex and OpenAI, and between Claude Code and Anthropic. Before a request goes out, the engine swaps unchecked images for placeholders and adds the note; everything else is forwarded as is, including your sign-in.+- In Codex, installing points Codex at the engine. In Claude Desktop, the plugin points each Claude Code session at the engine when the session starts, and puts it back when the session ends.- With Auto-select on, the engine does the same for the images of earlier turns you haven't pinned, and the plugin gives the model one tool, `cam_view_image`, to fetch an image back into the current turn. The placeholders before it stay as they were, so the cached part of the request isn't broken.-- Selections and the Auto-select switch are saved per task. Only you can change them; the model can only fetch an image for one turn, and only with Auto-select on.-- The panel is an MCP app you open from the side panel. It doesn't go through the model and costs no tokens.+- Selections and the Auto-select switch are saved per task or session. Only you can change them; the model can only fetch an image for one turn, and only with Auto-select on.+- The panel doesn't go through the model and costs no tokens. In Codex it's an MCP app in the side panel; in Claude Desktop the engine serves the same page to the built-in browser, on your machine only.## Requirements-- Codex desktop app. Tested on Windows with Codex 26.924.-- macOS and Linux: CI installs the plugin with Codex's own CLI, starts it, and runs the install and uninstall scripts, but nobody has tried it in the desktop app on these platforms yet. [Issues](https://github.com/chipfighter/codex-attachment-manager/issues) welcome.-- No separate Node install: the plugin uses the Node 24 that ships with Codex, and falls back to `node` 24 or later on your PATH.+- **Codex**: the Codex desktop app. Tested on Windows with Codex 26.924.+- **Claude Desktop**: the Code tab, local sessions, signed in with your Claude subscription. Tested on Windows with the Claude Code 2.1.295 that Claude Desktop runs.+- macOS and Linux: CI installs the plugin with Codex's own CLI, starts it, and runs the install and uninstall scripts, but nobody has tried it in the desktop apps on these platforms yet. [Issues](https://github.com/chipfighter/context-attachment-manager/issues) welcome.+- Node: the plugin uses the Node 24 that ships with Codex, and falls back to `node` 24 or later on your PATH. Claude Desktop doesn't ship Node, so without Codex, install [Node 24 or later](https://nodejs.org).## Install### In Codex, no terminal-1. On Codex's **Plugins** page, click **Add a marketplace**, enter `chipfighter/codex-attachment-manager` as the **Source**, leave the rest empty, and click **Add marketplace**.-2. Install **Codex Attachment Manager** from the list.+1. On Codex's **Plugins** page, click **Add a marketplace**, enter `chipfighter/context-attachment-manager` as the **Source**, leave the rest empty, and click **Add marketplace**.+2. Install **Context Attachment Manager** from the list.3. Open a task, click **Toggle side panel** at the top right, open a new tab with **+**, and choose **Context Assets** under **Plugins and MCPs**. If it isn't there, restart Codex once.4. The panel says the plugin is not enabled yet. Click **Enable plugin**, then restart Codex.-### One command+### In Codex, one commandWindows (PowerShell):```powershell-irm https://github.com/chipfighter/codex-attachment-manager/releases/latest/download/install.ps1 | iex+irm https://github.com/chipfighter/context-attachment-manager/releases/latest/download/install.ps1 | iex```macOS and Linux:```bash-curl -fsSL https://github.com/chipfighter/codex-attachment-manager/releases/latest/download/install.sh | sh+curl -fsSL https://github.com/chipfighter/context-attachment-manager/releases/latest/download/install.sh | sh```The command installs the plugin with Codex's own CLI and sets up the proxy. Restart Codex afterwards. Run it again later to upgrade.-### What installing changes+What installing changes in Codex:- Adds a marked proxy block to `~/.codex/config.toml`, after backing the file up.- If a proxy is set in your environment variables, adds a marked `NO_PROXY` block with local addresses only to `~/.codex/.env`.- Nothing else. If you have set `openai_base_url` yourself, installing stops without writing anything.+### In Claude Desktop++Claude Desktop installs plugins only from marketplaces you have added, and adding one from GitHub takes the `claude` command, Claude Code's command line ([setup guide](https://code.claude.com/docs/en/setup)). Once:++```bash+claude plugin marketplace add chipfighter/context-attachment-manager+```++```bash+claude plugin install codex-attachment-manager@codex-attachment-manager+```++Instead of the second command, you can also install it in the Code tab: click **+** next to the prompt box, choose **Plugins**, then **Add plugin**, pick **Context Attachment Manager**, and install it for your user account. The install ID keeps the project's old name.++Then start a new session in the Code tab. There is nothing to set up: the plugin doesn't edit any settings, and only points that session's own Claude Code process at the engine while it runs.+## Usage+### In Codex+1. 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.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.+### 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.+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.+## Uninstall+### Codex+Disable first, then remove: click **Disable plugin** in the panel, remove the plugin on the **Plugins** page, and restart Codex.Or run the uninstall command. It restores the direct connection and removes the plugin, and it works even when the plugin files are gone:@@ -100,39 +133,45 @@ Or run the uninstall command. It restores the direct connection and removes theWindows (PowerShell):```powershell-irm https://github.com/chipfighter/codex-attachment-manager/releases/latest/download/uninstall.ps1 | iex+irm https://github.com/chipfighter/context-attachment-manager/releases/latest/download/uninstall.ps1 | iex```macOS and Linux:```bash-curl -fsSL https://github.com/chipfighter/codex-attachment-manager/releases/latest/download/uninstall.sh | sh+curl -fsSL https://github.com/chipfighter/context-attachment-manager/releases/latest/download/uninstall.sh | sh```-Your selections and logs stay in the data folder (see [Privacy](#privacy)); delete it if you don't need them.-**If Codex can't connect** and its errors mention `localhost:17891` (for example, the plugin was removed without disabling it first), run the uninstall command above and restart Codex. On macOS and Linux the engine also restores the direct connection by itself once the plugin is removed or turned off, from the next start of Codex.+### Claude Desktop++Uninstall it with **Manage plugins** under **+** → **Plugins** in the Code tab, or with `claude plugin uninstall codex-attachment-manager@codex-attachment-manager`. New sessions then connect directly; there is nothing to restore.++Your selections and logs stay in the data folder (see [Privacy](#privacy)); delete it if you don't need them.+## Good to know-- Only images are managed, because they are the only files that reach the model as they are. Codex doesn't send PDFs or videos themselves, only text the model extracts from them or images it makes of them, and those images are listed like any other. Audio waits for a Codex model that accepts it: until then, Codex replaces audio with a short note before sending.+- Only images are managed, because they are the only files that reach the model as they are. Codex doesn't send PDFs or videos themselves, only text the model extracts from them or images it makes of them, and those images are listed like any other. Audio waits for a model that accepts it: until then, Codex replaces audio with a short note before sending.- Results of Codex's built-in image generation can't be unchecked.- With Auto-select on, each image the model fetches adds a request to that turn. Smaller models may misread small details in an image they fetched: in our tests GPT-6 Luna at low effort sometimes did, as it does with images opened with Codex's own image viewer, while GPT-6 Sol and Astra read them right. Pin an image whose details matter, or use a larger model.-- If you uncheck an image while a turn is still running over WebSocket, the rest of that turn still carries the original. The panel tells you; the change applies from the next message.-- Enabling, disabling and upgrading take effect after you restart Codex.+- **Claude accounts created on or after August 31, 2026** check the model's earlier thinking against the conversation before it. To leave an image out on such an account, the engine also leaves out the earlier thinking that no longer matches the conversation as sent, so the model may think again and use more tokens; the panel tells you each time. Thinking from after the change is kept, and checking the image again brings back the thinking from before. Older accounts aren't affected.+- In Claude Code, the main conversation is managed; subagents keep their own history as it is. Sessions that use another API address or a cloud provider (Bedrock, Vertex, Foundry) are left alone.+- If you uncheck an image while a Codex turn is still running over WebSocket, the rest of that turn still carries the original. The panel tells you; the change applies from the next message.+- In Codex, enabling, disabling and upgrading take effect after you restart Codex. In Claude Desktop, a new plugin version takes effect in new sessions: upgrade with `claude plugin marketplace update codex-attachment-manager`, then `claude plugin update codex-attachment-manager@codex-attachment-manager`.- After you switch Codex's language, the panel changes right away and the note for the model changes from the next message, but the tab name in the side panel changes only after a restart.- Right after Codex starts, the engine may restart a few times and you may see "Reconnecting" once.- The engine goes through your system proxy: on Windows it reads the system setting, on macOS it supports HTTP(S) proxies only (no PAC or SOCKS), and on Linux it reads `HTTPS_PROXY` and similar variables.## Privacy-- All data stays in a local folder: `%USERPROFILE%\.codex-attachment-manager` on Windows, `~/Library/Application Support/codex-attachment-manager` on macOS, `~/.local/share/codex-attachment-manager` on Linux. It holds your selections, request statistics (sizes and counts only, never content), logs (no conversation content or credentials) and the backup of `config.toml`.-- Besides the requests Codex already sends to OpenAI, the plugin sends nothing anywhere.-- Codex's conversation records are only read, never modified.+- All data stays in a local folder: `%USERPROFILE%\.codex-attachment-manager` on Windows, `~/Library/Application Support/codex-attachment-manager` on macOS, `~/.local/share/codex-attachment-manager` on Linux. It holds your selections, request statistics (sizes and counts only, never content), hashes the engine uses to tell which thinking still matches (never content), logs (no conversation content or credentials) and the backup of `config.toml`.+- Besides the requests Codex and Claude Code already send to OpenAI and Anthropic, the plugin sends nothing anywhere.+- The conversation records of Codex and Claude Code are only read, never modified.## Development-- `plugin/` is the plugin itself: the MCP server, the engine, the panel and the `cam` command line (runtime code in `plugin/src`). `spike/` holds the tests and experiments, `scripts/` the one-line install and uninstall scripts, and `docs/` the spec and the technical design (in Chinese; start with [docs/spec.md](docs/spec.md)). The development records of v0.1 are in `docs/history/v0.1/`.+- `plugin/` is the plugin itself: the MCP server, the engine, the panel and the `cam` command line (runtime code in `plugin/src`). The Claude plugin is `.claude-plugin/` plus the mod in `hooks/`. `spike/` holds the tests and experiments, `scripts/` the one-line install and uninstall scripts, and `docs/` the spec and the technical design (in Chinese; start with [docs/spec.md](docs/spec.md)). The development records of v0.1 are in `docs/history/v0.1/`.- Install from source into your Codex: quit Codex, run `cam install` in the repository (`./cam install` on macOS and Linux), then start Codex. `cam status` shows the installation, `cam uninstall` removes it.- Run the tests with Node 24 or later: `cd spike && node --test`. CI runs them on Windows, macOS and Linux, then installs the plugin with Codex's CLI and runs the install and uninstall scripts.- Work on the panel without Codex: `node spike/scripts/panel-dev.ts`, then open `http://127.0.0.1:17895/?solo=1`. The page uses synthetic images and a temporary Codex folder, so your real data is never read or changed.diff --git a/README_CN.md b/README_CN.mdindex fc54290..c7561df 100644--- a/README_CN.md+++ b/README_CN.md@@ -2,20 +2,23 @@<img src="plugin/assets/logo.png" width="96" height="96" alt=""></p>-<h1 align="center">Codex Attachment Manager</h1>+<h1 align="center">Context Attachment Manager</h1>-<p align="center">不换任务,决定哪些历史图片随下一条消息发给模型。</p>+<p align="center">在 Codex 和 Claude 桌面版里,不换对话,决定哪些历史图片随下一条消息发给模型。</p><p align="center">- <a href="https://github.com/chipfighter/codex-attachment-manager/actions/workflows/ci.yml"><img src="https://github.com/chipfighter/codex-attachment-manager/actions/workflows/ci.yml/badge.svg" alt="CI"></a>- <a href="https://github.com/chipfighter/codex-attachment-manager/releases"><img src="https://img.shields.io/github/v/release/chipfighter/codex-attachment-manager?include_prereleases" alt="版本"></a>+ <a href="https://github.com/chipfighter/context-attachment-manager/actions/workflows/ci.yml"><img src="https://github.com/chipfighter/context-attachment-manager/actions/workflows/ci.yml/badge.svg" alt="CI"></a>+ <a href="https://github.com/chipfighter/context-attachment-manager/releases"><img src="https://img.shields.io/github/v/release/chipfighter/context-attachment-manager?include_prereleases" alt="版本"></a><img src="https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey" alt="平台:Windows、macOS、Linux"><img src="https://img.shields.io/badge/Codex%20desktop-26.924-339CFF" alt="在 Codex 桌面版 26.924 上实测">+ <img src="https://img.shields.io/badge/Claude%20Desktop-Claude%20Code%202.1.295-D97757" alt="在 Claude 桌面版(Claude Code 2.1.295)上实测"><a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="许可证:MIT"></a></p><p align="center"><a href="README.md">English</a> · <b>简体中文</b></p>+> **0.4 新增:Claude 桌面版也能用了。** 在 Claude 桌面版的 Code 标签页装上插件,在会话里输入 `/cam`,同一个面板就在 Claude 桌面版自带的浏览器里打开,就在对话旁边。项目原名 *Codex Attachment Manager*,因为不再只给 Codex 用,改了名。+<p align="center"><img src="docs/images/demo.gif" alt="面板的筛选先只显示 PDF 页面,再恢复显示全部,上传的图按整轮取消勾选。问起 v1 桌面版的聊天按钮,模型回复 need IMG-001;面板指出 IMG-001,用户勾上它,模型看图答出橙色。" width="100%"></p>@@ -24,75 +27,105 @@我在 Codex 里用 GPT 反复生图、改图。图攒到十几张以后,这个任务开始出问题:连接一直断,每隔几分钟自动重试一次,始终发不出去。查下去发现,Codex 每次请求都会把任务历史里的图全部重新发一遍,一次请求已经涨到约 44 MB。想去掉旧图只能新开任务,前面的对话就接不上了。-所以我想要的是:长对话照常继续,每一轮自己决定模型还能看到哪些图。不再需要的图取消勾选,从下一条消息起换成一小段占位文字,任务不换,对话连续。+所以我想要的是:长对话照常继续,每一轮自己决定模型还能看到哪些图。不再需要的图取消勾选,从下一条消息起换成一小段占位文字,任务不换,对话连续。Claude Code 每次请求也会把整段历史发一遍,所以 0.4 把同一个面板带到了 Claude 桌面版。## 功能-- **所有图片一个列表**:Codex 右侧的侧边面板里多出一个“上下文素材”标签页,按轮次列出任务里的每张图,包括你上传的,以及模型查看、生成的,带缩略图、编号和大小,点开可以看大图。+- **所有图片一个列表**:面板按轮次列出任务(Codex)或会话(Claude Code)里的每张图,包括你上传的,以及模型查看、生成的,带缩略图、编号和大小,点开可以看大图。在 Codex 里,它是侧边面板里的“上下文素材”标签页;在 Claude 桌面版里,用 `/cam` 在自带的浏览器里打开。- **按来源筛选**:图多的时候,只看某几类:你上传的、在 Codex 里批注 PDF 时附上的页面(标出第几页和 PDF 文件名)、网页截图,以及模型查看的、工具返回的、生成的。筛选只改变面板里显示哪些,不影响发送。- **点一下就不再发送**:取消勾选的图,从下一条消息起换成一小段占位文字。可以单张勾选,也可以整轮勾选。- **重复的图自动处理**:有内容相同的图还在发送时,占位文字指向那一张。- **模型知道原因**:一段说明告诉模型,这些图是你为了节省上下文省略的。它之前看着原图给出的回答仍然算数,也不会编造看不到的细节。- **模型要图,你来决定**:模型需要某张图时,会回复“需要 IMG-xxx”。面板列出它要的图,点一下就跳过去。重新勾上的图回到对话里原来的位置,并标着编号。-- **也可以交给模型选**(0.3 新增):在面板底栏打开“自动选图”,每个任务各开各的。之前各轮的图默认不发,模型需要哪张,就按编号取回,只在那一轮提供;勾上的图固定发送,每轮都发。面板会标出模型最近一轮取回了哪几张。+- **也可以交给模型选**(0.3 新增):在面板底栏打开“自动选图”,每个任务或会话各开各的。之前各轮的图默认不发,模型需要哪张,就按编号取回,只在那一轮提供;勾上的图固定发送,每轮都发。面板会标出模型最近一轮取回了哪几张。- **看得见省了多少**:面板预估下一条请求的大小,以及比全部发送省了多少;请求没能改写时会提示。-- **中英文界面**:面板、标签页名字和给模型的说明,都跟随 Codex 的界面语言(简体中文、英文)。-- **数据留在本机**:除了 Codex 本来就要发给 OpenAI 的请求,插件不向任何地方发送数据。+- **中英文界面**:面板、标签页名字和给模型的说明,都跟随 Codex 的界面语言(简体中文、英文);没装 Codex 时跟随系统语言。+- **数据留在本机**:除了 Codex 和 Claude Code 本来就要发给 OpenAI、Anthropic 的请求,插件不向任何地方发送数据。## 工作原理-- 插件在本机启动一个小代理(引擎),位于 Codex 和 OpenAI 之间。请求发出前,引擎把取消勾选的图换成占位文字,并加上那段说明;其余内容原样转发。+- 插件在本机启动一个小代理(引擎),位于 Codex 和 OpenAI、Claude Code 和 Anthropic 之间。请求发出前,引擎把取消勾选的图换成占位文字,并加上那段说明;其余内容原样转发,登录凭据也原样转发。+- 在 Codex 里,安装时把 Codex 指向引擎。在 Claude 桌面版里,插件在每个 Claude Code 会话启动时把它指向引擎,会话结束时还原。- 开着自动选图时,引擎对之前各轮没有固定发送的图也这样处理;插件给模型一个工具 `cam_view_image`,用来把某张图取回到当前这一轮。前面的占位文字保持不变,请求里已经缓存的部分不受影响。-- 勾选状态和自动选图开关按任务分别保存,只有你能改;模型只能在开着自动选图时,取回某张图在那一轮看。-- 面板是一个 MCP 应用,从侧边面板打开,不经过模型,也不花 token。+- 勾选状态和自动选图开关按任务或会话分别保存,只有你能改;模型只能在开着自动选图时,取回某张图在那一轮看。+- 面板不经过模型,也不花 token。在 Codex 里它是侧边面板里的 MCP 应用;在 Claude 桌面版里,由引擎把同一个页面提供给自带的浏览器,只在本机访问。## 环境要求-- Codex 桌面版。在 Windows 上用 Codex 26.924 实测过。-- macOS、Linux:CI 会用 Codex 自己的命令行装上插件、启动插件,并跑一遍安装和卸载脚本;但还没有人在这两个平台的桌面版上实际用过。遇到问题欢迎[提 issue](https://github.com/chipfighter/codex-attachment-manager/issues)。-- 不用另装 Node:插件使用 Codex 自带的 Node 24;找不到时,才用 PATH 里 24 及以上版本的 `node`。+- **Codex**:Codex 桌面版。在 Windows 上用 Codex 26.924 实测过。+- **Claude 桌面版**:Code 标签页里的本地会话,用你的 Claude 订阅登录。在 Windows 上实测过,Claude 桌面版运行的是 Claude Code 2.1.295。+- macOS、Linux:CI 会用 Codex 自己的命令行装上插件、启动插件,并跑一遍安装和卸载脚本;但还没有人在这两个平台的桌面版上实际用过。遇到问题欢迎[提 issue](https://github.com/chipfighter/context-attachment-manager/issues)。+- Node:插件使用 Codex 自带的 Node 24;找不到时,才用 PATH 里 24 及以上版本的 `node`。Claude 桌面版不带 Node,没装 Codex 的话,请装 [Node 24 或更新版本](https://nodejs.org)。## 安装### 在 Codex 里安装,不用开终端-1. 在 Codex 的**插件**页面点**添加插件市场**,**来源**填 `chipfighter/codex-attachment-manager`,其余留空,点**添加市场**。-2. 在列表里找到 **Codex Attachment Manager**,安装。+1. 在 Codex 的**插件**页面点**添加插件市场**,**来源**填 `chipfighter/context-attachment-manager`,其余留空,点**添加市场**。+2. 在列表里找到 **Context Attachment Manager**,安装。3. 打开一个任务,点右上角的**显示/隐藏侧边面板**,用 **+** 新建一个标签页,在**插件和 MCP**下选**上下文素材**。找不到的话,先重启一次 Codex。4. 面板提示插件还没有启用。点**启用插件**,然后重启 Codex。-### 一行命令+### 在 Codex 里用一行命令安装Windows(PowerShell):```powershell-irm https://github.com/chipfighter/codex-attachment-manager/releases/latest/download/install.ps1 | iex+irm https://github.com/chipfighter/context-attachment-manager/releases/latest/download/install.ps1 | iex```macOS、Linux:```bash-curl -fsSL https://github.com/chipfighter/codex-attachment-manager/releases/latest/download/install.sh | sh+curl -fsSL https://github.com/chipfighter/context-attachment-manager/releases/latest/download/install.sh | sh```命令会用 Codex 自己的命令行装好插件,并写好代理设置。装完重启 Codex。以后再运行一次,就是升级到最新版本。-### 安装会改什么+安装会在 Codex 里改这些:- 在 `~/.codex/config.toml` 里写一段带标记的代理设置,改之前先备份。- 如果环境变量里设了代理,再在 `~/.codex/.env` 里写一段带标记的 `NO_PROXY`,只包含本机地址。- 别的一概不动。如果你自己设了 `openai_base_url`,安装会停下来,什么都不写。+### 在 Claude 桌面版里安装++Claude 桌面版只能从已经添加的插件市场安装插件,而从 GitHub 添加插件市场要用 Claude Code 的命令行 `claude`([安装说明](https://code.claude.com/docs/en/setup))。只需要做一次:++```bash+claude plugin marketplace add chipfighter/context-attachment-manager+```++```bash+claude plugin install codex-attachment-manager@codex-attachment-manager+```++第二条命令也可以换成在 Code 标签页里装:点输入框旁边的 **+**,选**插件**,再选**添加插件**,找到 **Context Attachment Manager**,装到你的用户账户下。安装用的标识还是项目原来的名字。++然后在 Code 标签页里新建一个会话。不用做任何设置:插件不改任何设置,只在会话运行期间把这个会话自己的 Claude Code 进程指向引擎。+## 使用+### 在 Codex 里+1. 在任务的侧边面板里打开**上下文素材**。新任务也可以在发第一条消息之前打开:发出消息后,面板会自动切到这个任务。2. 取消勾选不想再发送的图。每次改动立刻保存,从下一条消息起生效。3. 模型回复“需要 IMG-xxx”、而那张图没有勾上时,面板顶部会列出它。点编号跳到那张图,勾上即可。4. 图多的时候,点刷新旁边的筛选按钮,选要看的来源。这时整轮勾选只管显示出来的图。5. 想交给模型选,就打开面板底栏的**自动选图**。勾上每轮都要发的图,比如一直要对照的参考图;其余的由模型需要时自己取回。关掉开关,你原来的勾选原样回来。+### 在 Claude 桌面版里++1. 在 Code 标签页的会话里输入 `/cam` 并发送,面板就在 Claude 桌面版自带的浏览器里打开,就在对话旁边。如果 `/cam` 是新会话的第一条消息,输入框可能提示命令不存在:照样发出去就行。Claude 桌面版在你发出第一条消息时才启动会话,插件这时才加上 `/cam`。+2. 之后的用法和 Codex 一样:取消勾选、重新勾上、按“需要 IMG-xxx”找图、筛选,或者打开**自动选图**。改动从下一条消息起生效。+3. 开着自动选图时,模型调用 `cam_view_image` 不会弹权限确认;你自己的 Claude Code 设置或钩子另有规定时,照它们的来。++用不了自带浏览器时(比如在终端里),`/cam` 会弹出一个小面板,给出面板的链接。+## 卸载+### Codex+先停用,再移除:在面板里点**停用插件**,在**插件**页面移除插件,然后重启 Codex。也可以运行卸载命令。它会恢复直连并移除插件,插件文件已经删掉时也能用:@@ -100,39 +133,45 @@ curl -fsSL https://github.com/chipfighter/codex-attachment-manager/releases/lateWindows(PowerShell):```powershell-irm https://github.com/chipfighter/codex-attachment-manager/releases/latest/download/uninstall.ps1 | iex+irm https://github.com/chipfighter/context-attachment-manager/releases/latest/download/uninstall.ps1 | iex```macOS、Linux:```bash-curl -fsSL https://github.com/chipfighter/codex-attachment-manager/releases/latest/download/uninstall.sh | sh+curl -fsSL https://github.com/chipfighter/context-attachment-manager/releases/latest/download/uninstall.sh | sh```-勾选记录和日志留在数据目录里(见[隐私](#隐私)),不需要可以删掉。-**Codex 连不上时**:如果 Codex 的报错里带着 `localhost:17891`(比如没先停用就移除了插件),运行上面的卸载命令,再重启 Codex。macOS、Linux 上,插件被移除或关掉后,引擎也会自己恢复直连,下次启动 Codex 时生效。+### Claude 桌面版++在 Code 标签页里点 **+** → **插件** → **管理插件** 卸载,或者运行 `claude plugin uninstall codex-attachment-manager@codex-attachment-manager`。之后新建的会话直接连接,不用恢复什么。++勾选记录和日志留在数据目录里(见[隐私](#隐私)),不需要可以删掉。+## 一点补充-- 只管理图片,因为只有图片会原样发给模型。Codex 不发送 PDF 和视频文件本身,只发送模型从中提取的文字或转成的图片,这些图片会和其他图一起列出来。音频要等 Codex 上有能直接听音频的模型:在那之前,Codex 会在发送前把音频换成一句说明。+- 只管理图片,因为只有图片会原样发给模型。Codex 不发送 PDF 和视频文件本身,只发送模型从中提取的文字或转成的图片,这些图片会和其他图一起列出来。音频要等有能直接听音频的模型:在那之前,Codex 会在发送前把音频换成一句说明。- Codex 自带生图工具的结果不能取消。- 开着自动选图时,模型每取一张图,这一轮就多一次请求。小模型读取回的图可能读错小细节:测试里 GPT-6 Luna(低推理强度)偶尔会读错,用 Codex 自带的看图打开同一张图也一样;GPT-6 Sol 和 Astra 读得对。细节要紧的图可以固定发送,或者换用更大的模型。-- 取消勾选时,如果这一轮还在进行,并且走的是 WebSocket,这一轮剩下的请求仍会带着原图。面板会提示,从下一条消息起生效。-- 启用、停用和升级,都要重启 Codex 才生效。+- **2026 年 8 月 31 日及以后注册的 Claude 账号**,会核对模型之前的思考记录和它前面的对话是否一致。在这样的账号上省略一张图时,引擎会一起去掉和实际发出的对话对不上的那部分旧思考,所以模型可能要重新思考、多用一些 token,面板每次都会提示。改动之后新产生的思考会保留;把图勾回来,之前的思考也会放回去。更早注册的账号不受影响。+- 在 Claude Code 里只管理主对话,子代理的历史保持原样。改用了别的 API 地址或云服务(Bedrock、Vertex、Foundry)的会话不接管。+- 取消勾选时,如果 Codex 这一轮还在进行,并且走的是 WebSocket,这一轮剩下的请求仍会带着原图。面板会提示,从下一条消息起生效。+- 在 Codex 里,启用、停用和升级都要重启 Codex 才生效。在 Claude 桌面版里,新版本从新建的会话起生效;升级先运行 `claude plugin marketplace update codex-attachment-manager`,再运行 `claude plugin update codex-attachment-manager@codex-attachment-manager`。- 切换 Codex 的界面语言后,面板立刻跟着换,给模型的说明从下一条消息起换;侧边面板里标签页的名字要重启 Codex 才换。- Codex 刚启动时,引擎可能会重启几次,偶尔会看到一次“正在重新连接”。- 引擎沿用系统代理:Windows 读系统设置;macOS 只支持 HTTP(S) 代理,不支持 PAC 和 SOCKS;Linux 读 `HTTPS_PROXY` 等环境变量。## 隐私-- 所有数据只留在本机的数据目录:Windows 是 `%USERPROFILE%\.codex-attachment-manager`,macOS 是 `~/Library/Application Support/codex-attachment-manager`,Linux 是 `~/.local/share/codex-attachment-manager`。里面有勾选记录、请求统计(只记大小和数量,不记内容)、日志(不记对话内容和凭据),以及 `config.toml` 的备份。-- 除了 Codex 本来就要发给 OpenAI 的请求,插件不向任何地方发送数据。-- Codex 的原始对话记录只读,不修改。+- 所有数据只留在本机的数据目录:Windows 是 `%USERPROFILE%\.codex-attachment-manager`,macOS 是 `~/Library/Application Support/codex-attachment-manager`,Linux 是 `~/.local/share/codex-attachment-manager`。里面有勾选记录、请求统计(只记大小和数量,不记内容)、引擎用来判断哪些思考还对得上的哈希(不记内容)、日志(不记对话内容和凭据),以及 `config.toml` 的备份。+- 除了 Codex 和 Claude Code 本来就要发给 OpenAI、Anthropic 的请求,插件不向任何地方发送数据。+- Codex 和 Claude Code 的原始对话记录只读,不修改。## 开发-- `plugin/` 是插件本体:MCP 服务、引擎、面板和 `cam` 命令行,运行代码在 `plugin/src`。`spike/` 是测试和实验脚本,`scripts/` 是一行命令用的安装、卸载脚本,`docs/` 是规格和技术方案,从 [docs/spec.md](docs/spec.md) 读起;v0.1 的开发记录在 `docs/history/v0.1/`。+- `plugin/` 是插件本体:MCP 服务、引擎、面板和 `cam` 命令行,运行代码在 `plugin/src`。Claude 插件是 `.claude-plugin/` 加上 `hooks/` 里的 Mod。`spike/` 是测试和实验脚本,`scripts/` 是一行命令用的安装、卸载脚本,`docs/` 是规格和技术方案,从 [docs/spec.md](docs/spec.md) 读起;v0.1 的开发记录在 `docs/history/v0.1/`。- 从源码装进自己的 Codex:先退出 Codex,在仓库里运行 `cam install`(macOS、Linux 上是 `./cam install`),再启动 Codex。`cam status` 查看安装状态,`cam uninstall` 卸载。- 运行测试(需要 Node 24 及以上):`cd spike && node --test`。CI 在 Windows、macOS、Linux 上跑全部单元测试,再用 Codex 的命令行装一遍插件,跑一遍安装和卸载脚本。- 不开 Codex 调面板:运行 `node spike/scripts/panel-dev.ts`,然后打开 `http://127.0.0.1:17895/?solo=1`。页面用合成的测试图和一个临时的 Codex 目录,不读取、不修改你的真实数据。diff --git a/docs/design.md b/docs/design.mdindex a115240..4ae9f3f 100644--- a/docs/design.md+++ b/docs/design.md@@ -1,7 +1,7 @@# 技术方案> 目标、约束和验收标准以 [spec.md](spec.md) 为准。本文件说明现在是怎么实现的、为什么这样做。-> 文中“已查证”的 Codex 行为,都针对桌面版 26.924(自带命令行 0.158),标着 v0.3 的针对 26.930(自带命令行 0.160);Codex 更新后可能变化。第 12 节的 Claude 行为(v0.4,开发中,未发布)针对 Claude 桌面应用 2.31226,自带 Claude Code 2.1.293。+> 文中“已查证”的 Codex 行为,都针对桌面版 26.924(自带命令行 0.158),标着 v0.3 的针对 26.930(自带命令行 0.160);Codex 更新后可能变化。第 12 节的 Claude 行为(v0.4)针对 Claude 桌面应用 2.31226,自带 Claude Code 2.1.293;思考记录部分在 Claude Code 2.1.295 上查证。> v0.1 开发过程中的调研和排错经过,归档在 [history/v0.1/](history/v0.1/),其中 plan.md 是当时逐步写成的完整方案。## 1. 总体结构@@ -27,6 +27,7 @@| 其他 | `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) | `claude-index.ts`、`claude-rewrite.ts` | 从 Claude Code 的会话记录找图、编号;改写 Anthropic Messages 请求 |+| Claude 思考记录(v0.4) | `claude-thinking.ts` | 账号校验思考记录时,去掉和实际发出的历史对不上的思考 || 面板页(v0.4) | `panel-web.js` | 引擎把 `panel.html` 作为网页提供时,代替 MCP 应用的宿主 |引擎和插件服务之间只通过数据目录里的文件共享状态,任何一方不在,另一方都照常工作。@@ -208,7 +209,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,开发中,未发布)+## 12. Claude Code 接入(v0.4)方案、关卡和任务见 [v0.4/plan.md](v0.4/plan.md)。做法是把上面的机制逐块移植,这里写对应的做法和平台逼迫的改动。@@ -226,8 +227,14 @@- **改写**(`claude-rewrite.ts`、`proxy.ts`):- 只改 `/v1/messages`:用户消息里和工具结果里的图换成占位符,文字和 Codex 版相同。- 说明是 `role: "system"` 消息,放在第一张被省略的图所在的那条消息之后;那里已经有系统消息时,并进去。每条含被省略图片的消息后面都跟一条简短说明(`rewrite.ts` 里的 `here`),从后往前插,勾选不变时位置不变。- - 思考块原样转发。账号拒绝改过的历史(400,`thinkingRejected`)时,改发原始请求,统计里记下 `fallback`,面板提示。`CAM_EXPERIMENT_BLOCK_BINDING=error` 让老账号也按新账号的方式校验,只用于实验。- 面板的“上一次请求”只记带工具的主对话请求。桌面版还会在会话里发附带请求(用户离开时的状态摘要、自动模式的安全检查):照样改写,但不记进这一行。+- **思考记录**(`claude-thinking.ts`、`proxy.ts`):+ - Anthropic 给每段思考记下它前面的内容(系统提示、工具、消息),之后对不上就失效:2026-08-31 起注册的账号直接拒绝(400,`thinkingRejected`),更早的账号放行。思考可以去掉,只要留下的每一段前面都和它产生时一样。+ - 引擎第一次给一个会话发出改过的历史后,记下每个请求“Claude Code 给的历史”对应“实际发出的内容”(两条哈希链,存在数据目录的 `claude/thinking/<会话 id>.json`,只有哈希)。之后的请求里,一段思考前面要发的内容和它产生时发出的一样,才保留;查不到的算不知道,去掉。比较的是值,不看 JSON 写法、键的顺序和缓存断点,字符串内容等于同样文字的文本块(Claude Code 把末尾的系统消息在它是最后一条时写成带缓存断点的文本块,之后写成字符串)。+ - 发送顺序:还不知道账号校验时,先发带全部思考的改写;被拒后,发去掉对不上的思考的改写,并记下这个会话的账号会校验,之后直接这样发;记录说都对得上却仍被拒,说明记录不全,清空重记,改发不带任何思考的改写(总会被接受);最后才是原始请求。全部勾回后也照这个顺序:取消期间产生的思考对不上原样的历史。+ - 去掉了思考时,统计里记下去掉了几段,面板照实提示(Anthropic 文档要求代理不要藏起来);改发原始请求时记下 `fallback`,面板提示这次没能按勾选改写。+ - `CAM_EXPERIMENT_BLOCK_BINDING=error` 让老账号也按新账号的方式校验,只用于实验。+ - 没用 Anthropic 的 `drop_block`(让服务端丢掉对不上的思考,实测它也保留之后新产生的思考):正式请求要带 beta 请求头,有些思考设置下不能用。用户 2026-10-11 选定由引擎自己去掉。- **面板**(`proxy.ts`、`panel-web.js`、Mod):- Claude Code 不登记只给应用用的工具,所以用户打不开插件的 MCP 应用;Mod 面板只能画 Claude 自带的元素,也放不进网页。于是由引擎在 `/__cam/panel?session=<id>` 提供 `panel.html`,前面加一段 `panel-web.js` 代替 MCP 应用的宿主:把面板的工具调用转成引擎的本机接口 `/__cam/claude/panel`、`select`、`image`。- 页面和接口只接受用本机名字(`localhost`、`127.0.0.1`、`[::1]`)访问、不带其他网站 Origin 的请求;接口还要带 `x-cam-panel` 请求头;页面带严格的 CSP。@@ -235,14 +242,14 @@- 小面板上的图片数,在打开时、每轮结束后,以及 `/clear`、`/resume` 之后重新读取。- 页面语言跟着引擎(`CAM_LANG` 或系统语言),不看浏览器。- **取图工具**:插件服务以 `CAM_HOST=claude` 运行,只给模型 `cam_view_image`。Mod 把调用它的会话 id 补进参数(插件服务可能比 `/clear`、`/resume` 活得久),并在 `classic.PreToolUse` 里放行这一个工具:先让下面的钩子和设置判断,它们拒绝或要求询问时照旧。-- **数据目录**:Claude 会话的勾选在 `claude/selection/`,请求统计在 `claude/requests/`,和 Codex 的分开。+- **数据目录**:Claude 会话的勾选在 `claude/selection/`,请求统计在 `claude/requests/`,思考记录的哈希在 `claude/thinking/`,和 Codex 的分开。- **安装**:- 仓库根目录同时是 Claude 插件市场(`.claude-plugin/marketplace.json` 指向仓库根目录),清单是 `.claude-plugin/plugin.json`:同一个 MCP 服务(`plugin/scripts/launch`,`CAM_HOST=claude`),另加 Mod(`hooks/hooks.json`)。- - 用户运行 `claude plugin marketplace add chipfighter/codex-attachment-manager` 和 `claude plugin install codex-attachment-manager@codex-attachment-manager`。装好的插件按版本缓存,代码改了要升版本才会重新安装。+ - 用户运行 `claude plugin marketplace add chipfighter/context-attachment-manager` 和 `claude plugin install codex-attachment-manager@codex-attachment-manager`。装好的插件按版本缓存,代码改了要升版本才会重新安装。- Claude 桌面不带 Node。没装 Codex 时,启动脚本用 PATH 上 24 以上的 `node`,找不到就提示安装 Node 24。- **测试**:单元测试同第 10 节(`claude-*.test.ts`)。Mod 的界面和钩子用 Claude Code 自带的测试工具(`claude plugin test`)测。模型测试用真实的 Claude 桌面订阅会话,按 v0.4/plan.md 的约定用 Haiku 5.5,中英文都测。- **依赖的 Claude 行为**(都不是公开接口,Claude 更新后要重新验证):- 会话记录的格式:`parentUuid`、`turnPosition`、压缩分界、并行工具结果的挂法;请求头 `x-claude-code-session-id`。- 桌面版启动会话的方式:启动时传入 `ANTHROPIC_BASE_URL`;新会话要到第一条输入才启动进程,所以 `/cam` 在那之前不在输入框的命令列表里。- `Claude_Browser` 浏览器工具;Mod 面板里的链接交给系统浏览器;桌面版在会话里发的附带请求。- - 思考记录的前缀校验:替换历史里的一张图,之后的思考块就对不上了;2026-08-31 以后注册的账号直接拒绝。+ - 思考记录的前缀校验:替换历史里的一张图,之后的思考块就对不上了;2026-08-31 以后注册的账号直接拒绝。比较时不看 JSON 写法和键的顺序;去掉开头或末尾的思考可以,去掉中间的会让后面的失效,把去掉过的放回去,会让它不在期间产生的失效。diff --git a/docs/spec.md b/docs/spec.mdindex 2b067ec..2750c02 100644--- a/docs/spec.md+++ b/docs/spec.md@@ -1,13 +1,13 @@-# 规格:Codex Attachment Manager(上下文素材管理器)+# 规格:Context Attachment Manager(上下文素材管理器)-> 本文件是目标、范围、约束和验收标准的唯一事实来源(2026-09-24 经用户、Claude、Codex 三方确认),描述当前版本 v0.3.0,以后随版本更新。v0.4(Claude 桌面 Code 接入)正在开发、尚未发布,相关内容都标着“v0.4”;它的关卡、任务和验收步骤见 [v0.4/](v0.4/)。+> 本文件是目标、范围、约束和验收标准的唯一事实来源(2026-09-24 经用户、Claude、Codex 三方确认),描述当前版本 v0.4.0,以后随版本更新。v0.4 加的 Claude 桌面 Code 接入,相关内容都标着“v0.4”;它的关卡、任务和验收步骤见 [v0.4/](v0.4/)。项目 2026-10-11 由 Codex Attachment Manager 改名,因为不再只给 Codex 用(用户定);安装用的标识(`codex-attachment-manager`)和数据目录不变,已装的用户照常升级。> 技术方案见 [design.md](design.md)。v0.1 的开发记录(原方案、任务记录、各阶段报告、最初的构想)归档在 [history/v0.1/](history/v0.1/),只作参考。## 1. 目标做一个开源工具,把某个 Codex 任务里出现过的素材按时间顺序列出来,让用户逐轮决定下一轮让模型看哪些。原始文件和聊天记录都留在本地、保持不变;取消勾选只影响之后发送的内容,不删除任何东西。-v0.4(开发中,未发布):同样的管理也用在 Claude 桌面应用的 Code 标签页里(本地会话、官方订阅登录)。做法是把现有插件的机制逐块移植过去,不另起架构、不削减功能,只在平台逼迫的地方改(用户 2026-10-10 定)。和 Codex 不同的地方见下面“Claude Code(v0.4)”一节。+v0.4:同样的管理也用在 Claude 桌面应用的 Code 标签页里(本地会话、官方订阅登录)。做法是把现有插件的机制逐块移植过去,不另起架构、不削减功能,只在平台逼迫的地方改(用户 2026-10-10 定)。和 Codex 不同的地方见下面“Claude Code(v0.4)”一节。### 用户场景@@ -111,18 +111,21 @@ v0.4(开发中,未发布):同样的管理也用在 Claude 桌面应用- 面板跟随 Codex 的界面语言;Codex 没告诉面板时,看系统语言。- 标签页标题和发给模型的说明也跟随 Codex 的界面语言,从装好起就对,不用先打开面板;切换语言后,发给模型的说明从下一条消息起就换,标签页标题要重启 Codex 才换(用户 2026-09-26 定:直接读 Codex 自己记下的语言设置,不改成默认英文)。- v0.1 支持简体中文和英文:任何地区的中文都显示简体中文,其他语言都显示英文。以后有用户反馈再加其他语言。- - Codex 自己显示的名字:插件页上名称和一句话简介用英文(Codex Attachment Manager),详细说明先英文、再附一段中文,因为插件清单只能写一种文字;标签页标题跟着语言(“上下文素材”或 Context Assets)。+ - Codex 自己显示的名字:插件页上名称和一句话简介用英文(Context Attachment Manager),详细说明先英文、再附一段中文,因为插件清单只能写一种文字;标签页标题跟着语言(“上下文素材”或 Context Assets)。- 安装命令在终端里的输出,按系统语言。- 以上是用户 2026-09-24 定的 MVP,外加 2026-09-25 要求补上的发送预览、改写失败提示、自动刷新、这两个按钮的位置和名称、标题里的任务名、新任务的自动绑定,以及中英文界面;2026-09-26 加了“模型需要”提示条、整轮勾选,以及直接读 Codex 的语言设置;v0.2 加了 PDF 页面、网页截图两类来源和按来源筛选(用户 2026-09-29 定);v0.3 加了自动选图(用户 2026-10-06 定)。### Claude Code(v0.4)-开发中,尚未发布。这里只写和 Codex 不同的地方;编号、内容相同、勾选、占位符和自动选图的规则照搬。+这里只写和 Codex 不同的地方;编号、内容相同、勾选、占位符和自动选图的规则照搬。- **范围**:Claude 桌面应用 Code 标签页里的本地会话,官方订阅登录,不需要 API key。Claude Code 的会话就相当于 Codex 的任务,每个会话各有一套勾选。已经改用别的服务地址,或者用第三方模型服务(Bedrock、Vertex、Foundry)的会话不接管。- **接入**:装上 Claude 插件就生效,不用手动配置。插件在会话启动时,把这个 Claude Code 进程的请求地址指向本机引擎,进程结束时还原。登录凭据原样转给 Anthropic。- **说明的位置**:Anthropic 不允许把系统消息放在用户消息之前,所以“上下文管理说明”放在第一张被省略的图所在的那条消息之后,是一条系统消息。另外,每条含被省略图片的消息后面都跟一条简短说明:这几张图当时是原图,之前的描述仍然有效;被问到要看图才能回答的细节时,写出“需要 IMG-xxx”,用户才知道该勾回哪张。Codex 的措辞不变。-- **思考记录**:思考块原样转发。改过的历史被 Anthropic 拒绝时(2026-08-31 以后注册的账号会这样),改发原始请求,面板提示这次没能按勾选改写,这一次也不算取消成功。+- **思考记录**(用户 2026-10-11 定):Anthropic 会核对每段思考前面的内容是否和它产生时一样。2026-08-31 起注册的账号对不上就拒绝请求,更早的账号放行。+ - 账号放行时,思考块原样转发,和 Codex 一样。+ - 账号拒绝时,引擎去掉和实际发出的历史对不上的思考记录,再按勾选发出:取消勾选照样生效,取消之后新产生的思考保留;全部勾回后,取消之前的思考放回去,取消期间产生的去掉。模型会少一些之前的思路,可能要重新思考、多用一些 token;面板提示这一次去掉了几段(Anthropic 文档要求代理不要把这件事藏起来)。+ - 还不行时才改发原始请求,面板提示这次没能按勾选改写,这一次也不算取消成功。对话不中断,也不会因为记录不全而卡住:记录不全时宁可多去掉思考。- **面板**:和 Codex 是同一个面板页面(用户 2026-10-10 要求两边一致)。Claude Code 不给用户打开插件的 MCP 应用,插件自己的小面板(Mod 面板)也放不进网页,所以面板由本机引擎作为网页提供:- 用户输入 `/cam`,面板在 Claude 桌面自带的浏览器里打开,就在对话旁边(用户 2026-10-10 选定)。- 只有两种情况才弹出插件的小面板:自带浏览器打不开时(终端、VS Code,或调用失败),给出面板链接和“复制链接”按钮;这个会话的请求没经过引擎、勾选不会生效时,提醒用户。@@ -163,13 +166,13 @@ v0.1 到 v0.3 都不做下面这些。其中音频和其他语言已确认是后- 真实数据不进仓库:从真实会话和用户素材里提取的图片、记录片段、日志和备份,只能放在本机,开发时放在 `local/` 目录(已被 git 忽略),装好的插件放在数据目录(Windows 是 `%USERPROFILE%\.codex-attachment-manager`,macOS 是 `~/Library/Application Support/codex-attachment-manager`,Linux 是 `~/.local/share/codex-attachment-manager`);任何时候都不提交。仓库里的样例数据只能是合成的或脱敏的。Windows 的数据目录 2026-09-25 从 `%LOCALAPPDATA%` 下挪出来(用户同意):Codex、Claude 这类微软商店应用启动的程序在 AppData 里新建的文件,会被转存到各应用的私有目录,插件服务、引擎和命令行看到的数据就不一样了。- 仓库里的文档和代码不写用户本机的具体路径(例如个人项目文件夹)。`~/.codex`、`%LOCALAPPDATA%` 这类通用位置可以写。本项目以后会开源。- 不改写原生任务的历史记录。-- 代理只替换用户取消的图片,连同 Codex 附在它前后的路径标签;自动选图开着时,还替换之前各轮没有固定发送的图(v0.3)。有图片被省略时,另外插入一条“上下文管理说明”开发者消息(用户 2026-09-25 要求告诉模型原因,见第 1 节“占位符”),并在仍发送的图前面加“已提供”标签(v0.1-25)。请求里的其他内容原样转发。v0.4:Claude 的请求里,说明是系统消息(位置见第 1 节“Claude Code(v0.4)”);思考块原样转发,不删除,也不关掉思考。+- 代理只替换用户取消的图片,连同 Codex 附在它前后的路径标签;自动选图开着时,还替换之前各轮没有固定发送的图(v0.3)。有图片被省略时,另外插入一条“上下文管理说明”开发者消息(用户 2026-09-25 要求告诉模型原因,见第 1 节“占位符”),并在仍发送的图前面加“已提供”标签(v0.1-25)。请求里的其他内容原样转发。v0.4:Claude 的请求里,说明是系统消息(位置见第 1 节“Claude Code(v0.4)”);思考块原样转发,只在账号拒绝时去掉对不上的那些,不关掉思考(用户 2026-10-11 定)。- 选择权在用户:默认只由用户在面板里勾选决定,工具和模型都不能自动勾选或取消;模型只能按约定索要(例如回复“需要 IMG-004”),给不给由用户决定。用户给某个任务打开“自动选图”后,之前各轮的图默认不发,由模型用取图工具按编号取回需要的图,只在这一轮有效;模型不能改用户的勾选,也不能替用户开关自动选图(v0.3,用户 2026-10-06 定,取代原来的“选择权永远在用户”)。- 先在 Windows 上开发和测试。技术栈:TypeScript/Node。macOS、Linux 由 CI 验证能装上、能启动;这两个平台桌面版上的实测,等用户在 GitHub 上反馈(用户 2026-09-25 定)。- 交付形态:Codex 插件。插件带一个本地 MCP 服务,负责拉起引擎、提供面板;仓库根目录就是插件市场。面板位置见第 1 节“界面”。- - 用户在 Codex 的插件页面添加插件市场 `chipfighter/codex-attachment-manager`、装上插件,再在面板里点“启用”;卸载前在面板里点“停用”。+ - 用户在 Codex 的插件页面添加插件市场 `chipfighter/context-attachment-manager`、装上插件,再在面板里点“启用”;卸载前在面板里点“停用”。- 也可以用发布附带的一行命令安装、卸载。开发时用仓库里的 `cam install` / `cam uninstall`。- - v0.4:同一个仓库也是 Claude 插件市场(`.claude-plugin/`)。Claude 插件带同一个 MCP 服务,另加一个 Mod,分别负责切换请求地址和 `/cam`。用户用 `claude plugin marketplace add chipfighter/codex-attachment-manager`、`claude plugin install codex-attachment-manager@codex-attachment-manager` 安装。Claude 桌面不带 Node,没装 Codex 时需要 Node 24 或更新版本(用户 2026-10-10 定:在说明里写明,不自动下载)。+ - v0.4:同一个仓库也是 Claude 插件市场(`.claude-plugin/`)。Claude 插件带同一个 MCP 服务,另加一个 Mod,分别负责切换请求地址和 `/cam`。用户用 `claude plugin marketplace add chipfighter/context-attachment-manager`、`claude plugin install codex-attachment-manager@codex-attachment-manager` 安装;Claude 桌面目前只能装已登记的插件市场里的插件,所以登记插件市场这一步要用命令行,装插件也可以在 Code 标签页里做(**+** → 插件 → 添加插件)。Claude 桌面不带 Node,没装 Codex 时需要 Node 24 或更新版本(用户 2026-10-10 定:在说明里写明,不自动下载)。- 许可证:MIT(用户 2026-09-25 确定)。## 4. 验收标准@@ -210,7 +213,7 @@ v0.1 之前的阶段验收(阶段 0 的重建路线、代理路线 P2)都已5. 面板按第 1 节“界面”里自动选图的写法显示:开关、“固定发送”的勾选、“最近一轮模型取回”提示条和行标签、发送预览;取回的副本不另占一行。6. 删减图片不诱发模型幻觉:模型不收回之前看着原图做出的回答,也不编造没看到的细节(同 v0.1 第 8 条)。-### v0.4(开发中)+### v0.4> 用户 2026-10-10 确认的方案。每条的检查步骤和证据要求见 [v0.4/acceptance.md](v0.4/acceptance.md)。@@ -219,7 +222,7 @@ v0.1 之前的阶段验收(阶段 0 的重建路线、代理路线 P2)都已3. 同一个会话里逐轮取消、恢复,从下一条消息起生效;原始会话记录只读。4. 删减图片不诱发模型幻觉:不收回看着原图做出的回答,不编造没看到的细节,需要时按编号要图。用真实的 Claude 订阅模型,中英文都测。5. 自动选图:需要看图时用取图工具取回,之前说过的内容够用时不取;取回的副本只在那一轮提供。-6. 改写被拒时,原样发送并在面板提示,对话不中断。+6. 账号拒绝改过历史之后的思考时,去掉对不上的思考记录后照样按勾选发出,取消之后新产生的思考保留,面板提示去掉了几段;还不行时原样发送并提示。对话不中断,全部勾回后也正常。用模拟的新账号(`prefix_mismatch_behavior: "error"`)实测。7. Codex 的功能没有退化。## 5. 待定问题@@ -228,4 +231,3 @@ v0.1 之前的阶段验收(阶段 0 的重建路线、代理路线 P2)都已- macOS、Linux 上,引擎会发现这一点,把 Codex 恢复直连,下次启动 Codex 时生效。- Windows 上,引擎随插件服务一起被结束(Codex 的 Job 限制,见 [design.md](design.md) 第 5 节),Codex 会连不上,要运行卸载命令恢复。面板、插件说明和 README 都提示“先停用再移除”。- 要不要让引擎不依赖插件启动(例如用 Windows 计划任务),需要用户同意在系统里注册任务,之后再定。-- v0.4:2026-08-31 以后注册的 Claude 账号会拒绝改过的历史(思考记录的校验),引擎只能改发原始请求。所以在这类账号上,取消勾选基本不会生效(面板会如实提示)。要不要另想办法,用户之后再定(2026-10-10)。diff --git a/docs/v0.4/acceptance.md b/docs/v0.4/acceptance.mdindex 266bfbe..9d6b5c4 100644--- a/docs/v0.4/acceptance.md+++ b/docs/v0.4/acceptance.md@@ -1,6 +1,6 @@# v0.4 验收标准-> 状态:待执行的增量验收。方案见 [plan.md](plan.md),执行见 [tasks.md](tasks.md)。现行 v0.3 行为引用 [spec.md](../spec.md),不另定义一套行为。+> 状态:v0.4.0 发布时的验收记录见文末(2026-10-11)。方案见 [plan.md](plan.md),执行见 [tasks.md](tasks.md)。现行 v0.3 行为引用 [spec.md](../spec.md),不另定义一套行为。> 必须区分:本机模拟、终端、真实桌面订阅、用户界面确认。前者通过不能自动替代后者。## A04-01 官方订阅接入@@ -31,8 +31,8 @@**G04-1 前置子集**:模型用 Haiku 5.5,运行次数先与用户确认。在真实桌面订阅、正常使用的思考配置下,历史中确实已有思考块后执行 A04-03,并用最小工具取回实验覆盖工具图及取回副本下一轮省略;不要求先完成完整自动模式。-- 账号放行时,改写后的请求正常完成,模型按 A04-03 的要求回答。账号拒绝(400)时,包括用 `prefix_mismatch_behavior: "error"` 模拟的新账号,引擎原样重发、对话不断,面板提示这次没能按勾选改写,且不计入取消成功。记录真实模型、思考配置、账号表现及请求诊断。-- 引擎不删思考块、不加 `drop_block`、不关思考。若有必要取舍,记录影响与可复现证据,经用户确认并修改规格后再改验收;当前不默认接受。+- 账号放行时,改写后的请求正常完成,模型按 A04-03 的要求回答。账号拒绝(400)时,包括用 `prefix_mismatch_behavior: "error"` 模拟的新账号,引擎去掉对不上的思考记录、照样按勾选发出,取消之后新产生的思考保留,全部勾回后也被接受,面板提示去掉了几段;还不行时原样重发、对话不断,面板提示,且不计入取消成功。记录真实模型、思考配置、账号表现及请求诊断。+- 引擎不关思考、不加 `drop_block`,只去掉对不上的思考块(用户 2026-10-11 看过实验证据后定,见 plan.md D04-03)。- 未修改图片的文本往返、没有实际思考块的测试不能证明兼容;用户账号放行之外,必须再测一次模拟新账号的拒绝路径。官方文档不能替代桌面订阅实测。**正式模型行为验收**:T04-05 覆盖手动模式,T04-08 覆盖完整自动模式。模型不收回之前看原图的有效描述,不补充现在看不到的新细节;手动按编号要图、恢复后能看图;自动模式该取图时取,不需要时不取。专项自测覆盖中英文,模型范围与成本上限先确定;Codex 的 GPT 自测不能代替它。@@ -94,7 +94,15 @@ Windows 优先。macOS/Linux 的 CI 与桌面实测分别记录,不将“CI| 项目 | 状态 | 说明 || --- | --- | --- || A04-01 实验入口部分 | 已通过 | T04-00;真实桌面官方订阅透明转发与恢复命令 |-| A04-01 正式交付部分 | 待执行 | 免配置安装、自动启动和正式恢复未完成 |-| A04-02–A04-12 | 待执行 | 模拟探针的测试不替代正式功能验收 |+| A04-01 正式交付部分 | 已通过(开发副本) | 装上即接管、会话结束还原,在开发副本的桌面会话里实测;从 GitHub 装的正式副本已装到用户本机,等用户在桌面会话里实测 |+| A04-02、A04-03 | 已通过 | 单元测试和桌面会话:无勾选变化原样转发,取消、恢复从下一条消息起生效 |+| A04-04 | 已通过 | Haiku 5.5 中英文各 3 次(2026-10-10);模拟新账号:去掉对不上的思考后按勾选发出,新思考保留,勾回后正常(2026-10-11,见 plan.md 2.1) |+| A04-05 | 已通过 | 单元测试;桌面会话里编号、轮次、来源与重复关系正确 |+| A04-06、A04-07 | 已通过 | `/cam` 在桌面自带的浏览器里打开,和 Codex 同一个面板;用户 2026-10-10 实测确认 |+| A04-08 | 已通过 | 该取时取、不该取时英文都不取,中文有 1 次多取(用户同意先不调) |+| A04-09 | 已通过 | 只读会话记录;日志和思考记录只存元数据和哈希 |+| A04-10 | 部分 | 两会话隔离、续聊、引擎重启已测;分叉、压缩、回退、子代理、卸载重载、桌面重启、登录刷新待用户实测 |+| A04-11 | 已通过 | 全部单元测试、CI 三平台、`cam install` 与健康检查;引擎改动后跑 Codex 自测(见 tasks.md T04-10) |+| A04-12 | 发布时更新 | 2026-10-11 用户授权不等审核直接发布,之后自己验收 |关卡失败时记录“未通过”及原因,不用“部分可用”覆盖用户要求的完整目标。diff --git a/docs/v0.4/plan.md b/docs/v0.4/plan.mdindex 2a5eff5..697dc5f 100644--- a/docs/v0.4/plan.md+++ b/docs/v0.4/plan.md@@ -1,6 +1,6 @@# v0.4 变更方案:Claude 桌面 Code 接入-> 状态:开发提案,正式功能尚未实现。2026-10-09 按用户要求整理;2026-10-10 用户确认:按现有插件的机制逐块移植,只在平台逼迫时改动(见第 1 节)。+> 状态:随 v0.4.0 发布(2026-10-11)。2026-10-09 按用户要求整理;2026-10-10 用户确认:按现有插件的机制逐块移植,只在平台逼迫时改动(见第 1 节);2026-10-11 用户定:新账号校验思考记录时,由引擎去掉对不上的思考(D04-03),并授权不等审核直接发布。> 当前版本的唯一规格仍是 [spec.md](../spec.md),现有实现见 [design.md](../design.md)。本目录记录 v0.4 的增量变更、关卡和开发任务,不另复制一套现行规格。> 执行顺序:本方案 → [任务清单](tasks.md) → [验收标准](acceptance.md)。每个任务都要有对应验收和证据;通过路由实验不等于通过完整迁移。@@ -23,7 +23,7 @@ v0.4 按现行 v0.3 的图片管理语义验收:稳定编号、每次出现独| 占位符、重复占位符、“已提供”标签;勾选不变时逐字节相同 | 照搬(D04-03) || “上下文管理说明”开发者消息,插在第一张被省略的图所在那一轮的用户消息之前 | 平台逼迫:改用 `role: "system"` 消息,放在那条用户消息之后(D04-03) || WebSocket 握手回 426,让 Codex 改走 HTTP | 不需要:Claude Code 本来就走 HTTP 和 SSE |-| 改写不了就原样发送,面板提示原因 | 照搬;思考签名被拒时也按这条处理(D04-03) |+| 改写不了就原样发送,面板提示原因 | 照搬;账号拒绝改过历史之后的思考时,先去掉对不上的思考记录、照样按勾选发送,还不行才原样发送(D04-03) || 面板是 MCP 应用,用户自己打开,不经过模型 | 平台逼迫:用户打不开插件的 MCP 应用,Mod 面板放不进网页。同一份 `panel.html` 改由引擎作为本机页面提供,用户输入 `/cam` 后在 Claude 桌面自带的浏览器里打开,仍不经过模型(D04-04) || 自动选图:`cam_view_image` 按编号取图,取回的图放在本轮末尾,副本下一轮换成说明 | 照搬,取图工具由同一个 MCP 服务提供(D04-05) |@@ -43,6 +43,11 @@ v0.4 按现行 v0.3 的图片管理语义验收:稳定编号、每次出现独- 面板(2026-10-10 桌面实测):Mod 面板只能画 Claude 自带的元素,放不进网页;Claude Code 不登记只给应用调用的工具,用户打不开插件的 MCP 应用。Mod 面板里的链接,点开交给系统默认浏览器。Mod 用 `$.mcp.call("Claude_Browser", "preview_start", { url })` 能在桌面自带的浏览器里打开本机页面,默认权限模式下也不弹确认;这是桌面版给模型用的工具,不是公开给插件的接口,终端和 VS Code 里没有。- 桌面版的新会话,发出第一条输入时才启动 Claude Code 进程。Mod 注册的命令在那之前不在输入框的命令列表里:输入时提示命令不存在,发出后照常执行。插件自带的命令文件一律带插件名前缀(`/codex-attachment-manager:cam`)。- 图片与思考(2026-10-10,T04-01,Haiku 5.5,推理强度 low,桌面订阅会话,工具查看的图,中英各 3 次):用户自己的账号接受改过的历史连同思考记录(全部 200)。全部省略后,模型不收回之前的描述、不猜新细节、不自己重读文件,勾回后看图答对;逐条说明写明何时写“需要 IMG-xxx”后,中英都 3/3 按编号要图。模拟新账号(`CAM_EXPERIMENT_BLOCK_BINDING=error`)时,改写后的请求得到 400,引擎改发原始请求得到 200,对话不断,面板提示。自动选图:需要看图时都用 `cam_view_image` 取回并答对;不需要时,中文有 1 次多取,英文都不取;取回的副本下一轮换回说明。+- 新账号的思考校验(2026-10-10 至 11,Claude Code 2.1.295,Haiku 5.5,推理强度 high 和 max,模拟新账号):+ - 引擎去掉对不上的思考(D04-03 现行做法):取消勾选后的第一个请求被拒,去掉 1 段对不上的思考后重发成功,之后同一会话直接这样发、不再被拒;取消之后新产生的思考在后面的请求里保留并被接受;全部勾回后,取消之前的思考放回去、取消期间产生的去掉,被接受。回答全部正确。面板提示去掉了几段(最终实测截图在验证机的 `local/v04/shots/`)。+ - 实验中发现并修好两个问题:比较历史时把字符串内容和同样文字的文本块当成不同(Claude Code 的末尾系统消息就是这样变的),多去掉了本该保留的思考;记录不全时(换了哈希写法)把取消期间产生的思考当成对得上,请求被拒,最后的原样请求在真正的新账号上也会被拒,会话会卡住。现在记录不全时宁可多去掉。旧做法(被拒就原样发送)也有这个卡住的问题:新账号上改过的请求成功过一次,之后全部勾回,原样请求就被拒。+ - 对照组 `drop_block`(服务端丢掉对不上的思考):只丢对不上的那段,之后新产生的思考保留。效果和引擎自己去掉相同,但要在正式请求里带 beta 请求头,有些思考设置下不能用,没采用。+ - 代价:丢掉旧思路后模型要重新想。同一个追问,旧思考在时用 29 个思考 token,被去掉后用 2,422 个;推理强度 low 时模型很少在看图之后思考,这个问题很少触发。- 并行调用工具时,Claude Code 把除最后一个以外的结果挂在各自的调用记录下面,不在沿父记录回溯出的链上(2026-10-10 在测试中发现并修复)。- 安装(2026-10-10,在隔离的配置目录里):从仓库导出的插件市场添加、安装到用户范围后,插件服务能起来;用 Codex 带的 Node,或只有系统的 Node 24,都能运行。@@ -53,7 +58,7 @@ v0.4 按现行 v0.3 的图片管理语义验收:稳定编号、每次出现独2026-10-09 查官方文档(链接见第 8 节)和桌面自带 Claude Code 2.1.293 的 Mod 类型定义。文档说的是 API 行为,订阅链路的实际表现以实测为准。- 桌面启动的环境变量过滤,与 Mod 运行时设置是不同入口;正式生命周期是否一直保持有效,不能从一次文本请求推断。-- **思考签名**:Fable 5.1、Opus 5.5、Sonnet 5.5、Haiku 5.5 做前缀校验。替换历史里的一张图、缩短一个工具结果,或增删 `tools` 里的工具,都会让之后所有的思考块失效。2026-08-31 起注册的账号默认返回 400;更早的账号照样校验,但放行给模型。加 beta 头 `thinking-binding-controls-2026-08-01` 并设 `thinking.block_binding.prefix_mismatch_behavior: "error"`,老账号也按新账号拒绝,可用于实验;只加 beta 头、不设该字段,响应会列出放行的失效块。文档明说代理自己的改写也算编辑。服务端上下文编辑只能按规则清掉最早的工具结果,不能指定某张图,也碰不到用户消息里的图。2026-10-10 实测(见 2.1):订阅链路接受该 beta 头;400 由引擎接住、改发原始请求,Claude Code 看不到;用户自己的账号是放行的那种。+- **思考签名**:Fable 5.1、Opus 5.5、Sonnet 5.5、Haiku 5.5 做前缀校验。替换历史里的一张图、缩短一个工具结果,或增删 `tools` 里的工具,都会让之后所有的思考块失效。2026-08-31 起注册的账号默认返回 400;更早的账号照样校验,但放行给模型。加 beta 头 `thinking-binding-controls-2026-08-01` 并设 `thinking.block_binding.prefix_mismatch_behavior: "error"`,老账号也按新账号拒绝,可用于实验;只加 beta 头、不设该字段,响应会列出放行的失效块。文档明说代理自己的改写也算编辑。服务端上下文编辑只能按规则清掉最早的工具结果,不能指定某张图,也碰不到用户消息里的图。2026-10-10 实测(见 2.1):订阅链路接受该 beta 头;400 由引擎接住,Claude Code 看不到;用户自己的账号是放行的那种。2026-10-11 查证:比较的是值,不看 JSON 写法和键的顺序;400 写明第一个失效的块和前面第一处不同的位置;去掉开头或末尾的思考可以,去掉中间的会让后面的失效,把去掉过的放回去,会让它不在期间产生的失效;文档要求代理去掉思考重试时不要藏起来。- **说明消息的位置**:对话中途可以放 `role: "system"` 消息,不需要 beta 头,但它必须紧跟在用户消息之后,后面是助手消息或已是最后一条。所以 Codex 的位置(那一轮用户消息之前)在 Claude 上不合法。2026-10-10 实测:订阅链路接受,效果见 2.1。- `turn.step` 只能改模型和推理强度,不是历史消息改写接口,不能替代请求改写引擎。@@ -95,7 +100,7 @@ v0.4 按现行 v0.3 的图片管理语义验收:稳定编号、每次出现独保留现行选择与占位语义,Claude 措辞需分别跑中英文模型验收。选择不变时输出稳定;自动取图不能反复修改前面的占位文本。-思考块按原机制原样转发:引擎不删思考块、不加 `drop_block`、不关思考。账号放行时效果与 Codex 相同;被拒(400)时按“改写不了就原样发送”处理,改发原始请求,面板提示这次没能按勾选改写,回退不计作取消成功。服务端上下文编辑不能指定某张图,不采用。要改变这一处理,先给出证据,由用户决定后再更新规格;不默认为用户接受功能降级。+思考块原样转发,不关思考。账号放行时效果与 Codex 相同。账号拒绝改过历史之后的思考时(2026-08-31 起注册的账号),引擎去掉和实际发出的历史对不上的思考记录,照样按勾选发出;之后新产生的思考保留;面板提示去掉了几段。这是用户 2026-10-11 看过实验证据(见 2.1)后选定的降级:模型少了被改位置之后的那部分旧思路。还不行时才按“改写不了就原样发送”处理,面板提示,这一次不计作取消成功。服务端上下文编辑不能指定某张图,`drop_block` 要在正式请求里带 beta 头,都不采用。做法见 design.md 第 12 节。### D04-04 面板与业务规则复用@@ -127,7 +132,7 @@ Codex 现有自测、安装和卸载保持可用;共享运行代码变化后| G04-1 核心可行性 | G04-0;T04-01 用 Haiku 5.5(用户 2026-10-10 定),运行次数在开始前与用户确认 | T04-02 面板实验(面板形式见 D04-04),T04-01 图片/思考闭环及最小取回副本实验 | A04-04 的前置子集及面板实验有实测证据;界面经用户反馈;没有未确认的降级 || G04-2 正式适配 | G04-1 通过,规格维护者将目标与采用方案写回现有文档 | T04-03–T04-07 | 手动模式与完整面板通过对应验收 || G04-3 自动模式 | 手动模式稳定;核心关卡覆盖取图副本 | T04-08 | 自动取图语义和模型行为通过 |-| G04-4 交付 | 前述功能通过 | T04-09–T04-11 | 全部验收、回归、安装检查通过,用户确认后再发布 |+| G04-4 交付 | 前述功能通过 | T04-09–T04-11 | 全部验收、回归、安装检查通过,用户确认后再发布(2026-10-11 用户授权不等审核直接发布,之后自己验收) |G04-1 任一核心能力失败时,不跳过关卡开发完整面板或宣称 v0.4 可用。先追溯原因、记录可行选项;涉及官方订阅、同会话连续性、桌面内交互或思考能力的取舍,由用户确认后更新规格。diff --git a/docs/v0.4/tasks.md b/docs/v0.4/tasks.mdindex f65e856..4debbe1 100644--- a/docs/v0.4/tasks.md+++ b/docs/v0.4/tasks.md@@ -5,7 +5,7 @@## 当前状态-2026-10-10:路由入口 T04-00 已完成;方案已按“现有机制逐块移植”改写(用户确认)。G04-1 尚未通过,正式运行代码尚未开发。下一步先做 T04-02(不用模型额度),再做 T04-01(Haiku 5.5);两者都通过后才能开始 G04-2。+2026-10-11:随 v0.4.0 发布,用户授权不等审核直接发布,之后自己验收。G04-0 到 G04-3 已通过,证据见 [plan.md](plan.md) 2.1。还没在桌面里实测的:分叉、压缩和回退(有单元测试)、子代理、卸载与重载、桌面重启、登录刷新,以及 macOS 和 Linux 的桌面版;这些在 T04-06、T04-09 里列着,等用户实测和反馈。## G04-0:路由入口@@ -16,7 +16,7 @@## G04-1:核心可行性-- [ ] **T04-01 历史图片取消/恢复与思考兼容**。依赖 T04-00。+- [x] **T04-01 历史图片取消/恢复与思考兼容**。依赖 T04-00。- 模型用 Haiku 5.5(用户 2026-10-10 定),思考用 Claude Code 的默认配置,先确认请求里确有思考块;运行次数在开始前与用户确认。- 用合成图 A、B 和一份重复出现,在同一桌面订阅会话中完成上传、看图、取消 A、继续对话、恢复 A、再继续;覆盖工具图片和实际出现过思考块的历史。- 确认本地出现记录与发出的图片块能够可靠对齐;同时检查被取消图确实未发、未取消图保留、恢复图回到应有位置。@@ -26,13 +26,13 @@- 关联:R04-02、R04-05;A04-02、A04-03、A04-04 的 G04-1 子集、A04-09。通过本任务不勾整项 A04-04。- 证据:本机脱敏请求差异、回应状态、只读检查、合成图的模型回答;失败时保存根因与选项。-- [ ] **T04-02 桌面内缩略图面板实验**。依赖 T04-00,可与 T04-01 并行。+- [x] **T04-02 桌面内缩略图面板实验**。依赖 T04-00,可与 T04-01 并行。- 面板形式见 plan.md 的 D04-04(用户 2026-10-10 定):同一份 `panel.html` 由引擎在本机提供,`/cam` 在 Claude 桌面自带的浏览器里打开。- 在真实 Code 中先显示一张、再显示多张合成图;验证缩略图、单张勾选、放大预览、保存和当前会话绑定,不通过模型执行操作。在外部浏览器打开同一页面只用于调试,不计桌面验收。- 关联:R04-04;A04-06。- 证据:Claude 自行检查截图;关键节点截图给用户,按现有规矩等待反馈。-- [ ] **T04-02a 核心关卡结论与规格同步**。依赖 T04-01、T04-02。+- [x] **T04-02a 核心关卡结论与规格同步**。依赖 T04-01、T04-02。- 将已验证、失败和待定项分别记录;在本轮实验约定的基础上,固化正式专项验收的模型范围与成本上限。- 由 Claude 将确认的目标、约束、验收与采用方案写回现行 `docs/spec.md`、`docs/design.md`,保持唯一事实来源。- 若需要功能/思考降级或改变桌面交互目标,先取得用户对具体取舍的确认;未确认不得开始正式适配。@@ -41,21 +41,21 @@## G04-2:正式手动模式-- [ ] **T04-03 Claude 接入与运行入口**。依赖 T04-02a。+- [x] **T04-03 Claude 接入与运行入口**。依赖 T04-02a。- 照原机制:Claude 插件带 MCP 服务(与 Codex 共用 `plugin/src`),由它拉起并看守引擎;Mod 负责切地址(先确认引擎就绪再切,保存并恢复原值)和 `/cam`。确定 Claude 插件的目录与清单、MCP 服务在 Claude 下的 Node 运行环境和安装副本检查。- Codex 和 Claude 共用一个引擎:现在引擎在没有 Codex 进程时自己退出(`engine.ts` 的 `watchForCodex`),要改成两边都不在用时才退出;替换规则要避免两份插件副本版本相同、代码不同时来回让对方的引擎退役。改的是共用代码,改完重新 `cam install`,确认 Codex 照常能连上。- 覆盖 HTTP 查询、认证、系统代理、SSE、上游错误、取消;无改写路径保持原始正文。- 关联:R04-01、R04-07;A04-01、A04-02、A04-10、A04-11。- 证据:回归测试和真实桌面订阅冒烟;不以实验插件代替正式包。-- [ ] **T04-04 会话索引与图片出现记录**。依赖 T04-02a。+- [x] **T04-04 会话索引与图片出现记录**。依赖 T04-02a。- 照原机制从 Claude Code 的本地会话记录只读、增量地找图和编号,引擎和插件服务各自计算;稳定编号、轮次、尺寸、重复关系与来源;处理直接图、工具图和取回副本。会话按 `x-claude-code-session-id` 认出。- 对齐按原机制的顺序:工具图用 `tool_use_id`,用户图用类型、轮次和内容哈希;核对历史预处理与发送块的差异;状态按客户端和会话隔离,未知结构保留。- 关联:R04-02、R04-03;A04-03、A04-05、A04-09。- 证据:合成 fixtures 的单元测试,真实桌面只读核对;提交中不含真实会话样本。-- [ ] **T04-05 Claude 手动请求改写**。依赖 T04-03、T04-04。- - 只替换确定的授权图片,保留消息/工具结构与其余字段;普通/重复占位符、已提供标签、中英文照原机制实现,上下文管理说明用 `role: "system"` 放在那条用户消息之后;思考块原样转发,被拒时原样重发并提示。+- [x] **T04-05 Claude 手动请求改写**。依赖 T04-03、T04-04。+ - 只替换确定的授权图片,保留消息/工具结构与其余字段;普通/重复占位符、已提供标签、中英文照原机制实现,上下文管理说明用 `role: "system"` 放在那条用户消息之后;思考块原样转发,账号拒绝改过历史之后的思考时,去掉对不上的思考记录、照样按勾选发出并提示,还不行才原样重发(用户 2026-10-11 定,见 plan.md D04-03)。- 选择不变时改写稳定;无法安全改写时原样转发并给出可见原因,回退不算取消成功。- 关联:R04-02、R04-06;A04-02、A04-03、A04-04、A04-09。- 证据:先失败再通过的单元测试、请求差异、同会话桌面取消/恢复及双语模型自测。@@ -65,8 +65,9 @@- 不只依赖 `session.start` 更新会话状态;核对真实事件时序。- 关联:R04-03;A04-05、A04-10。- 证据:两会话隔离、重载、续聊、分叉、压缩、回退、工具中间请求的回归与桌面记录。+ - 进度(2026-10-11):已测两个会话同时运行、勾选不同,各按各的改写(引擎日志);会话在引擎重启后、闲置几小时后续聊正常;同一轮里工具调用之间的请求照样改写。压缩分界和回退分支有单元测试。还没在桌面里测:分叉、`/compact`、`/rewind`、子代理。-- [ ] **T04-07 完整手动面板**。依赖 T04-02、T04-04、T04-05。+- [x] **T04-07 完整手动面板**。依赖 T04-02、T04-04、T04-05。- 接入完整列表、预览、整轮勾选、来源筛选、发送预估/实际统计、需要编号定位、任务名、刷新、启停、主题和双语。- 逐项引用现行 v0.3 的行为;筛选不改变发送,整轮选择按显示项处理。复用 `panel.html`(D04-04)。- 关联:R04-04、R04-06;A04-06、A04-07。@@ -74,7 +75,7 @@## G04-3:自动模式-- [ ] **T04-08 自动选图与原图工具**。依赖 T04-05、T04-06、T04-07;先确认 T04-01 覆盖取图副本省略。+- [x] **T04-08 自动选图与原图工具**。依赖 T04-05、T04-06、T04-07;先确认 T04-01 覆盖取图副本省略。- 自动开关默认关;旧图省略、新图照常、固定发送与手动状态分开;模型按编号真正取到图片,副本仅在本轮提供。取图工具由插件的 MCP 服务提供,始终注册、不随开关增删。- 取回不另编号、不改用户勾选;下一轮省略副本,前面的占位文本保持稳定;关闭自动恢复手动状态。- 关联:R04-05;A04-04、A04-08。@@ -87,6 +88,7 @@- 只写自管设置;不保存认证值;识别安装、启用、当前会话加载三个状态。- 关联:R04-01、R04-06;A04-01、A04-09、A04-10。- 证据:合成配置回归、实际安装副本与桌面订阅测试;记录平台覆盖,不将 CI 启动冒烟当成跨平台桌面实测。+ - 进度(2026-10-11):从 GitHub 插件市场装到用户范围(隔离的配置目录里一次、用户本机一次),插件服务能起来;用 Codex 带的 Node 或只有系统的 Node 24 都能跑;Codex 和 Claude 共用引擎,`cam install` 后健康检查正常。还没测:卸载、重载、桌面重启、引擎失败、登录刷新。- [ ] **T04-10 Codex 回归与最终审阅**。依赖 T04-03–T04-09。- 跑改动相关的现有测试,确认 v0.1–v0.3 语义、原样路径、自动模式和装卸不退化。