opencode-tui-image-clipboard-fix 1.0.15 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +8 -10
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -132,24 +132,22 @@ export const ImageClipboardFix = async ({ client, directory }) => {
132
132
  */
133
133
  "experimental.chat.messages.transform": async (input, output) => {
134
134
  for (const message of output.messages) {
135
- // 只处理用户消息
136
135
  if (message.info?.role !== "user")
137
136
  continue;
138
137
  const { parts } = message;
139
- // 只处理当前会话的消息(缓存中有记录的)
140
- // 历史消息不在缓存中,跳过添加提示
138
+ const textPart = parts.find((p) => p.type === "text");
139
+ // 清理历史消息中已存储的 [Image Reference:] 提示
140
+ if (textPart?.text?.includes("[Image Reference:")) {
141
+ textPart.text = textPart.text.replace(/\n\n\[Image Reference:[^\]]*\]/g, "");
142
+ }
143
+ // 只对当前消息(缓存中有记录)添加提示
141
144
  let imagePaths;
142
145
  if (message.info?.id) {
143
146
  imagePaths = messageImagePaths.get(message.info.id);
144
147
  }
145
- // 如果缓存中有路径(当前消息),替换文本并添加提示
146
- if (imagePaths && imagePaths.size > 0) {
147
- const textPart = parts.find((p) => p.type === "text");
148
- if (textPart && textPart.text && !textPart.text.includes("[Image Reference:")) {
149
- textPart.text = modifyTextContent(textPart.text, imagePaths);
150
- }
148
+ if (imagePaths && imagePaths.size > 0 && textPart?.text) {
149
+ textPart.text = modifyTextContent(textPart.text, imagePaths);
151
150
  }
152
- // 移除图片 FilePart(所有消息都移除,避免模型报错)
153
151
  removeImagePartsSilently(parts);
154
152
  }
155
153
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-tui-image-clipboard-fix",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "type": "module",
5
5
  "displayName": "Image Clipboard Fix",
6
6
  "description": "OpenCode TUI plugin to fix image paste issues - saves clipboard images locally and replaces [Image N] with file paths",