summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorzerone0x <[email protected]>2026-01-19 03:17:49 +0800
committerGitHub <[email protected]>2026-01-18 13:17:49 -0600
commit38c641a2fc6d45c504d419609359f64710a4e732 (patch)
treee7ee45d701367ba6c9fb0f7cf0dae343df0b0ab7
parent501ef2d989afde09b54299d309442a7b1a39a680 (diff)
downloadopencode-38c641a2fc6d45c504d419609359f64710a4e732.tar.gz
opencode-38c641a2fc6d45c504d419609359f64710a4e732.zip
fix(tool): treat .fbs files as text instead of images (#9276)
Co-authored-by: Claude <[email protected]>
-rw-r--r--packages/opencode/src/tool/read.ts4
-rw-r--r--packages/opencode/test/tool/read.test.ts29
2 files changed, 32 insertions, 1 deletions
diff --git a/packages/opencode/src/tool/read.ts b/packages/opencode/src/tool/read.ts
index ce4ab2861..3b1484cbc 100644
--- a/packages/opencode/src/tool/read.ts
+++ b/packages/opencode/src/tool/read.ts
@@ -59,7 +59,9 @@ export const ReadTool = Tool.define("read", {
throw new Error(`File not found: ${filepath}`)
}
- const isImage = file.type.startsWith("image/") && file.type !== "image/svg+xml"
+ // Exclude SVG (XML-based) and vnd.fastbidsheet (.fbs extension, commonly FlatBuffers schema files)
+ const isImage =
+ file.type.startsWith("image/") && file.type !== "image/svg+xml" && file.type !== "image/vnd.fastbidsheet"
const isPdf = file.type === "application/pdf"
if (isImage || isPdf) {
const mime = file.type
diff --git a/packages/opencode/test/tool/read.test.ts b/packages/opencode/test/tool/read.test.ts
index 04ffc80ea..7250bd2fd 100644
--- a/packages/opencode/test/tool/read.test.ts
+++ b/packages/opencode/test/tool/read.test.ts
@@ -300,4 +300,33 @@ describe("tool.read truncation", () => {
},
})
})
+
+ test(".fbs files (FlatBuffers schema) are read as text, not images", async () => {
+ await using tmp = await tmpdir({
+ init: async (dir) => {
+ // FlatBuffers schema content
+ const fbsContent = `namespace MyGame;
+
+table Monster {
+ pos:Vec3;
+ name:string;
+ inventory:[ubyte];
+}
+
+root_type Monster;`
+ await Bun.write(path.join(dir, "schema.fbs"), fbsContent)
+ },
+ })
+ await Instance.provide({
+ directory: tmp.path,
+ fn: async () => {
+ const read = await ReadTool.init()
+ const result = await read.execute({ filePath: path.join(tmp.path, "schema.fbs") }, ctx)
+ // Should be read as text, not as image
+ expect(result.attachments).toBeUndefined()
+ expect(result.output).toContain("namespace MyGame")
+ expect(result.output).toContain("table Monster")
+ },
+ })
+ })
})