From 0b98c0b8db4db2ca0d03c60435541881e1212bc2 Mon Sep 17 00:00:00 2001 From: Divit Kashyap <162712154+divitkashyap@users.noreply.github.com> Date: Sun, 24 May 2026 13:33:42 +0100 Subject: [PATCH] feat(opencode): add trigger words for inline image attachments Skills like vision-analysis auto-activate based on trigger words in the user's message text (e.g. "screenshot", "describe", "analyze"). Inline images sent to the LLM only include the file part with no surrounding text, so those skills never see anything to match against. Extract a trigger word from the filename before pushing a media file part to the model message: Screenshot 2026-04-08 at 2.54.51 pm.png -> [screenshot] clipboard-2026-05.png -> [clipboard] photo.jpg -> [photo] other images -> [image] Refs #21514 --- packages/opencode/src/session/message-v2.ts | 12 ++++++++++++ packages/opencode/test/session/message-v2.test.ts | 1 + 2 files changed, 13 insertions(+) diff --git a/packages/opencode/src/session/message-v2.ts b/packages/opencode/src/session/message-v2.ts index 2745ff4f45d7..cc558f5a6032 100644 --- a/packages/opencode/src/session/message-v2.ts +++ b/packages/opencode/src/session/message-v2.ts @@ -714,6 +714,18 @@ export const toModelMessagesEffect = Effect.fnUntraced(function* ( text: `[Attached ${part.mime}: ${part.filename ?? "file"}]`, }) } else { + if (isMedia(part.mime)) { + const filename = part.filename ?? "" + const lower = filename.toLowerCase() + let trigger = "image" + if (lower.includes("screenshot")) trigger = "screenshot" + else if (lower.includes("clipboard")) trigger = "clipboard" + else if (lower.includes("photo")) trigger = "photo" + userMessage.parts.push({ + type: "text", + text: `[${trigger}]`, + }) + } userMessage.parts.push({ type: "file", url: part.url, diff --git a/packages/opencode/test/session/message-v2.test.ts b/packages/opencode/test/session/message-v2.test.ts index 82bed0e9cc6f..8efd60b8498a 100644 --- a/packages/opencode/test/session/message-v2.test.ts +++ b/packages/opencode/test/session/message-v2.test.ts @@ -303,6 +303,7 @@ describe("session.message-v2.toModelMessage", () => { role: "user", content: [ { type: "text", text: "hello" }, + { type: "text", text: "[image]" }, { type: "file", mediaType: "image/png",