diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts index b2816c0ef..08c3d7809 100644 --- a/packages/opencode/src/session/prompt.ts +++ b/packages/opencode/src/session/prompt.ts @@ -907,22 +907,32 @@ export namespace SessionPrompt { extra: { bypassCwdCheck: true, ...info.model }, metadata: async () => {}, }) - pieces.push( - { - id: Identifier.ascending("part"), - messageID: info.id, - sessionID: input.sessionID, - type: "text", - synthetic: true, - text: result.output, - }, - { + pieces.push({ + id: Identifier.ascending("part"), + messageID: info.id, + sessionID: input.sessionID, + type: "text", + synthetic: true, + text: result.output, + }) + if (result.attachments?.length) { + pieces.push( + ...result.attachments.map((attachment) => ({ + ...attachment, + synthetic: true, + filename: attachment.filename ?? part.filename, + messageID: info.id, + sessionID: input.sessionID, + })), + ) + } else { + pieces.push({ ...part, id: part.id ?? Identifier.ascending("part"), messageID: info.id, sessionID: input.sessionID, - }, - ) + }) + } }) .catch((error) => { log.error("failed to read file", { error }) diff --git a/packages/plugin/package.json b/packages/plugin/package.json index b158923d6..c3572c5da 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -24,4 +24,4 @@ "typescript": "catalog:", "@typescript/native-preview": "catalog:" } -} \ No newline at end of file +} diff --git a/packages/sdk/js/package.json b/packages/sdk/js/package.json index 5fbfb5eb0..f739788f6 100644 --- a/packages/sdk/js/package.json +++ b/packages/sdk/js/package.json @@ -26,4 +26,4 @@ "publishConfig": { "directory": "dist" } -} \ No newline at end of file +}