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
feat(platforms): Qwen Code, Cline, Kilo Code, goose and Cherry Studio
chipfighterc28e905cefe7
diff --git a/ADAPTERS.md b/ADAPTERS.mdindex f96b332..3322f1a 100644--- a/ADAPTERS.md+++ b/ADAPTERS.md@@ -10,12 +10,12 @@ The panel (pick images, pin, search) is only in Codex and Claude Desktop. Every## Agents you can connect now-WorkBuddy, OpenCode, Gemini CLI, pi and DeepSeek Harness. These adapters were written from each agent's code and docs and are **not tested live yet**. If one does not work for you, please [open an issue](https://github.com/chipfighter/context-attachment-manager/issues) with what you saw.+WorkBuddy, OpenCode, Gemini CLI, pi, DeepSeek Harness, Qwen Code, Cline, Kilo Code, goose and Cherry Studio. These adapters were written from each agent's code and docs and are **not tested live yet**. If one does not work for you, please [open an issue](https://github.com/chipfighter/context-attachment-manager/issues) with what you saw.How to install, step by step (also for an AI doing it for you): [INSTALL.md, Other agents](INSTALL.md#other-agents). In short, from a clone of this repository:- `cam detect` tells which agent a shell runs in, from the variables each agent sets for its commands, and prints the next command.-- `cam connect <agent> --apply` registers a route in the local engine, from a local address to where the agent's requests go now, and writes the agent's settings: that address, and the MCP server for `cam_view_image`. Files are backed up first, and what was written is recorded.+- `cam connect <agent> --apply` registers a route in the local engine, from a local address to where the agent's requests go now, and writes the agent's settings: that address, and the MCP server for `cam_view_image`. What each setting held before is recorded (the files are never copied: they may hold API keys).- `cam disconnect <agent>` puts back what was there, except settings changed since.- `cam connect <agent>` without `--apply` only prints the steps.diff --git a/INSTALL.md b/INSTALL.mdindex 491f44e..07f3feb 100644--- a/INSTALL.md+++ b/INSTALL.md@@ -1,6 +1,6 @@# Install-The easy way: paste this to your agent (Codex, Claude Desktop's Code tab, WorkBuddy, OpenCode, Gemini CLI, pi or DeepSeek Harness) and let it do the steps below for you.+The easy way: paste this to your agent (Codex, Claude Desktop's Code tab, WorkBuddy, OpenCode, Gemini CLI, pi, DeepSeek Harness, Qwen Code, Cline, Kilo Code or goose; for Cherry Studio, see [Other agents](#other-agents)) and let it do the steps below for you.```textInstall the Context Attachment Manager plugin for me, following https://github.com/chipfighter/context-attachment-manager/blob/main/INSTALL.md@@ -21,6 +21,10 @@ Install for the agent the user is talking to you in, and only that one. Which ag| `GEMINI_CLI=1` | Gemini CLI | [Other agents](#other-agents) || `PI_SESSION_ID` | pi | [Other agents](#other-agents) || `DSH_SHELL=1` | DeepSeek Harness | [Other agents](#other-agents) |+| `QWEN_CODE=1` | Qwen Code | [Other agents](#other-agents) |+| `CLINE_ACTIVE=true` | Cline | [Other agents](#other-agents) |+| `KILO=1` | Kilo Code | [Other agents](#other-agents) |+| `GOOSE_TERMINAL=1` | goose | [Other agents](#other-agents) |If none matches, or more than one, ask the user which agent this is. For the other agents, `cam detect` (below) checks the same variables and prints the exact command to run next.2. **Follow that section only**, and run the commands yourself. Do not edit the agent's settings by hand: the commands back them up and record what they wrote, so they can be undone.@@ -75,7 +79,7 @@ Then start a new session in the Code tab. There is nothing to set up: the plugin## Other agents-WorkBuddy, OpenCode, Gemini CLI, pi and DeepSeek Harness get auto-select without a panel: earlier turns' images go out as short placeholders, and the model pulls back the one it needs by its id. These adapters are new and were not tested on the agents themselves yet; please [open an issue](https://github.com/chipfighter/context-attachment-manager/issues) if one does not work for you.+WorkBuddy, OpenCode, Gemini CLI, pi, DeepSeek Harness, Qwen Code, Cline, Kilo Code, goose and Cherry Studio get auto-select without a panel: earlier turns' images go out as short placeholders, and the model pulls back the one it needs by its id. These adapters are new and were not tested on the agents themselves yet; please [open an issue](https://github.com/chipfighter/context-attachment-manager/issues) if one does not work for you.They need [Node.js 24 or later](https://nodejs.org) (`node --version`) and the plugin's code in a folder where it can stay (the agent runs it from there):@@ -95,9 +99,14 @@ Run the command it prints under `next`, then restart the agent. What that comman- **OpenCode**: `cam connect opencode --apply` sets `options.baseURL` of the provider your `model` uses (or `--provider <id>`) in `~/.config/opencode/opencode.json`, and adds the MCP server under `mcp`. A config file with comments is not changed; the command says so, and `cam connect opencode` without `--apply` prints the steps instead.- **Gemini CLI**: `cam connect gemini-cli --apply` sets `GOOGLE_GEMINI_BASE_URL` (API key sign-in) or `CODE_ASSIST_ENDPOINT` (Google sign-in) in `~/.gemini/.env`, and adds the MCP server to `~/.gemini/settings.json`. A `.env` in your project folder that sets the same variable wins over it. Vertex AI is not supported.- **pi**: `cam connect pi --apply` sets `baseUrl` of the provider pi uses now (or `--provider <name>`) in `~/.pi/agent/models.json`, and lists the plugin's pi extension under `extensions` in `~/.pi/agent/settings.json`. The extension adds the MCP server.+- **Qwen Code**: `cam connect qwen-code --apply` sets `baseUrl` of the model you use under `modelProviders` in `~/.qwen/settings.json` (or `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL` in `~/.qwen/.env`), and adds the MCP server there. Qwen OAuth is not supported.+- **Cline**: `cam connect cline --apply` sets `settings.baseUrl` of the provider you use (or `--provider <id>`) in `~/.cline/data/settings/providers.json`, and adds the MCP server to `cline_mcp_settings.json` beside it. Cline's own account provider is not supported. Reload the VS Code window afterwards.+- **Kilo Code**: `cam connect kilo-code --apply` sets `options.baseURL` of the provider your `model` uses (or `--provider <id>`) in `~/.config/kilo/kilo.json`, and adds the MCP server under `mcp`. Kilo's own gateway account is not supported.+- **goose**: `cam connect goose` prints what to put in goose's `config.yaml` (the provider's `<PROVIDER>_HOST` and an extension); this command does not write YAML.+- **Cherry Studio**: it runs no commands of its own, so run `cam connect cherry-studio --base-url <API host>` yourself, with the API host your provider shows in Cherry Studio's settings, and put the printed address in that field; add the printed MCP server under Settings > MCP Servers.- **DeepSeek Harness**: `dsh plugin --profile <profile> add "<folder>/plugin/src/adapters/dsh"` installs the plugin as a dsh bundle. It turns dsh's own image offload off and does what it did, and also offloads earlier turns' images when a new turn starts. The model reads an offloaded image back from the path its placeholder names.-Each `cam connect --apply` backs the files up first (in the data folder, see [Your data](#your-data)), and keeps the address the agent used before as the destination: requests go there through the engine. Run it again after an update; it keeps what it found the first time.+Each `cam connect --apply` records the settings it changed and what they held before (in the data folder, see [Your data](#your-data)); it never copies the files, which may hold API keys. It keeps the address the agent used before as the destination: requests go there through the engine. Run it again after an update; it keeps what it found the first time.## Custom endpoints@@ -152,7 +161,7 @@ Undo the settings first, then restart the agent and delete the folder:node "$HOME/context-attachment-manager/plugin/src/cam.ts" disconnect <agent>```-`<agent>` is `workbuddy`, `opencode`, `gemini-cli` or `pi`. It puts back what was there before, except settings you changed since. For DeepSeek Harness: `dsh plugin --profile <profile> remove dsh-context-attachment-manager`.+`<agent>` is `workbuddy`, `opencode`, `gemini-cli`, `pi`, `qwen-code`, `cline` or `kilo-code`; for goose and Cherry Studio, put back the address you had by hand. It puts back what was there before, except settings you changed since. For DeepSeek Harness: `dsh plugin --profile <profile> remove dsh-context-attachment-manager`.Remove the plugin only after this: an agent still pointed at the engine cannot connect once nothing starts it.diff --git a/README.md b/README.mdindex 067126d..09ad8ea 100644--- a/README.md+++ b/README.md@@ -93,6 +93,11 @@ The plugin's core knows no platform; each one gets a thin adapter. The panel is| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | Google's open-source terminal agent | Auto-select, new, feedback welcome || [pi](https://github.com/earendil-works/pi) | Minimal, extensible terminal coding agent | Auto-select (pi extension), new, feedback welcome || [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) | DeepSeek's agent harness where everything is a plugin | Auto-select (dsh plugin), new, feedback welcome |+| [Qwen Code](https://github.com/QwenLM/qwen-code) | Qwen's open-source terminal agent | Auto-select, new, feedback welcome |+| [Cline](https://github.com/cline/cline) | Open-source coding agent for VS Code, JetBrains and the terminal | Auto-select, new, feedback welcome |+| [Kilo Code](https://github.com/Kilo-Org/kilocode) | Open-source coding agent for VS Code, JetBrains and the terminal | Auto-select, new, feedback welcome |+| [goose](https://github.com/aaif-goose/goose) | Open-source agent for desktop and terminal, extended with MCP | Auto-select, new, feedback welcome |+| [Cherry Studio](https://github.com/CherryHQ/cherry-studio) | Open-source desktop chat client for many models | Auto-select, new, feedback welcome || **Your agent** | A thin adapter; the core stays as it is | Send a PR and add your agent here: [ADAPTERS.md](ADAPTERS.md) |To install on any of them, paste the sentence in [Install](#install) to that agent; how each one is connected is in [INSTALL.md](INSTALL.md#other-agents). Something off? [Open an issue](https://github.com/chipfighter/context-attachment-manager/issues).diff --git a/README_CN.md b/README_CN.mdindex 13ed78b..6ebe765 100644--- a/README_CN.md+++ b/README_CN.md@@ -93,6 +93,11 @@ https://github.com/user-attachments/assets/b9767a20-8ca4-4a33-86bc-5e0a16a2ed13| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | Google 开源的终端智能体 | 自动选图,新接入,欢迎反馈 || [pi](https://github.com/earendil-works/pi) | 极简、可扩展的终端编程智能体 | 自动选图(pi 扩展),新接入,欢迎反馈 || [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) | DeepSeek 的智能体框架,一切皆插件 | 自动选图(dsh 插件),新接入,欢迎反馈 |+| [Qwen Code](https://github.com/QwenLM/qwen-code) | 通义千问开源的终端智能体 | 自动选图,新接入,欢迎反馈 |+| [Cline](https://github.com/cline/cline) | 开源的编程智能体,VS Code、JetBrains 和终端都能用 | 自动选图,新接入,欢迎反馈 |+| [Kilo Code](https://github.com/Kilo-Org/kilocode) | 开源的编程智能体,VS Code、JetBrains 和终端都能用 | 自动选图,新接入,欢迎反馈 |+| [goose](https://github.com/aaif-goose/goose) | 开源的桌面和终端智能体,用 MCP 扩展 | 自动选图,新接入,欢迎反馈 |+| [Cherry Studio](https://github.com/CherryHQ/cherry-studio) | 开源的桌面 AI 聊天客户端,能接多家模型 | 自动选图,新接入,欢迎反馈 || **你的 Agent** | 写一层薄薄的接入,核心一行不用改 | 提个 PR,把你的平台加到这里:[接入说明](ADAPTERS.md)(英文) |在哪个平台上装,就把[安装](#安装)里那句话发给那个平台的 Agent;各平台具体改了什么,见 [INSTALL.md](INSTALL.md#other-agents)(英文)。用下来有问题,欢迎[提 issue](https://github.com/chipfighter/context-attachment-manager/issues)。diff --git a/README_JA.md b/README_JA.mdindex 2fd90eb..55a1d96 100644--- a/README_JA.md+++ b/README_JA.md@@ -95,6 +95,11 @@ Codex で短編ドラマのキーフレーム 9 枚、合計約 32 MB の画像| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | Google のオープンソースのターミナル型エージェント | 自動選択、新規対応、フィードバック歓迎 || [pi](https://github.com/earendil-works/pi) | ミニマルで拡張できるターミナル型コーディングエージェント | 自動選択(pi 拡張)、新規対応、フィードバック歓迎 || [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) | すべてがプラグインの DeepSeek のエージェント基盤 | 自動選択(dsh プラグイン)、新規対応、フィードバック歓迎 |+| [Qwen Code](https://github.com/QwenLM/qwen-code) | Qwen のオープンソースのターミナル型エージェント | 自動選択、新規対応、フィードバック歓迎 |+| [Cline](https://github.com/cline/cline) | VS Code・JetBrains・ターミナルで使えるオープンソースのコーディングエージェント | 自動選択、新規対応、フィードバック歓迎 |+| [Kilo Code](https://github.com/Kilo-Org/kilocode) | VS Code・JetBrains・ターミナルで使えるオープンソースのコーディングエージェント | 自動選択、新規対応、フィードバック歓迎 |+| [goose](https://github.com/aaif-goose/goose) | MCP で拡張できる、デスクトップとターミナルのオープンソースエージェント | 自動選択、新規対応、フィードバック歓迎 |+| [Cherry Studio](https://github.com/CherryHQ/cherry-studio) | 多くのモデルにつながるオープンソースのデスクトップ AI チャット | 自動選択、新規対応、フィードバック歓迎 || **あなたのエージェント** | 薄い接続層を書くだけで、コアは変更不要 | PR を送って、ここに追加してください:[ADAPTERS.md](ADAPTERS.md)(英語) |どのエージェントでも、[インストール](#インストール)の文をそのエージェントに送ればインストールできます。各エージェントで何を変更するかは [INSTALL.md](INSTALL.md#other-agents)(英語)にあります。問題があれば [issue](https://github.com/chipfighter/context-attachment-manager/issues) でお知らせください。diff --git a/docs/design.md b/docs/design.mdindex 594c4aa..0fbfc7e 100644--- a/docs/design.md+++ b/docs/design.md@@ -31,9 +31,9 @@ v0.11 起代码分成三层([v0.11/plan.md](v0.11/plan.md)):`core/` 是不| Claude 会话索引和改写(v0.4) | `adapters/claude/claude-index.ts`、`adapters/claude/claude-rewrite.ts`、`adapters/protocols/anthropic-messages/rewrite.ts` | 从 Claude Code 的会话记录找图、编号,把请求里的图对上记录;把决定落进 Anthropic Messages 请求 || Claude 思考记录和提示缓存(v0.4、v0.10) | `adapters/protocols/anthropic-messages/thinking.ts`、`adapters/protocols/anthropic-messages/cache.ts` | 账号校验思考记录时,去掉和实际发出的历史对不上的思考;改过历史后,让提示缓存仍能读到 || 面板页(v0.4) | `panel/panel-web.js`、`panel/panel-language.ts`、`adapters/claude/panel-web.ts` | 引擎把 `panel.html` 作为网页提供时,代替 MCP 应用的宿主 |-| 只接核心的平台(v0.11) | `platforms.ts`、`core/platform.ts`、`core/request-index.ts`、`adapters/protocols/any.ts`、`adapters/protocols/openai-chat/rewrite.ts`、`adapters/protocols/gemini/rewrite.ts`、`adapters/{workbuddy,opencode,gemini-cli,pi}/platform.ts`、`adapters/pi/extension.ts` | 平台登记表和每个平台的条目;按路径认格式,从请求本身认图、按内容编号、存原图,自动选图一直开着;`cam connect` 登记线路;pi 的扩展加会话头、注册取图服务 |+| 只接核心的平台(v0.11) | `platforms.ts`、`core/platform.ts`、`core/request-index.ts`、`adapters/protocols/any.ts`、`adapters/protocols/openai-chat/rewrite.ts`、`adapters/protocols/gemini/rewrite.ts`、`adapters/{workbuddy,opencode,gemini-cli,pi,qwen-code,cline,kilo-code,goose,cherry-studio}/platform.ts`、`adapters/pi/extension.ts` | 平台登记表和每个平台的条目;按路径认格式,从请求本身认图、按内容编号、存原图,自动选图一直开着;`cam connect` 登记线路;pi 的扩展加会话头、注册取图服务 || DeepSeek Harness(v0.11) | `adapters/dsh/index.js`、`adapters/dsh/offload.js`、`adapters/dsh/package.json`、`adapters/dsh/cordis.patch.yml` | dsh 插件包:装上时停掉官方的图片卸载行,新一轮开始时卸载之前各轮的图,图片超预算时照旧卸载最旧的 |-| 安装到其他平台(v0.11) | `platforms.ts`(`detectPlatform`)、`core/config-edit.ts`、各平台条目的 `detect` 和 `setup`、`cam.ts`(`detect`、`connect --apply`、`disconnect`) | 按环境变量认平台;改平台的设置文件,先备份、记下改动,撤回时只动还保持原样的设置 |+| 安装到其他平台(v0.11) | `platforms.ts`(`detectPlatform`)、`core/config-edit.ts`、各平台条目的 `detect` 和 `setup`、`cam.ts`(`detect`、`connect --apply`、`disconnect`) | 按环境变量认平台;改平台的设置文件,记下改了哪几项和原来的值(不复制文件,里面可能有 API key),撤回时只动还保持原样的设置 || 换模型后接回 Codex(v0.11) | `adapters/codex/setup.ts`(`wantsEngine`、`keepRouted`)、`adapters/codex/codexconfig.ts`(`routedThroughEngine`)、`proxy.ts` | config.toml 被 cc-switch 之类改写后,引擎重新接上,线路指向用户新选的服务商 |引擎和插件服务之间只通过数据目录里的文件共享状态,任何一方不在,另一方都照常工作。diff --git a/docs/spec.md b/docs/spec.mdindex 424da07..5155364 100644--- a/docs/spec.md+++ b/docs/spec.md@@ -217,7 +217,7 @@ v0.1 到 v0.3 都不做下面这些。其中音频和其他语言已确认是后- v0.11 也不做:- 新平台的面板(用户 2026-11-02 定:默认不带,用户主动要求时再接);- 让模型请求经过不了引擎、自己也没有能改历史的插件的客户端:省略旧图要么让引擎站在客户端和模型 API 之间,要么用客户端自己的插件改历史(DeepSeek Harness);MCP 只能给模型加取图工具,不能从客户端发出的历史里删图;- - Antigravity(用户 2026-11-02 定);+ - Antigravity 和其他闭源平台(用户 2026-11-02 定,暂时不支持);Roo Code(仓库已归档);- 跨请求格式的转换:翻译器只改图片相关的几处,请求照原格式发往原服务(v0.9 的规则不变);- 拆成多个仓库(用户 2026-11-02 定;拆成多个包以后看情况)。@@ -363,9 +363,9 @@ v0.1 之前的阶段验收(阶段 0 的重建路线、代理路线 P2)都已1. 代码分成接入层、核心层、面板层,分层检查测试通过:核心层不引用接入层和面板层,面板层只经核心的公开接口。2. Codex 和 Claude 的行为不变:原有单元测试和冒烟测试全过;各种勾选组合下改写结果和拆之前逐字节相同;模型自测不退化(gpt-6-sol,中英文)。3. 有对外的接入接口文档(英文)和契约测试;面板在文档里是可选的一节,新平台默认不接。-4. 其他平台只接核心、不带面板:WorkBuddy、OpenCode、Gemini CLI、pi 的请求经过引擎,之前各轮的图按自动选图省略,模型能按编号取回;DeepSeek Harness 用顶替官方插件的 dsh 插件,新一轮开始时卸载之前各轮的图。用户 2026-11-02 定不在本机实跑:按各平台的代码和文档写接入,用合成请求测试,README 的平台表标明没实测,等用户反馈。+4. 其他平台只接核心、不带面板:WorkBuddy、OpenCode、Gemini CLI、pi、Qwen Code、Cline、Kilo Code、goose、Cherry Studio 的请求经过引擎,之前各轮的图按自动选图省略,模型能按编号取回;DeepSeek Harness 用顶替官方插件的 dsh 插件,新一轮开始时卸载之前各轮的图。用户 2026-11-02 定不在本机实跑:按各平台的代码和文档写接入,用合成请求测试,README 的平台表标明没实测,等用户反馈。5. README 开头改成多模态税的口径,删掉“为什么做这个”,底部有平台表(简介和接入情况);`ADAPTERS.md` 写各平台的接法和怎么加新平台。-6. 安装:用户把 README 里那句话发给所在平台的 Agent,Agent 照 INSTALL.md 装对平台。平台由各平台给命令设的环境变量认出(`cam detect`),认不出或认出多个就问用户;只接核心的平台由 `cam connect <平台> --apply` 改设置(先备份、记下改动),`cam disconnect` 撤回,用户之后改过的设置不动。+6. 安装:用户把 README 里那句话发给所在平台的 Agent,Agent 照 INSTALL.md 装对平台。平台由各平台给命令设的环境变量认出(`cam detect`),认不出或认出多个就问用户;只接核心的平台由 `cam connect <平台> --apply` 改设置(记下改了哪几项、原来是什么;不复制文件,因为里面常有 API key),`cam disconnect` 撤回,用户之后改过的设置不动。7. Codex 被换模型的工具(如 cc-switch)改写服务地址后,引擎重新接上,请求经过引擎发往用户新选的服务商;用户停用了插件就不再接。## 5. 待定问题diff --git a/docs/v0.11/plan.md b/docs/v0.11/plan.mdindex c35651e..fa56cbc 100644--- a/docs/v0.11/plan.md+++ b/docs/v0.11/plan.md@@ -18,7 +18,7 @@1. **三层**:接入层(一个平台一份,尽量薄)、核心层(不认识任何平台)、面板层(只经核心接口拿数据)。以后调算法只改核心层;维护某个平台只看它的那一份。2. **Codex 和 Claude 的行为不变**:这次是重组,不改用户看得到的任何行为。3. **对外接口文档和契约测试**:第三方照文档写接入,跑契约测试证明能用。-4. **用新结构接其他平台**:WorkBuddy、OpenCode、Gemini CLI、pi、DeepSeek Harness,只接核心,不带面板,检验接入层是不是真的薄。+4. **用新结构接其他平台**:WorkBuddy、OpenCode、Gemini CLI、pi、DeepSeek Harness,再加 Qwen Code、Cline、Kilo Code、goose、Cherry Studio,只接核心,不带面板,检验接入层是不是真的薄。## 2. 已定的规则(用户 2026-11-02 定)@@ -42,7 +42,7 @@ plugin/src/adapters/ 接入层protocols/ 请求格式的翻译器:openai-responses、anthropic-messages、openai-chat、gemini;any.ts 给只接核心的平台用codex/、claude/ 带面板的两个平台,各自读本地记录、改配置、开面板- workbuddy/、opencode/、gemini-cli/、pi/ 只接核心的平台,每个一个 platform.ts(pi 另有扩展)+ workbuddy/、opencode/、gemini-cli/、pi/、qwen-code/、cline/、kilo-code/、goose/、cherry-studio/ 只接核心的平台,每个一个 platform.ts(pi 另有扩展)dsh/ DeepSeek Harness 的 dsh 插件包(index.js、offload.js、package.json、cordis.patch.yml)```@@ -94,7 +94,7 @@ plugin/src/- 仍是一个版本、一份内容。全机只有一个引擎,所有平台共用;各平台装不同版本时,引擎会互相请对方退役,Codex 和 Claude 两份副本之间已经出现过(design 第 5 节)。所以不按平台拆成不同的包。- 每个平台按它自己的方式装:Codex、Claude 照旧走各自的插件市场和安装命令;只接核心的平台把仓库克隆到一个固定的文件夹,`cam detect` 认出平台,`cam connect <平台> --apply` 登记线路并改好平台的设置,`cam disconnect` 撤回;DeepSeek Harness 用 `dsh plugin add` 装 dsh 包。-- 用户 2026-11-02 定:用户把一句话发给自己的 Agent,Agent 看仓库就能在对应的平台上装好,而且不会装错(例如 WorkBuddy 里的 DeepSeek 模型要装 WorkBuddy 的那一份)。所以平台由各平台给命令设的环境变量来认,不靠模型自己猜;改设置由命令来做,不让模型手改:先备份,记下改了什么、原来是什么,`cam disconnect` 只撤回还保持原样的设置。带注释的 JSON 不改,只打出步骤。+- 用户 2026-11-02 定:用户把一句话发给自己的 Agent,Agent 看仓库就能在对应的平台上装好,而且不会装错(例如 WorkBuddy 里的 DeepSeek 模型要装 WorkBuddy 的那一份)。所以平台由各平台给命令设的环境变量来认,不靠模型自己猜;改设置由命令来做,不让模型手改:记下改了哪几项、原来是什么(不复制整个文件:设置文件和 .env 里常有 API key),`cam disconnect` 只撤回还保持原样的设置。带注释的 JSON 不改,只打出步骤。- 面板文件随包一起发,只有 Codex 桌面版和 Claude 桌面版的接入打开它。- 拆的过程中插件版本号不动,免得 Codex 中途从工作区自动重装;全部做完再升到 0.11.0 发布。@@ -140,7 +140,7 @@ DSH 的请求可能用 DeepSeek 的文件模式发图(请求里是文件引用5. 拆面板:`panel-state.ts` 只读核心接口;插件服务里的面板工具和取图工具分开。6. 拆安装:Codex 的配置和命令行、Claude 的 Mod 进各自的接入。7. 写 `ADAPTERS.md`(英文,对外)和契约测试;在 Codex 和 Claude 里跑一遍模型自测(gpt-6-sol,中英文)。-8. 接其他平台:平台登记表(自动选图的规则收进核心、会话编号不限 UUID、引擎认所有平台的探活);openai-chat、gemini 两个翻译器;核心从请求建清单;WorkBuddy、OpenCode、Gemini CLI、pi 的条目,pi 的扩展,DSH 的插件包;`cam detect`、`cam connect --apply`、`cam disconnect`;INSTALL.md 按平台写;Codex 在 cc-switch 切换后自动接回;README 底部的平台表。不带面板,不实跑(第 7 节)。+8. 接其他平台:平台登记表(自动选图的规则收进核心、会话编号不限 UUID、引擎认所有平台的探活);openai-chat、gemini 两个翻译器;核心从请求建清单;WorkBuddy、OpenCode、Gemini CLI、pi 的条目,pi 的扩展,DSH 的插件包;`cam detect`、`cam connect --apply`、`cam disconnect`;INSTALL.md 按平台写;Codex 在 cc-switch 切换后自动接回;README 底部的平台表;再接 Qwen Code、Cline、Kilo Code、goose、Cherry Studio(goose 的设置是 YAML、Cherry Studio 的在应用里,这两个只打出步骤)。不带面板,不实跑(第 7 节)。9. Claude 桌面版实跑一轮,然后推送、发 0.11.0。## 6. 风险@@ -164,3 +164,4 @@ DSH 的请求可能用 DeepSeek 的文件模式发图(请求里是文件引用10. 安装:Agent 看仓库就能在所在平台装对,平台靠环境变量认,设置由命令改(第 3.7 节)。11. DeepSeek Harness 直接停掉官方的图片卸载,用我们的(第 3.9 节)。12. 这几个平台接完以后,再改 README、定新的仓库名字、简介、标签,做新的视频和图片,调整宣传口径。+13. 再接的平台只接开源、用户多、用途多的:Qwen Code、Cline、Kilo Code、goose、Cherry Studio(Roo Code 的仓库已归档,不接)。闭源平台暂时不支持。测试只在 Codex 和 Claude 上实跑,其余平台不测(11-02 晚)。diff --git a/plugin/src/adapters/cherry-studio/platform.ts b/plugin/src/adapters/cherry-studio/platform.tsnew file mode 100644index 0000000..9a09353--- /dev/null+++ b/plugin/src/adapters/cherry-studio/platform.ts@@ -0,0 +1,20 @@+// Purpose: v0.11 — Cherry Studio (a desktop chat client for many models): the core alone, no panel. Each model provider+// has its own "API 地址" (API host) in Cherry Studio's settings, to which it adds the format's path (/v1/chat/completions,+// /v1/messages, …); so the route is registered with that host as shown there (`--base-url`), and the same host replaced+// by the route's address gets the same path added. Its settings live in the app, not in a file this tool writes, and+// it runs no shell commands of its own, so the steps are printed for the user. Its requests name no session the engine+// knows, so conversations are told apart by their first prompt. Not tested live.+// Input: none. Output: the platform's entry (core/platform.ts).++import { MCP_NAME, type CorePlatform } from "../../core/platform.ts";++export const cherryStudio: CorePlatform = {+ name: "cherry-studio",+ title: "Cherry Studio",+ upstream: null,+ connect: ({ url, mcp }) => [+ `Run this with --base-url set to the API host your provider shows in Cherry Studio (Settings > Model Provider), then put ${url} in that same field`,+ `In Settings > MCP Servers, add a server: type stdio, name ${MCP_NAME}, command ${mcp.command}, arguments ${mcp.args.join(" ")}, environment ${Object.entries(mcp.env).map(([name, value]) => `${name}=${value}`).join(" ")}; turn it on in the chats you use`,+ "Start a new conversation.",+ ],+};diff --git a/plugin/src/adapters/cline/platform.ts b/plugin/src/adapters/cline/platform.tsnew file mode 100644index 0000000..8657ae0--- /dev/null+++ b/plugin/src/adapters/cline/platform.ts@@ -0,0 +1,49 @@+// Purpose: v0.11 — Cline (VS Code, JetBrains and its CLI share one configuration): the core alone, no panel. Providers+// are in ~/.cline/data/settings/providers.json (CLINE_DIR moves ~/.cline), each with an optional `settings.baseUrl`+// over its built-in address (the defaults below, from Cline's provider list); `lastUsedProvider` is the one in use.+// Cline's own account provider goes to Cline's service and is not handled. The request format follows the provider.+// Its requests name no session the engine knows, so sessions are told apart by their first prompt. MCP servers are in+// ~/.cline/data/settings/cline_mcp_settings.json; its terminals run with CLINE_ACTIVE=true. providers.json also holds+// the API keys: only the one address is changed in it, and the file is never copied. Not tested live.+// Input: the environment, the settings files. Output: the platform's entry (core/platform.ts).++import { join } from "node:path";+import { jsonAt } from "../../core/config-edit.ts";+import { MCP_NAME, type CorePlatform } from "../../core/platform.ts";++const DEFAULTS: Record<string, string> = {+ anthropic: "https://api.anthropic.com/v1",+ "openai-native": "https://api.openai.com/v1",+ gemini: "https://generativelanguage.googleapis.com/v1beta",+ deepseek: "https://api.deepseek.com/v1",+ openrouter: "https://openrouter.ai/api/v1",+};++export const cline: CorePlatform = {+ name: "cline",+ title: "Cline",+ upstream: null,+ detect: (env) => env.CLINE_ACTIVE === "true",+ setup: ({ home, env, provider }) => {+ const settings = join(env.CLINE_DIR?.trim() || join(home, ".cline"), "data", "settings");+ const providers = join(settings, "providers.json");+ const used = jsonAt(providers, ["lastUsedProvider"]);+ const name = provider ?? (typeof used === "string" ? used : null);+ if (!name) throw new Error("Cline: name the provider whose requests should go through the engine, e.g. --provider anthropic");+ if (name === "cline") throw new Error("Cline: its own account provider goes to Cline's service; pick a provider with your own key (Anthropic, OpenAI, OpenRouter, …)");+ const set = jsonAt(providers, ["providers", name, "settings", "baseUrl"]);+ return {+ current: typeof set === "string" ? set : null,+ fallback: DEFAULTS[name] ?? null,+ edits: ({ url, mcp }) => [+ { file: providers, json: ["providers", name, "settings", "baseUrl"], value: url },+ { file: env.CLINE_MCP_SETTINGS_PATH?.trim() || join(settings, "cline_mcp_settings.json"), json: ["mcpServers", MCP_NAME], value: { command: mcp.command, args: mcp.args, env: mcp.env } },+ ],+ };+ },+ connect: ({ url, mcp }) => [+ `In Cline's provider settings, set the base URL of the provider you use to ${url}`,+ `In Cline's MCP servers (Configure MCP Servers), add: "${MCP_NAME}": ${JSON.stringify({ command: mcp.command, args: mcp.args, env: mcp.env })}`,+ "Reload the VS Code window (or restart the Cline CLI).",+ ],+};diff --git a/plugin/src/adapters/goose/platform.ts b/plugin/src/adapters/goose/platform.tsnew file mode 100644index 0000000..5396116--- /dev/null+++ b/plugin/src/adapters/goose/platform.ts@@ -0,0 +1,49 @@+// Purpose: v0.11 — goose (aaif-goose/goose, desktop and CLI): the core alone, no panel. config.yaml (~/.config/goose, or+// %APPDATA%\Block\goose\config on Windows) names the provider in GOOSE_PROVIDER and its address in <PROVIDER>_HOST+// (ANTHROPIC_HOST, OPENAI_HOST, GOOGLE_HOST), by default the providers' own (below, from goose's provider code); MCP+// servers are stdio extensions in the same file. It is YAML, which this tool does not write, so the steps are printed;+// the provider and its address are read from it. Shell commands run with GOOSE_TERMINAL=1. Its requests name no+// session the engine knows, so sessions are told apart by their first prompt. Not tested live.+// Input: the environment, config.yaml. Output: the platform's entry (core/platform.ts).++import { existsSync, readFileSync } from "node:fs";+import { join } from "node:path";+import { MCP_NAME, type CorePlatform } from "../../core/platform.ts";++const DEFAULTS: Record<string, string> = {+ anthropic: "https://api.anthropic.com",+ openai: "https://api.openai.com",+ google: "https://generativelanguage.googleapis.com",+};++const configFile = (home: string, env: NodeJS.ProcessEnv) => (process.platform === "win32" && env.APPDATA ? join(env.APPDATA, "Block", "goose", "config", "config.yaml") : join(home, ".config", "goose", "config.yaml"));+// A top-level `KEY: value` line of config.yaml.+function yamlValue(file: string, key: string): string | null {+ if (!existsSync(file)) return null;+ const match = new RegExp(`^${key}:[ \\t]*["']?([^"'\\r\\n#]+?)["']?[ \\t]*(?:#.*)?$`, "m").exec(readFileSync(file, "utf8"));+ return match ? match[1].trim() : null;+}++export const goose: CorePlatform = {+ name: "goose",+ title: "goose",+ upstream: null,+ detect: (env) => env.GOOSE_TERMINAL === "1",+ setup: ({ home, env, provider }) => {+ const file = configFile(home, env);+ const name = (provider ?? env.GOOSE_PROVIDER?.trim() ?? yamlValue(file, "GOOSE_PROVIDER"))?.toLowerCase() ?? null;+ if (!name) throw new Error("goose: name the provider whose requests should go through the engine, e.g. --provider anthropic");+ const key = `${name.toUpperCase()}_HOST`;+ return {+ current: env[key]?.trim() || yamlValue(file, key),+ fallback: DEFAULTS[name] ?? null,+ edits: () => [],+ manual: `goose keeps its settings in YAML (${file}), which this command does not write: set them by hand, or with goose configure`,+ };+ },+ connect: ({ url, mcp }) => [+ `In goose's config.yaml, set the address of the provider you use: <PROVIDER>_HOST: ${url} (ANTHROPIC_HOST, OPENAI_HOST or GOOGLE_HOST)`,+ `Add under "extensions:": ${MCP_NAME}: { type: stdio, name: ${MCP_NAME}, enabled: true, cmd: ${JSON.stringify(mcp.command)}, args: ${JSON.stringify(mcp.args)}, envs: ${JSON.stringify(mcp.env)}, timeout: 300 }`,+ "Restart goose.",+ ],+};diff --git a/plugin/src/adapters/kilo-code/platform.ts b/plugin/src/adapters/kilo-code/platform.tsnew file mode 100644index 0000000..a308ffb--- /dev/null+++ b/plugin/src/adapters/kilo-code/platform.ts@@ -0,0 +1,53 @@+// Purpose: v0.11 — Kilo Code (VS Code, JetBrains and its CLI, built on OpenCode): the core alone, no panel. Its config+// is OpenCode's, renamed: kilo.json (or kilo.jsonc) in ~/.config/kilo (KILO_CONFIG_DIR moves it), with each provider's+// `provider.<id>.options.baseURL` and MCP servers under "mcp"; the route is for one provider, the one named or the one+// of the configured `model`. Kilo's own gateway account is not handled. Its process sets KILO=1, which its shell+// commands keep. Its requests name no session the engine knows, so sessions are told apart by their first prompt. Not+// tested live. (The same shape as adapters/opencode; adapters do not share code.)+// Input: the environment, the config file. Output: the platform's entry (core/platform.ts).++import { existsSync } from "node:fs";+import { join } from "node:path";+import { jsonAt } from "../../core/config-edit.ts";+import { MCP_NAME, type CorePlatform } from "../../core/platform.ts";++// The AI SDK providers' own addresses.+const DEFAULTS: Record<string, string> = {+ anthropic: "https://api.anthropic.com/v1",+ openai: "https://api.openai.com/v1",+ google: "https://generativelanguage.googleapis.com/v1beta",+};++function configFile(home: string, env: NodeJS.ProcessEnv): string {+ const dir = env.KILO_CONFIG_DIR?.trim() || join(home, ".config", "kilo");+ const jsonc = join(dir, "kilo.jsonc");+ return !existsSync(join(dir, "kilo.json")) && existsSync(jsonc) ? jsonc : join(dir, "kilo.json");+}++export const kiloCode: CorePlatform = {+ name: "kilo-code",+ title: "Kilo Code",+ upstream: null,+ detect: (env) => env.KILO === "1",+ setup: ({ home, env, provider }) => {+ const file = configFile(home, env);+ const model = jsonAt(file, ["model"]);+ const name = provider ?? (typeof model === "string" && model.includes("/") ? model.split("/")[0] : null);+ if (!name) throw new Error("Kilo Code: name the provider whose requests should go through the engine, e.g. --provider anthropic");+ if (name === "kilo") throw new Error("Kilo Code: its own gateway account goes to Kilo's service; pick a provider with your own key");+ const set = jsonAt(file, ["provider", name, "options", "baseURL"]);+ return {+ current: typeof set === "string" ? set : null,+ fallback: DEFAULTS[name] ?? null,+ edits: ({ url, mcp }) => [+ { file, json: ["provider", name, "options", "baseURL"], value: url },+ { file, json: ["mcp", MCP_NAME], value: { type: "local", command: [mcp.command, ...mcp.args], environment: mcp.env, enabled: true } },+ ],+ };+ },+ connect: ({ url, mcp }) => [+ `In kilo.json (~/.config/kilo), set your provider's base URL: "provider": { "<provider id>": { "options": { "baseURL": "${url}" } } }`,+ `Add the MCP server: "mcp": { "${MCP_NAME}": { "type": "local", "command": ${JSON.stringify([mcp.command, ...mcp.args])}, "environment": ${JSON.stringify(mcp.env)} } }`,+ "Restart Kilo Code.",+ ],+};diff --git a/plugin/src/adapters/qwen-code/platform.ts b/plugin/src/adapters/qwen-code/platform.tsnew file mode 100644index 0000000..6b7b129--- /dev/null+++ b/plugin/src/adapters/qwen-code/platform.ts@@ -0,0 +1,53 @@+// Purpose: v0.11 — Qwen Code (QwenLM/qwen-code, grown out of Gemini CLI): the core alone, no panel. ~/.qwen/settings.json+// lists models per protocol under `modelProviders` (`openai`, `anthropic`, …), each with its own `baseUrl`;+// `security.auth.selectedType` names the protocol in use and `model.name` the model, so the route is for that model's+// entry. Without an entry, OPENAI_BASE_URL or ANTHROPIC_BASE_URL in ~/.qwen/.env (or the shell) decides. The request+// format follows the protocol. Its requests name no session the engine knows, so sessions are told apart by their+// first prompt. MCP servers go under "mcpServers" in the same settings file; shell commands run with QWEN_CODE=1.+// Qwen OAuth and Vertex AI are not handled. Not tested live.+// Input: the environment, the settings files. Output: the platform's entry (core/platform.ts).++import { join } from "node:path";+import { envAt, jsonAt } from "../../core/config-edit.ts";+import { MCP_NAME, type CorePlatform } from "../../core/platform.ts";++const ENV_NAME: Record<string, string> = { openai: "OPENAI_BASE_URL", anthropic: "ANTHROPIC_BASE_URL" };+const DEFAULTS: Record<string, string> = { openai: "https://api.openai.com/v1", anthropic: "https://api.anthropic.com" };++export const qwenCode: CorePlatform = {+ name: "qwen-code",+ title: "Qwen Code",+ upstream: null,+ detect: (env) => env.QWEN_CODE === "1",+ setup: ({ home, env }) => {+ const dir = join(home, ".qwen");+ const settings = join(dir, "settings.json");+ const type = jsonAt(settings, ["security", "auth", "selectedType"]) ?? (env.OPENAI_API_KEY ? "openai" : undefined);+ if (typeof type !== "string" || !ENV_NAME[type]) throw new Error(`Qwen Code signs in with ${String(type ?? "nothing set yet")}; only an OpenAI-compatible or Anthropic provider can go through the engine (set one up with /auth first)`);+ const models = jsonAt(settings, ["modelProviders", type]);+ const model = jsonAt(settings, ["model", "name"]);+ const at = Array.isArray(models) ? models.findIndex((entry) => entry?.id === model) : -1;+ const mcp = (info: { mcp: { command: string; args: string[]; env: Record<string, string> } }) => ({ file: settings, json: ["mcpServers", MCP_NAME], value: { command: info.mcp.command, args: info.mcp.args, env: info.mcp.env } });+ if (at >= 0) {+ const set = (models as Array<Record<string, unknown>>)[at].baseUrl;+ return {+ current: typeof set === "string" ? set : null,+ fallback: DEFAULTS[type],+ edits: (info) => [{ file: settings, json: ["modelProviders", type, String(at), "baseUrl"], value: info.url }, mcp(info)],+ };+ }+ const envFile = join(dir, ".env");+ const name = ENV_NAME[type];+ return {+ current: envAt(envFile, name) ?? env[name]?.trim() ?? null,+ fallback: DEFAULTS[type],+ edits: (info) => [{ file: envFile, env: name, value: info.url }, mcp(info)],+ note: `A .env in your project folder that sets ${name} too wins over ~/.qwen/.env.`,+ };+ },+ connect: ({ url, mcp }) => [+ `In ~/.qwen/settings.json, set "baseUrl": "${url}" on the model you use under "modelProviders" (or OPENAI_BASE_URL / ANTHROPIC_BASE_URL in ~/.qwen/.env)`,+ `In ~/.qwen/settings.json, add: "mcpServers": { "${MCP_NAME}": { "command": ${JSON.stringify(mcp.command)}, "args": ${JSON.stringify(mcp.args)}, "env": ${JSON.stringify(mcp.env)} } }`,+ "Restart Qwen Code.",+ ],+};diff --git a/plugin/src/cam.ts b/plugin/src/cam.tsindex c8d5ef5..01b6b4e 100644--- a/plugin/src/cam.ts+++ b/plugin/src/cam.ts@@ -243,7 +243,7 @@ async function main(): Promise<void> {return;}// v0.11: a platform using the core alone (platforms.ts, ADAPTERS.md): registers the route from the engine to where its- // requests go now, and prints what to set in the platform; with --apply, sets it (backed up, recorded for+ // requests go now, and prints what to set in the platform; with --apply, sets it (each setting's earlier value recorded for// `disconnect`). --base-url names that address; --provider the provider, for a platform with one per provider.if (command === "connect" || command === "disconnect") {const platform = corePlatformOf(threadId);@@ -264,10 +264,14 @@ async function main(): Promise<void> {const route = registerRoute({ platform: platform.name, baseUrl });const url = routeBaseUrl(port, route.id).replace("localhost", "127.0.0.1");const mcp = { command: stableNode(), args: [join(import.meta.dirname, "plugin-server.ts")], env: { CAM_HOST: platform.name } };+ if (apply && plan?.manual) {+ console.log([`${platform.title}: ${plan.manual}.`, `${url} -> ${baseUrl}`, ...platform.connect({ url, mcp }).map((step, at) => `${at + 1}. ${step}`)].join("\n"));+ return;+ }if (apply) {- if (!plan) throw new Error(`${platform.title}: its settings cannot be written yet; set them by hand: cam connect ${platform.name}`);+ if (!plan) throw new Error(`${platform.title}: its settings are not in a file this command writes; set them by hand: cam connect ${platform.name}`);const files = applyEdits(platform.name, plan.edits({ url, mcp }), dataDir());- console.log([`${platform.title}: requests go through the engine to ${baseUrl}.`, `Changed (backed up first): ${files.join(", ")}`, ...(plan.note ? [plan.note] : []), `Restart ${platform.title}. To undo: cam disconnect ${platform.name}`].join("\n"));+ console.log([`${platform.title}: requests go through the engine to ${baseUrl}.`, `Changed: ${files.join(", ")}`, ...(plan.note ? [plan.note] : []), `Restart ${platform.title}. To undo: cam disconnect ${platform.name}`].join("\n"));return;}// Plain lines, to copy from: inside JSON the paths' backslashes would be escaped twice.diff --git a/plugin/src/core/platform.ts b/plugin/src/core/platform.tsindex ef492dd..ebe5a61 100644--- a/plugin/src/core/platform.ts+++ b/plugin/src/core/platform.ts@@ -18,7 +18,8 @@ export type ConnectInfo = {// edits: what to write (core/config-edit.ts). provider: for a platform with one address per model provider, the one// the user named (or the platform's shell said).export type SetupContext = { home: string; env: NodeJS.ProcessEnv; provider: string | null };-export type SetupPlan = { current: string | null; fallback: string | null; edits: (info: ConnectInfo) => ConfigEdit[]; note?: string };+// manual: why the settings are only printed, not written (a format this tool does not write, such as YAML).+export type SetupPlan = { current: string | null; fallback: string | null; edits: (info: ConnectInfo) => ConfigEdit[]; note?: string; manual?: string };// The name of the plugin's MCP server in a platform's settings.export const MCP_NAME = "context-attachment-manager";diff --git a/plugin/src/platforms.ts b/plugin/src/platforms.tsindex 2acb4d2..a68d93b 100644--- a/plugin/src/platforms.ts+++ b/plugin/src/platforms.ts@@ -5,13 +5,18 @@// so it is not in CORE_PLATFORMS; `cam detect` still names it.// Input: none. Output: the registry, and which platform a shell command runs in.+import { cherryStudio } from "./adapters/cherry-studio/platform.ts";+import { cline } from "./adapters/cline/platform.ts";import { geminiCli } from "./adapters/gemini-cli/platform.ts";+import { goose } from "./adapters/goose/platform.ts";+import { kiloCode } from "./adapters/kilo-code/platform.ts";import { opencode } from "./adapters/opencode/platform.ts";import { pi } from "./adapters/pi/platform.ts";+import { qwenCode } from "./adapters/qwen-code/platform.ts";import { workbuddy } from "./adapters/workbuddy/platform.ts";import type { CorePlatform } from "./core/platform.ts";-export const CORE_PLATFORMS: CorePlatform[] = [workbuddy, opencode, geminiCli, pi];+export const CORE_PLATFORMS: CorePlatform[] = [workbuddy, opencode, geminiCli, pi, qwenCode, cline, kiloCode, cherryStudio, goose];export const PANEL_PLATFORMS = ["codex", "claude"] as const;export const corePlatformOf = (name: string | null | undefined): CorePlatform | null => CORE_PLATFORMS.find((platform) => platform.name === name) ?? null;