diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts index 05ba4b0db0..de9e72b479 100644 --- a/packages/core/src/config.ts +++ b/packages/core/src/config.ts @@ -16,7 +16,7 @@ import { Global } from "@opencode-ai/util/global" import { Location } from "./location" import { AbsolutePath } from "./schema" import { ConfigAgent } from "./config/agent" -import { ConfigAttachments } from "./config/attachments" +import { ConfigMedia } from "./config/media" import { ConfigCompaction } from "./config/compaction" import { ConfigCommand } from "./config/command" import { ConfigExperimental } from "./config/experimental" @@ -85,8 +85,8 @@ export class Info extends Schema.Class("Config.Info")({ lsp: ConfigLSP.Info.pipe(Schema.optional).annotate({ description: "Enable built-in language servers or configure server overrides", }), - attachments: ConfigAttachments.Info.pipe(Schema.optional).annotate({ - description: "Attachment processing configuration", + media: ConfigMedia.Info.pipe(Schema.optional).annotate({ + description: "Media processing configuration", }), tool_output: ConfigToolOutput.Info.pipe(Schema.optional).annotate({ description: "Tool output truncation thresholds", diff --git a/packages/core/src/config/attachments.ts b/packages/core/src/config/media.ts similarity index 62% rename from packages/core/src/config/attachments.ts rename to packages/core/src/config/media.ts index ea7862c0fa..fa5dad7630 100644 --- a/packages/core/src/config/attachments.ts +++ b/packages/core/src/config/media.ts @@ -1,15 +1,15 @@ -export * as ConfigAttachments from "./attachments" +export * as ConfigMedia from "./media" import { Schema } from "effect" import { PositiveInt } from "../schema" -export class Image extends Schema.Class("Config.Attachments.Image")({ +export class Image extends Schema.Class("Config.Media.Image")({ auto_resize: Schema.Boolean.pipe(Schema.optional), max_width: PositiveInt.pipe(Schema.optional), max_height: PositiveInt.pipe(Schema.optional), max_base64_bytes: PositiveInt.pipe(Schema.optional), }) {} -export class Info extends Schema.Class("Config.Attachments")({ +export class Info extends Schema.Class("Config.Media")({ image: Image.pipe(Schema.optional), }) {} diff --git a/packages/core/src/image.ts b/packages/core/src/image.ts index f24b222590..961358810a 100644 --- a/packages/core/src/image.ts +++ b/packages/core/src/image.ts @@ -61,7 +61,7 @@ const layer = Layer.effect( const image = Object.assign( {}, ...(yield* config.entries()).flatMap((entry) => - entry.type === "document" && entry.info.attachments?.image ? [entry.info.attachments.image] : [], + entry.type === "document" && entry.info.media?.image ? [entry.info.media.image] : [], ), ) const normalize = yield* loadAdapter diff --git a/packages/core/src/v1/config/migrate.ts b/packages/core/src/v1/config/migrate.ts index afff5bdbd5..512e2b5330 100644 --- a/packages/core/src/v1/config/migrate.ts +++ b/packages/core/src/v1/config/migrate.ts @@ -63,7 +63,7 @@ export function migrate(info: typeof ConfigV1.Info.Type) { watcher: info.watcher, formatter: info.formatter, lsp: info.lsp, - attachments: info.attachment, + media: info.attachment, tool_output: info.tool_output, mcp: mcp(info), compaction: info.compaction && { diff --git a/packages/core/test/config/config.test.ts b/packages/core/test/config/config.test.ts index b3a7cf7de5..aac9e95a4a 100644 --- a/packages/core/test/config/config.test.ts +++ b/packages/core/test/config/config.test.ts @@ -803,7 +803,7 @@ describe("Config", () => { custom: { command: ["custom-fmt", "$FILE"], extensions: [".foo"] }, }, lsp: { typescript: { disabled: true }, custom: { command: ["custom-lsp"], extensions: [".foo"] } }, - attachments: { + media: { image: { auto_resize: false, max_width: 1200, max_height: 900, max_base64_bytes: 1048576 }, }, tool_output: { max_lines: 1000, max_bytes: 32768 }, @@ -890,7 +890,7 @@ describe("Config", () => { typescript: { disabled: true }, custom: { command: ["custom-lsp"], extensions: [".foo"] }, }) - expect(documents[0]?.info.attachments).toEqual({ + expect(documents[0]?.info.media).toEqual({ image: { auto_resize: false, max_width: 1200, max_height: 900, max_base64_bytes: 1048576 }, }) expect(documents[0]?.info.tool_output).toEqual({ max_lines: 1000, max_bytes: 32768 }) @@ -1097,7 +1097,7 @@ describe("Config", () => { expect(documents[0]?.info.references).toEqual({ docs: { path: "../docs", description: "Use for product documentation", hidden: true }, }) - expect(documents[0]?.info.attachments).toEqual({ image: { auto_resize: false, max_width: 1200 } }) + expect(documents[0]?.info.media).toEqual({ image: { auto_resize: false, max_width: 1200 } }) expect(documents[0]?.info.providers?.custom).toMatchObject({ settings: { apiKey: "secret" }, models: { diff --git a/packages/core/test/tool-read.test.ts b/packages/core/test/tool-read.test.ts index 68e93ee54d..c9b549646e 100644 --- a/packages/core/test/tool-read.test.ts +++ b/packages/core/test/tool-read.test.ts @@ -2,7 +2,7 @@ import { beforeEach, describe, expect } from "bun:test" import path from "path" import { Effect, Exit, Layer, PlatformError, Stream } from "effect" import { Config } from "@opencode-ai/core/config" -import { ConfigAttachments } from "@opencode-ai/core/config/attachments" +import { ConfigMedia } from "@opencode-ai/core/config/media" import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder" import { LayerNode } from "@opencode-ai/util/effect/layer-node" import { FileSystem } from "@opencode-ai/core/filesystem" @@ -432,8 +432,8 @@ describe("ReadTool", () => { new Config.Document({ type: "document", info: new Config.Info({ - attachments: new ConfigAttachments.Info({ - image: new ConfigAttachments.Image({ auto_resize: false, max_width: 4 }), + media: new ConfigMedia.Info({ + image: new ConfigMedia.Image({ auto_resize: false, max_width: 4 }), }), }), }), @@ -475,7 +475,7 @@ describe("ReadTool", () => { new Config.Document({ type: "document", info: new Config.Info({ - attachments: new ConfigAttachments.Info({ image: new ConfigAttachments.Image({ max_width: 4 }) }), + media: new ConfigMedia.Info({ image: new ConfigMedia.Image({ max_width: 4 }) }), }), }), ]) @@ -514,8 +514,8 @@ describe("ReadTool", () => { new Config.Document({ type: "document", info: new Config.Info({ - attachments: new ConfigAttachments.Info({ - image: new ConfigAttachments.Image({ max_base64_bytes: 1 }), + media: new ConfigMedia.Info({ + image: new ConfigMedia.Image({ max_base64_bytes: 1 }), }), }), }), diff --git a/packages/www/content/docs/(Configure)/attachments.mdx b/packages/www/content/docs/(Configure)/attachments.mdx index 789ed19d64..45af964385 100644 --- a/packages/www/content/docs/(Configure)/attachments.mdx +++ b/packages/www/content/docs/(Configure)/attachments.mdx @@ -111,7 +111,7 @@ Configure image normalization in `opencode.json` or `opencode.jsonc`: ```jsonc title="opencode.jsonc" { "$schema": "https://opencode.ai/config.json", - "attachments": { + "media": { "image": { "auto_resize": true, "max_width": 2000, diff --git a/packages/www/content/docs/config.mdx b/packages/www/content/docs/config.mdx index 413352e907..b9ff6266ae 100644 --- a/packages/www/content/docs/config.mdx +++ b/packages/www/content/docs/config.mdx @@ -267,14 +267,14 @@ this field, but it does not start language servers yet. See the [LSP guide](/lsp) for accepted fields and current limitations. -### Attachments +### Media Control how oversized images loaded by the `read` tool are resized or rejected before they are sent to a model. ```jsonc { - "attachments": { + "media": { "image": { "auto_resize": true, "max_width": 2000, diff --git a/packages/www/content/docs/migrate-v1.mdx b/packages/www/content/docs/migrate-v1.mdx index ff46727f62..bdb6be3c43 100644 --- a/packages/www/content/docs/migrate-v1.mdx +++ b/packages/www/content/docs/migrate-v1.mdx @@ -175,16 +175,16 @@ Rename the singular `snapshot` field to `snapshots`. Its boolean value does not { "snapshots": false } ``` -### Attachments +### Media -Rename the singular `attachment` object to `attachments`. Nested image settings keep the same names: +Rename the singular `attachment` object to `media`. Nested image settings keep the same names: ```jsonc // V1 { "attachment": { "image": { "auto_resize": true } } } // V2 -{ "attachments": { "image": { "auto_resize": true } } } +{ "media": { "image": { "auto_resize": true } } } ``` ### MCP servers